Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions | Variables
#include "gmxpre.h"
#include "gromacs/math/vec.h"
#include "gromacs/selection/nbsearch.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/exceptions.h"
#include "position.h"
#include "selmethod.h"
#include "selmethod_impl.h"
+ Include dependency graph for sm_distance.cpp:

Description

Implements distance-based selection methods.

This file implements the distance, mindistance and within selection methods.

Author
Teemu Murtola teemu.nosp@m..mur.nosp@m.tola@.nosp@m.gmai.nosp@m.l.com

Classes

struct  t_methoddata_distance
 Data structure for distance-based selection method. More...
 

Functions

static void * init_data_common (int npar, gmx_ana_selparam_t *param)
 Allocates data for distance-based selection methods. More...
 
static void init_common (const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
 Initializes a distance-based selection method. More...
 
static void free_data_common (void *data)
 Frees the data allocated for a distance-based selection method. More...
 
static void init_frame_common (const gmx::SelMethodEvalContext &context, void *data)
 Initializes the evaluation of a distance-based within selection method for a frame. More...
 
static void evaluate_distance (const gmx::SelMethodEvalContext &, gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
 Evaluates the distance selection method. More...
 
static void evaluate_within (const gmx::SelMethodEvalContext &, gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
 Evaluates the within selection method. More...
 

Variables

static gmx_ana_selparam_t smparams_distance []
 Parameters for the distance selection method. More...
 
static gmx_ana_selparam_t smparams_mindistance []
 Parameters for the mindistance selection method. More...
 
static gmx_ana_selparam_t smparams_within []
 Parameters for the within selection method. More...
 
static const char helptitle_distance [] = "Selecting based on distance"
 Help title for distance selection methods.
 
static const char *const help_distance []
 Help text for distance selection methods. More...
 
gmx_ana_selmethod_t sm_distance
 Selection method data for the distance method. More...
 
gmx_ana_selmethod_t sm_mindistance
 Selection method data for the distance method. More...
 
gmx_ana_selmethod_t sm_within
 Selection method data for the within method. More...
 

Function Documentation

static void evaluate_distance ( const gmx::SelMethodEvalContext ,
gmx_ana_pos_t pos,
gmx_ana_selvalue_t out,
void *  data 
)
static

Evaluates the distance selection method.

See sel_updatefunc_pos() for description of the parameters. data should point to a t_methoddata_distance.

Calculates the distance of each position from t_methoddata_distance::p and puts them in out->u.r.

static void evaluate_within ( const gmx::SelMethodEvalContext ,
gmx_ana_pos_t pos,
gmx_ana_selvalue_t out,
void *  data 
)
static

Evaluates the within selection method.

See sel_updatefunc() for description of the parameters. data should point to a t_methoddata_distance.

Finds the atoms that are closer than the defined cutoff to t_methoddata_distance::xref and puts them in out.g.

static void free_data_common ( void *  data)
static

Frees the data allocated for a distance-based selection method.

Parameters
dataData to free (should point to a t_methoddata_distance).

Frees the memory allocated for t_methoddata_distance::xref and t_methoddata_distance::nb.

static void init_common ( const gmx_mtop_t *  top,
int  npar,
gmx_ana_selparam_t param,
void *  data 
)
static

Initializes a distance-based selection method.

Parameters
topNot used.
nparNot used (should be 2).
paramMethod parameters (should point to one of the distance parameter arrays).
dataPointer to t_methoddata_distance to initialize.
Returns
0 on success, a non-zero error code on failure.

Initializes the neighborhood search data structure (t_methoddata_distance::nb). Also checks that the cutoff is valid.

static void * init_data_common ( int  npar,
gmx_ana_selparam_t param 
)
static

Allocates data for distance-based selection methods.

Parameters
[in]nparNot used (should be 2).
[in,out]paramMethod parameters (should point to one of the distance parameter arrays).
Returns
Pointer to the allocated data (t_methoddata_distance).

Allocates memory for a t_methoddata_distance structure and initializes the parameter as follows:

static void init_frame_common ( const gmx::SelMethodEvalContext context,
void *  data 
)
static

Initializes the evaluation of a distance-based within selection method for a frame.

Parameters
[in]contextEvaluation context.
dataShould point to a t_methoddata_distance.
Returns
0 on success, a non-zero error code on error.

Initializes the neighborhood search for the current frame.

Variable Documentation

const char* const help_distance[]
static
Initial value:
= {
"::",
"",
" distance from POS [cutoff REAL]",
" mindistance from POS_EXPR [cutoff REAL]",
" within REAL of POS_EXPR",
"",
"[TT]distance[tt] and [TT]mindistance[tt] calculate the distance from the",
"given position(s), the only difference being in that [TT]distance[tt]",
"only accepts a single position, while any number of positions can be",
"given for [TT]mindistance[tt], which then calculates the distance to the",
"closest position.",
"[TT]within[tt] directly selects atoms that are within [TT]REAL[tt] of",
"[TT]POS_EXPR[tt].[PAR]",
"For the first two keywords, it is possible to specify a cutoff to speed",
"up the evaluation: all distances above the specified cutoff are",
"returned as equal to the cutoff.",
}

Help text for distance selection methods.

gmx_ana_selmethod_t sm_distance
Initial value:
= {
"distance",
4 ,
nullptr,
nullptr,
nullptr,
{ "distance from POS [cutoff REAL]", helptitle_distance, asize(help_distance), help_distance },
}
static const char helptitle_distance[]
Help title for distance selection methods.
Definition: sm_distance.cpp:152
static const char *const help_distance[]
Help text for distance selection methods.
Definition: sm_distance.cpp:154
One or more real values.
Definition: selvalue.h:56
static void free_data_common(void *data)
Frees the data allocated for a distance-based selection method.
Definition: sm_distance.cpp:253
static void init_frame_common(const gmx::SelMethodEvalContext &context, void *data)
Initializes the evaluation of a distance-based within selection method for a frame.
Definition: sm_distance.cpp:258
constexpr int asize(T(&)[N])
Calculates the number of elements in a static array at compile time.
Definition: arraysize.h:51
static gmx_ana_selparam_t smparams_distance[]
Parameters for the distance selection method.
Definition: sm_distance.cpp:134
static void init_common(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
Initializes a distance-based selection method.
Definition: sm_distance.cpp:236
static void * init_data_common(int npar, gmx_ana_selparam_t *param)
Allocates data for distance-based selection methods.
Definition: sm_distance.cpp:228
static void evaluate_distance(const gmx::SelMethodEvalContext &, gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
Evaluates the distance selection method.
Definition: sm_distance.cpp:274

Selection method data for the distance method.

gmx_ana_selmethod_t sm_mindistance
Initial value:
= {
"mindistance",
4 ,
nullptr,
nullptr,
nullptr,
{ "mindistance from POS_EXPR [cutoff REAL]", helptitle_distance, asize(help_distance), help_distance },
}
static const char helptitle_distance[]
Help title for distance selection methods.
Definition: sm_distance.cpp:152
static const char *const help_distance[]
Help text for distance selection methods.
Definition: sm_distance.cpp:154
One or more real values.
Definition: selvalue.h:56
static void free_data_common(void *data)
Frees the data allocated for a distance-based selection method.
Definition: sm_distance.cpp:253
static void init_frame_common(const gmx::SelMethodEvalContext &context, void *data)
Initializes the evaluation of a distance-based within selection method for a frame.
Definition: sm_distance.cpp:258
constexpr int asize(T(&)[N])
Calculates the number of elements in a static array at compile time.
Definition: arraysize.h:51
static void init_common(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
Initializes a distance-based selection method.
Definition: sm_distance.cpp:236
static void * init_data_common(int npar, gmx_ana_selparam_t *param)
Allocates data for distance-based selection methods.
Definition: sm_distance.cpp:228
static gmx_ana_selparam_t smparams_mindistance[]
Parameters for the mindistance selection method.
Definition: sm_distance.cpp:140
static void evaluate_distance(const gmx::SelMethodEvalContext &, gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
Evaluates the distance selection method.
Definition: sm_distance.cpp:274

Selection method data for the distance method.

Initial value:
= {
"within",
4 ,
nullptr,
nullptr,
nullptr,
{ "within REAL of POS_EXPR", helptitle_distance, asize(help_distance), help_distance },
}
static void evaluate_within(const gmx::SelMethodEvalContext &, gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
Evaluates the within selection method.
Definition: sm_distance.cpp:295
static gmx_ana_selparam_t smparams_within[]
Parameters for the within selection method.
Definition: sm_distance.cpp:146
static const char helptitle_distance[]
Help title for distance selection methods.
Definition: sm_distance.cpp:152
static const char *const help_distance[]
Help text for distance selection methods.
Definition: sm_distance.cpp:154
One group of atoms.
Definition: selvalue.h:59
static void free_data_common(void *data)
Frees the data allocated for a distance-based selection method.
Definition: sm_distance.cpp:253
static void init_frame_common(const gmx::SelMethodEvalContext &context, void *data)
Initializes the evaluation of a distance-based within selection method for a frame.
Definition: sm_distance.cpp:258
constexpr int asize(T(&)[N])
Calculates the number of elements in a static array at compile time.
Definition: arraysize.h:51
static void init_common(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
Initializes a distance-based selection method.
Definition: sm_distance.cpp:236
static void * init_data_common(int npar, gmx_ana_selparam_t *param)
Allocates data for distance-based selection methods.
Definition: sm_distance.cpp:228

Selection method data for the within method.

gmx_ana_selparam_t smparams_distance[]
static
Initial value:
= {
{ "cutoff", { REAL_VALUE, 1, { nullptr } }, nullptr, 2 },
{ "from", { POS_VALUE, 1, { nullptr } }, nullptr, 4 },
}
One or more real values.
Definition: selvalue.h:56
One or more position values.
Definition: selvalue.h:58

Parameters for the distance selection method.

gmx_ana_selparam_t smparams_mindistance[]
static
Initial value:
= {
{ "cutoff", { REAL_VALUE, 1, { nullptr } }, nullptr, 2 },
{ "from", { POS_VALUE, -1, { nullptr } }, nullptr, 4 | 16 },
}
One or more real values.
Definition: selvalue.h:56
One or more position values.
Definition: selvalue.h:58

Parameters for the mindistance selection method.

gmx_ana_selparam_t smparams_within[]
static
Initial value:
= {
{ nullptr, { REAL_VALUE, 1, { nullptr } }, nullptr, 0 },
{ "of", { POS_VALUE, -1, { nullptr } }, nullptr, 4 | 16 },
}
One or more real values.
Definition: selvalue.h:56
One or more position values.
Definition: selvalue.h:58

Parameters for the within selection method.