Gromacs
2024.4
|
#include "gmxpre.h"
#include "poscalc.h"
#include <cstring>
#include <algorithm>
#include <vector>
#include "gromacs/math/vec.h"
#include "gromacs/selection/indexutil.h"
#include "gromacs/selection/position.h"
#include "gromacs/trajectory/trajectoryframe.h"
#include "gromacs/utility/arrayref.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
#include "centerofmass.h"
Implements gmx::PositionCalculationCollection and functions in poscalc.h.
Classes | |
class | gmx::PositionCalculationCollection::Impl |
Private implementation class for PositionCalculationCollection. More... | |
struct | gmx_ana_poscalc_t |
Data structure for position calculation. More... | |
Functions | |
static e_index_t | index_type_for_poscalc (e_poscalc_t type) |
Returns the partition type for a given position type. More... | |
PositionCalculationCollection::RequiredTopologyInfo | gmx::anonymous_namespace{poscalc.cpp}::requiredTopologyInfo (e_poscalc_t type, int flags) |
Helper function for determining required topology information. | |
static void | set_poscalc_maxindex (gmx_ana_poscalc_t *pc, gmx_ana_index_t *g, bool bBase) |
Initializes position calculation using the maximum possible input index. More... | |
static bool | can_use_base (gmx_ana_poscalc_t *pc) |
Checks whether a position calculation should use a base at all. More... | |
static bool | should_merge (gmx_ana_poscalc_t *pc1, gmx_ana_poscalc_t *pc2, gmx_ana_index_t *g1, gmx_ana_index_t *g) |
Checks whether two position calculations should use a common base. More... | |
static gmx_ana_poscalc_t * | create_simple_base (gmx_ana_poscalc_t *pc) |
Creates a static base for position calculation. More... | |
static void | merge_to_base (gmx_ana_poscalc_t *base, gmx_ana_poscalc_t *pc) |
Merges a calculation into another calculation such that the new calculation can be used as a base. More... | |
static void | merge_bases (gmx_ana_poscalc_t *tbase, gmx_ana_poscalc_t *mbase) |
Merges two bases into one. More... | |
static void | setup_base (gmx_ana_poscalc_t *pc) |
Setups the static base calculation for a position calculation. More... | |
void | gmx_ana_poscalc_set_flags (gmx_ana_poscalc_t *pc, int flags) |
Sets the flags for position calculation. More... | |
void | gmx_ana_poscalc_set_maxindex (gmx_ana_poscalc_t *pc, gmx_ana_index_t *g) |
Sets the maximum possible input index group for position calculation. More... | |
void | gmx_ana_poscalc_init_pos (gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p) |
Initializes positions for position calculation output. More... | |
void | gmx_ana_poscalc_free (gmx_ana_poscalc_t *pc) |
Frees the memory allocated for position calculation. More... | |
gmx::PositionCalculationCollection::RequiredTopologyInfo | gmx_ana_poscalc_required_topology_info (gmx_ana_poscalc_t *pc) |
Returns true if the position calculation requires topology information. More... | |
void | gmx_ana_poscalc_update (gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p, gmx_ana_index_t *g, t_trxframe *fr, const t_pbc *pbc) |
Updates a single COM/COG structure for a frame. More... | |
|
static |
Checks whether a position calculation should use a base at all.
[in] | pc | Position calculation data to check. |
pc
can use a base and gets some benefit out of it, false otherwise.
|
static |
Creates a static base for position calculation.
pc | Data structure to copy. |
pc
.Creates and returns a deep copy of pc
, but clears the POS_DYNAMIC and POS_MASKONLY flags. The newly created structure is set as the base (gmx_ana_poscalc_t::sbase
) of pc
and inserted in the collection before pc
.
void gmx_ana_poscalc_free | ( | gmx_ana_poscalc_t * | pc | ) |
Frees the memory allocated for position calculation.
pc | Position calculation data to be freed. |
The pc
pointer is invalid after the call.
void gmx_ana_poscalc_init_pos | ( | gmx_ana_poscalc_t * | pc, |
gmx_ana_pos_t * | p | ||
) |
Initializes positions for position calculation output.
[in] | pc | Position calculation data structure. |
[out] | p | Output positions. |
Calls to gmx_ana_poscalc_update() using pc
should use only positions initialized with this function. The p->g
pointer is initialized to point to an internal group that contains the maximum index group set with gmx_ana_poscalc_set_maxindex().
gmx::PositionCalculationCollection::RequiredTopologyInfo gmx_ana_poscalc_required_topology_info | ( | gmx_ana_poscalc_t * | pc | ) |
Returns true if the position calculation requires topology information.
[in] | pc | Position calculation data to query. |
pc
requires for initialization and/or evaluation. void gmx_ana_poscalc_set_flags | ( | gmx_ana_poscalc_t * | pc, |
int | flags | ||
) |
Sets the flags for position calculation.
[in,out] | pc | Position calculation data structure. |
[in] | flags | New flags. |
flags
are added to the old flags. If calculation type is POS_ATOM, POS_MASS is automatically cleared. If both POS_DYNAMIC and POS_MASKONLY are provided, POS_DYNAMIC is cleared. If calculation type is not POS_RES or POS_MOL, POS_COMPLMAX and POS_COMPLWHOLE are automatically cleared.
void gmx_ana_poscalc_set_maxindex | ( | gmx_ana_poscalc_t * | pc, |
gmx_ana_index_t * | g | ||
) |
Sets the maximum possible input index group for position calculation.
[in,out] | pc | Position calculation data structure. |
[in] | g | Maximum index group for the calculation. |
Subsequent calls to gmx_ana_poscalc_update() should use only subsets of g
for evaluation.
The topology should have been set for the collection of which pc
is a member.
void gmx_ana_poscalc_update | ( | gmx_ana_poscalc_t * | pc, |
gmx_ana_pos_t * | p, | ||
gmx_ana_index_t * | g, | ||
t_trxframe * | fr, | ||
const t_pbc * | pbc | ||
) |
Updates a single COM/COG structure for a frame.
[in] | pc | Position calculation data. |
[in,out] | p | Output positions, initialized previously with gmx_ana_poscalc_init_pos() using pc . |
[in] | g | Index group to use for the update. |
[in] | fr | Current frame. |
[in] | pbc | PBC data, or NULL if no PBC should be used. |
gmx_ana_poscalc_init_frame() should be called for each frame before calling this function.
|
static |
Returns the partition type for a given position type.
[in] | type | e_poscalc_t value to convert. |
e_indet_t
.
|
static |
Merges two bases into one.
[in,out] | tbase | Base calculation to merge to. |
[in] | mbase | Base calculation to merge to tbase . |
After the call, mbase
has been freed and tbase
is used as the base for all calculations that previously had mbase
as their base. It is assumed that any overlap between tbase
and mbase
is in complete blocks, i.e., that the merge is possible.
|
static |
Merges a calculation into another calculation such that the new calculation can be used as a base.
[in,out] | base | Base calculation to merge to. |
[in,out] | pc | Position calculation to merge to base . |
After the call, base
can be used as a base for pc
(or any calculation that used it as a base). It is assumed that any overlap between base
and pc
is in complete blocks, i.e., that the merge is possible.
|
static |
Initializes position calculation using the maximum possible input index.
[in,out] | pc | Position calculation data structure. |
[in] | g | Maximum index group for the calculation. |
[in] | bBase | Whether pc will be used as a base or not. |
bBase
affects on how the pc->gmax
field is initialized.
|
static |
Setups the static base calculation for a position calculation.
[in,out] | pc | Position calculation to setup the base for. |
|
static |
Checks whether two position calculations should use a common base.
[in] | pc1 | Calculation 1 to check for. |
[in] | pc2 | Calculation 2 to check for. |
[in] | g1 | Index group structure that contains the atoms from pc1 . |
[in,out] | g | Working space, should have enough allocated memory to contain the intersection of the atoms in pc1 and pc2 . |