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

Description

Implements the merge and plus selection modifiers.

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

Classes

struct  methoddata_merge
 Data structure for the merging selection modifiers. More...
 

Typedefs

typedef struct methoddata_merge t_methoddata_merge
 Data structure for the merging selection modifiers. More...
 

Functions

static void * init_data_merge (int npar, gmx_ana_selparam_t *param)
 Allocates data for the merging selection modifiers. More...
 
static void init_merge (const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
 Initializes data for the merging selection modifiers. More...
 
static void init_output_merge (const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 Initializes output for the merge selection modifier. More...
 
static void init_output_plus (const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 Initializes output for the plus selection modifier. More...
 
static void free_data_merge (void *data)
 Frees the memory allocated for the merging selection modifiers. More...
 
static void evaluate_merge (const gmx::SelMethodEvalContext &context, gmx_ana_pos_t *p, gmx_ana_selvalue_t *out, void *data)
 Evaluates the merge selection modifier. More...
 
static void evaluate_plus (const gmx::SelMethodEvalContext &context, gmx_ana_pos_t *p, gmx_ana_selvalue_t *out, void *data)
 Evaluates the plus selection modifier. More...
 
static void init_output_common (const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 Does common initialization to all merging modifiers. More...
 

Variables

static gmx_ana_selparam_t smparams_merge []
 Parameters for the merging selection modifiers. More...
 
static const char helptitle_merge [] = "Merging selections"
 Help title for the merging selection modifiers.
 
static const char *const help_merge []
 Help text for the merging selection modifiers. More...
 
gmx_ana_selmethod_t sm_merge
 Selection method data for the plus modifier. More...
 
gmx_ana_selmethod_t sm_plus
 Selection method data for the plus modifier. More...
 

Typedef Documentation

Data structure for the merging selection modifiers.

Function Documentation

static void evaluate_merge ( const gmx::SelMethodEvalContext context,
gmx_ana_pos_t p,
gmx_ana_selvalue_t out,
void *  data 
)
static

Evaluates the merge selection modifier.

Parameters
[in]contextNot used.
[in]pPositions to merge (should point to data->p1).
[out]outOutput data structure (out->u.p is used).
[in]dataShould point to a t_methoddata_merge.
static void evaluate_plus ( const gmx::SelMethodEvalContext context,
gmx_ana_pos_t p,
gmx_ana_selvalue_t out,
void *  data 
)
static

Evaluates the plus selection modifier.

Parameters
[in]contextNot used.
[in]pPositions to merge (should point to data->p1).
[out]outOutput data structure (out->u.p is used).
[in]dataShould point to a t_methoddata_merge.
static void free_data_merge ( void *  data)
static

Frees the memory allocated for the merging selection modifiers.

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

Frees the memory allocated for t_methoddata_merge.

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

Allocates data for the merging selection modifiers.

Parameters
[in]nparShould be 2 for plus and 3 for merge.
[in,out]paramMethod parameters (should point to a copy of smparams_merge).
Returns
Pointer to the allocated data (t_methoddata_merge).

Allocates memory for a t_methoddata_merge structure.

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

Initializes data for the merging selection modifiers.

Parameters
[in]topNot used.
[in]nparNot used (should be 2 or 3).
[in]paramMethod parameters (should point to smparams_merge).
[in]dataShould point to a t_methoddata_merge.
Returns
0 if everything is successful, -1 on error.
static void init_output_common ( const gmx_mtop_t *  top,
gmx_ana_selvalue_t out,
void *  data 
)
static

Does common initialization to all merging modifiers.

Parameters
[in]topTopology data structure.
[in,out]outPointer to output data structure.
[in,out]dataShould point to t_methoddata_merge.
static void init_output_merge ( const gmx_mtop_t *  top,
gmx_ana_selvalue_t out,
void *  data 
)
static

Initializes output for the merge selection modifier.

Parameters
[in]topTopology data structure.
[in,out]outPointer to output data structure.
[in,out]dataShould point to t_methoddata_merge.
static void init_output_plus ( const gmx_mtop_t *  top,
gmx_ana_selvalue_t out,
void *  data 
)
static

Initializes output for the plus selection modifier.

Parameters
[in]topTopology data structure.
[in,out]outPointer to output data structure.
[in,out]dataShould point to t_methoddata_merge.

Variable Documentation

const char* const help_merge[]
static
Initial value:
= {
"::",
"",
" POSEXPR merge POSEXPR [stride INT]",
" POSEXPR merge POSEXPR [merge POSEXPR ...]",
" POSEXPR plus POSEXPR [plus POSEXPR ...]",
"",
"Basic selection keywords can only create selections where each atom",
"occurs at most once. The [TT]merge[tt] and [TT]plus[tt] selection",
"keywords can be used to work around this limitation. Both create",
"a selection that contains the positions from all the given position",
"expressions, even if they contain duplicates.",
"The difference between the two is that [TT]merge[tt] expects two or more",
"selections with the same number of positions, and the output contains",
"the input positions selected from each expression in turn, i.e.,",
"the output is like A1 B1 A2 B2 and so on. It is also possible to merge",
"selections of unequal size as long as the size of the first is a",
"multiple of the second one. The [TT]stride[tt] parameter can be used",
"to explicitly provide this multiplicity.",
"[TT]plus[tt] simply concatenates the positions after each other, and",
"can work also with selections of different sizes.",
"These keywords are valid only at the selection level, not in any",
"subexpressions.",
}

Help text for the merging selection modifiers.

Initial value:
= {
"merge",
256 ,
nullptr,
nullptr,
nullptr,
{ "merge POSEXPR", helptitle_merge, asize(help_merge), help_merge },
}
static void evaluate_merge(const gmx::SelMethodEvalContext &context, gmx_ana_pos_t *p, gmx_ana_selvalue_t *out, void *data)
Evaluates the merge selection modifier.
Definition: sm_merge.cpp:303
static const char *const help_merge[]
Help text for the merging selection modifiers.
Definition: sm_merge.cpp:119
static const char helptitle_merge[]
Help title for the merging selection modifiers.
Definition: sm_merge.cpp:117
One or more position values.
Definition: selvalue.h:57
static void init_output_merge(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
Initializes output for the merge selection modifier.
Definition: sm_merge.cpp:255
static void free_data_merge(void *data)
Frees the memory allocated for the merging selection modifiers.
Definition: sm_merge.cpp:297
constexpr int asize(T(&)[N])
Calculates the number of elements in a static array at compile time.
Definition: arraysize.h:50
static void init_merge(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
Initializes data for the merging selection modifiers.
Definition: sm_merge.cpp:201
static gmx_ana_selparam_t smparams_merge[]
Parameters for the merging selection modifiers.
Definition: sm_merge.cpp:110
static void * init_data_merge(int npar, gmx_ana_selparam_t *param)
Allocates data for the merging selection modifiers.
Definition: sm_merge.cpp:188

Selection method data for the plus modifier.

Initial value:
= {
"plus",
256 ,
nullptr,
nullptr,
nullptr,
{ "plus POSEXPR", helptitle_merge, asize(help_merge), help_merge },
}
static const char *const help_merge[]
Help text for the merging selection modifiers.
Definition: sm_merge.cpp:119
static const char helptitle_merge[]
Help title for the merging selection modifiers.
Definition: sm_merge.cpp:117
One or more position values.
Definition: selvalue.h:57
static void free_data_merge(void *data)
Frees the memory allocated for the merging selection modifiers.
Definition: sm_merge.cpp:297
constexpr int asize(T(&)[N])
Calculates the number of elements in a static array at compile time.
Definition: arraysize.h:50
static void init_merge(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
Initializes data for the merging selection modifiers.
Definition: sm_merge.cpp:201
static void init_output_plus(const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
Initializes output for the plus selection modifier.
Definition: sm_merge.cpp:276
static gmx_ana_selparam_t smparams_merge[]
Parameters for the merging selection modifiers.
Definition: sm_merge.cpp:110
static void evaluate_plus(const gmx::SelMethodEvalContext &context, gmx_ana_pos_t *p, gmx_ana_selvalue_t *out, void *data)
Evaluates the plus selection modifier.
Definition: sm_merge.cpp:335
static void * init_data_merge(int npar, gmx_ana_selparam_t *param)
Allocates data for the merging selection modifiers.
Definition: sm_merge.cpp:188

Selection method data for the plus modifier.

gmx_ana_selparam_t smparams_merge[]
static
Initial value:
= {
{ nullptr, { POS_VALUE, -1, { nullptr } }, nullptr, 4 | 16 },
{ nullptr, { POS_VALUE, -1, { nullptr } }, nullptr, 4 | 16 },
{ "stride", { INT_VALUE, 1, { nullptr } }, nullptr, 2 },
}
One or more position values.
Definition: selvalue.h:57
One or more integer values.
Definition: selvalue.h:54

Parameters for the merging selection modifiers.