Gromacs
2024.4
|
#include "gmxpre.h"
#include "gromacs/selection/position.h"
#include <cstring>
#include "gromacs/math/vec.h"
#include "gromacs/selection/indexutil.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
Implements functions in position.h.
Functions | |
void | gmx_ana_pos_reserve (gmx_ana_pos_t *pos, int n, int isize) |
Ensures that enough memory has been allocated to store positions. More... | |
void | gmx_ana_pos_reserve_velocities (gmx_ana_pos_t *pos) |
Request memory allocation for velocities. More... | |
void | gmx_ana_pos_reserve_forces (gmx_ana_pos_t *pos) |
Request memory allocation for forces. More... | |
void | gmx_ana_pos_reserve_for_append (gmx_ana_pos_t *pos, int n, int isize, bool bVelocities, bool bForces) |
Reserves memory for use with gmx_ana_pos_append_init(). More... | |
void | gmx_ana_pos_init_const (gmx_ana_pos_t *pos, const rvec x) |
Initializes a gmx_ana_pos_t to represent a constant position. More... | |
void | gmx_ana_pos_copy (gmx_ana_pos_t *dest, gmx_ana_pos_t *src, bool bFirst) |
Copies the evaluated positions to a preallocated data structure. More... | |
void | gmx_ana_pos_set_nr (gmx_ana_pos_t *pos, int nr) |
Sets the number of positions in a position structure. More... | |
void | gmx_ana_pos_empty_init (gmx_ana_pos_t *pos) |
Empties a position data structure with full initialization. More... | |
void | gmx_ana_pos_empty (gmx_ana_pos_t *pos) |
Empties a position data structure. More... | |
void | gmx_ana_pos_append_init (gmx_ana_pos_t *dest, gmx_ana_pos_t *src, int i) |
Appends a position to a preallocated data structure with full initialization. More... | |
void | gmx_ana_pos_append (gmx_ana_pos_t *dest, gmx_ana_pos_t *src, int i, int refid) |
Appends a position to a preallocated data structure. More... | |
void | gmx_ana_pos_append_finish (gmx_ana_pos_t *pos) |
Updates position data structure state after appends. More... | |
void | gmx_ana_pos_add_to_group (gmx_ana_index_t *g, gmx_ana_pos_t *src, int i) |
Appends atoms from a position into a preallocated index group. More... | |
void gmx_ana_pos_add_to_group | ( | gmx_ana_index_t * | g, |
gmx_ana_pos_t * | src, | ||
int | i | ||
) |
Appends atoms from a position into a preallocated index group.
[in,out] | g | Data structure to which the new atoms are appended. |
[in] | src | Data structure from which the position is copied. |
[in] | i | Index in src to copy. |
void gmx_ana_pos_append | ( | gmx_ana_pos_t * | dest, |
gmx_ana_pos_t * | src, | ||
int | i, | ||
int | refid | ||
) |
Appends a position to a preallocated data structure.
[in,out] | dest | Data structure to which the new position is appended. |
[in] | src | Data structure from which the position is copied. |
[in] | i | Index in src to copy. |
[in] | refid | Reference ID in out (all negative values are treated as -1). |
void gmx_ana_pos_append_finish | ( | gmx_ana_pos_t * | pos | ) |
Updates position data structure state after appends.
[in,out] | pos | Position data structure. |
After gmx_ana_pos_empty(), internal state of the position data structure is not consistent before this function is called. This function should be called after any gmx_ana_pos_append() calls have been made.
void gmx_ana_pos_append_init | ( | gmx_ana_pos_t * | dest, |
gmx_ana_pos_t * | src, | ||
int | i | ||
) |
Appends a position to a preallocated data structure with full initialization.
[in,out] | dest | Data structure to which the new position is appended. |
[in] | src | Data structure from which the position is copied. |
[in] | i | Index in from to copy. |
void gmx_ana_pos_copy | ( | gmx_ana_pos_t * | dest, |
gmx_ana_pos_t * | src, | ||
bool | bFirst | ||
) |
Copies the evaluated positions to a preallocated data structure.
[in,out] | dest | Destination positions. |
[in] | src | Source positions. |
[in] | bFirst | If true, memory is allocated for dest and a full copy is made; otherwise, only variable parts are copied, and no memory is allocated. |
dest
should have been initialized somehow (calloc() is enough).
void gmx_ana_pos_empty | ( | gmx_ana_pos_t * | pos | ) |
Empties a position data structure.
[in,out] | pos | Position data structure. |
Sets the number of positions to 0.
void gmx_ana_pos_empty_init | ( | gmx_ana_pos_t * | pos | ) |
Empties a position data structure with full initialization.
[in,out] | pos | Position data structure. |
Sets the number of positions to 0.
void gmx_ana_pos_init_const | ( | gmx_ana_pos_t * | pos, |
const rvec | x | ||
) |
Initializes a gmx_ana_pos_t
to represent a constant position.
[out] | pos | Position data structure to initialize. |
[in] | x | Position vector to use. |
void gmx_ana_pos_reserve | ( | gmx_ana_pos_t * | pos, |
int | n, | ||
int | isize | ||
) |
Ensures that enough memory has been allocated to store positions.
[in,out] | pos | Position data structure. |
[in] | n | Maximum number of positions. |
[in] | isize | Maximum number of atoms. |
Ensures that enough memory is allocated in pos
to calculate n
positions from isize
atoms.
void gmx_ana_pos_reserve_for_append | ( | gmx_ana_pos_t * | pos, |
int | n, | ||
int | isize, | ||
bool | bVelocities, | ||
bool | bForces | ||
) |
Reserves memory for use with gmx_ana_pos_append_init().
[in,out] | pos | Position data structure. |
[in] | n | Maximum number of positions. |
[in] | isize | Maximum number of atoms. |
[in] | bVelocities | Whether to reserve space for velocities. |
[in] | bForces | Whether to reserve space for forces. |
Ensures that enough memory is allocated in pos
to calculate n
positions from isize
atoms.
This method needs to be called instead of gmx_ana_pos_reserve() if the intent is to use gmx_ana_pos_append_init()/gmx_ana_pos_append().
void gmx_ana_pos_reserve_forces | ( | gmx_ana_pos_t * | pos | ) |
Request memory allocation for forces.
[in,out] | pos | Position data structure. |
Currently, this function can only be called after gmx_ana_pos_reserve() has been called at least once with a n
>= 0.
void gmx_ana_pos_reserve_velocities | ( | gmx_ana_pos_t * | pos | ) |
Request memory allocation for velocities.
[in,out] | pos | Position data structure. |
Currently, this function can only be called after gmx_ana_pos_reserve() has been called at least once with a n
>= 0.
void gmx_ana_pos_set_nr | ( | gmx_ana_pos_t * | pos, |
int | nr | ||
) |
Sets the number of positions in a position structure.
[in,out] | pos | Position data structure. |
[in] | nr | Number of positions. |