Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions | Variables
#include "gmxpre.h"
#include <cstdlib>
#include <cstring>
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/smalloc.h"
#include "keywords.h"
#include "parsetree.h"
#include "selelem.h"
#include "selmethod.h"
#include "selmethod_impl.h"
+ Include dependency graph for sm_same.cpp:

Description

Implements the same selection method.

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

Classes

struct  t_methoddata_same
 Data structure for the same selection method. More...
 

Functions

static void * init_data_same (int npar, gmx_ana_selparam_t *param)
 Allocates data for the same selection method. More...
 
static void init_same (const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
 Initializes the same selection method. More...
 
static void free_data_same (void *data)
 Frees the data allocated for the same selection method. More...
 
static void init_frame_same_int (const gmx::SelMethodEvalContext &context, void *data)
 Initializes the evaluation of the same selection method for a frame. More...
 
static void evaluate_same_int (const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 Evaluates the same selection method. More...
 
static void init_frame_same_str (const gmx::SelMethodEvalContext &context, void *data)
 Initializes the evaluation of the same selection method for a frame. More...
 
static void evaluate_same_str (const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 Evaluates the same selection method. More...
 
void _gmx_selelem_custom_init_same (gmx_ana_selmethod_t **method, const gmx::SelectionParserParameterListPointer &params, void *scanner)
 Does custom processing for parameters of the same selection method. More...
 
static int cmp_int (const void *a, const void *b)
 Helper function for comparison of two integers.
 
static int cmp_str (const void *a, const void *b)
 Helper function for comparison of two strings.
 

Variables

static gmx_ana_selparam_t smparams_same_int []
 Parameters for the same selection method. More...
 
static gmx_ana_selparam_t smparams_same_str []
 Parameters for the same selection method. More...
 
static const char *const help_same []
 Help text for the same selection method. More...
 
gmx_ana_selmethod_t sm_same
 Selection method data for the same method. More...
 
static gmx_ana_selmethod_t sm_same_str
 Selection method data for the same method. More...
 

Function Documentation

void _gmx_selelem_custom_init_same ( gmx_ana_selmethod_t **  method,
const gmx::SelectionParserParameterListPointer params,
void *  scanner 
)

Does custom processing for parameters of the same selection method.

Parameters
[in,out]methodThe method to initialize.
[in,out]paramsPointer to the first parameter.
[in]scannerScanner data structure.

If *method is not a same method, this function returns immediately.

static void evaluate_same_int ( const gmx::SelMethodEvalContext context,
gmx_ana_index_t g,
gmx_ana_selvalue_t out,
void *  data 
)
static

Evaluates the same selection method.

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

Calculates which values in data->val.i can be found in data->as.i (assumed sorted), and writes the corresponding atoms to output. If data->val is sorted, uses a linear scan of both arrays, otherwise a binary search of data->as is performed for each block of values in data->val.

static void evaluate_same_str ( const gmx::SelMethodEvalContext context,
gmx_ana_index_t g,
gmx_ana_selvalue_t out,
void *  data 
)
static

Evaluates the same selection method.

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

Calculates which strings in data->val.s can be found in data->as.s (assumed sorted), and writes the corresponding atoms to output. A binary search of data->as is performed for each block of values in data->val.

static void free_data_same ( void *  data)
static

Frees the data allocated for the same selection method.

Parameters
dataData to free (should point to a t_methoddata_same).
static void * init_data_same ( int  npar,
gmx_ana_selparam_t param 
)
static

Allocates data for the same selection method.

Parameters
[in]nparNot used (should be 2).
[in,out]paramMethod parameters (should point to a copy of smparams_same_int or smparams_same_str).
Returns
Pointer to the allocated data (t_methoddata_same).
static void init_frame_same_int ( const gmx::SelMethodEvalContext context,
void *  data 
)
static

Initializes the evaluation of the same selection method for a frame.

Parameters
[in]contextNot used.
dataShould point to a t_methoddata_same.

Sorts the data->as.i array and removes identical values for faster and simpler lookup.

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

Initializes the evaluation of the same selection method for a frame.

Parameters
[in]contextNot used.
dataShould point to a t_methoddata_same.

Sorts the data->as.s array and removes identical values for faster and simpler lookup.

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

Initializes the same selection method.

Parameters
topNot used.
nparNot used (should be 2).
paramInitialized method parameters (should point to a copy of smparams_same_int or smparams_same_str).
dataPointer to t_methoddata_same to initialize.
Returns
0 on success, -1 on failure.

Variable Documentation

const char* const help_same[]
static
Initial value:
= {
"::",
"",
" same KEYWORD as ATOM_EXPR",
"",
"The keyword [TT]same[tt] can be used to select all atoms for which",
"the given [TT]KEYWORD[tt] matches any of the atoms in [TT]ATOM_EXPR[tt].",
"Keywords that evaluate to integer or string values are supported.",
}

Help text for the same selection method.

Initial value:
= {
"same",
0,
nullptr,
nullptr,
nullptr,
{ "same KEYWORD as ATOM_EXPR", "Extending selections", asize(help_same), help_same },
}
static void init_frame_same_int(const gmx::SelMethodEvalContext &context, void *data)
Initializes the evaluation of the same selection method for a frame.
Definition: sm_same.cpp:328
static void * init_data_same(int npar, gmx_ana_selparam_t *param)
Allocates data for the same selection method.
Definition: sm_same.cpp:219
One group of atoms.
Definition: selvalue.h:59
static void init_same(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
Initializes the same selection method.
Definition: sm_same.cpp:283
static const char *const help_same[]
Help text for the same selection method.
Definition: sm_same.cpp:166
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_same_int[]
Parameters for the same selection method.
Definition: sm_same.cpp:154
static void free_data_same(void *data)
Frees the data allocated for the same selection method.
Definition: sm_same.cpp:304
static void evaluate_same_int(const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
Evaluates the same selection method.
Definition: sm_same.cpp:379

Selection method data for the same method.

gmx_ana_selmethod_t sm_same_str
static
Initial value:
= {
"same",
8 ,
nullptr,
nullptr,
nullptr,
{ nullptr, nullptr, 0, nullptr },
}
static void * init_data_same(int npar, gmx_ana_selparam_t *param)
Allocates data for the same selection method.
Definition: sm_same.cpp:219
One group of atoms.
Definition: selvalue.h:59
static void init_frame_same_str(const gmx::SelMethodEvalContext &context, void *data)
Initializes the evaluation of the same selection method for a frame.
Definition: sm_same.cpp:455
static void init_same(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
Initializes the same selection method.
Definition: sm_same.cpp:283
static gmx_ana_selparam_t smparams_same_str[]
Parameters for the same selection method.
Definition: sm_same.cpp:160
constexpr int asize(T(&)[N])
Calculates the number of elements in a static array at compile time.
Definition: arraysize.h:51
static void free_data_same(void *data)
Frees the data allocated for the same selection method.
Definition: sm_same.cpp:304
static void evaluate_same_str(const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
Evaluates the same selection method.
Definition: sm_same.cpp:501

Selection method data for the same method.

This selection method is used for matching string keywords. The parser never sees this method; _gmx_selelem_custom_init_same() replaces sm_same with this method in cases where it is required.

gmx_ana_selparam_t smparams_same_int[]
static
Initial value:
= {
{ nullptr, { INT_VALUE, -1, { nullptr } }, nullptr, 4 | 32 },
{ "as", { INT_VALUE, -1, { nullptr } }, nullptr, 4 | 16 },
}
One or more integer values.
Definition: selvalue.h:55

Parameters for the same selection method.

gmx_ana_selparam_t smparams_same_str[]
static
Initial value:
= {
{ nullptr, { STR_VALUE, -1, { nullptr } }, nullptr, 4 | 32 },
{ "as", { STR_VALUE, -1, { nullptr } }, nullptr, 4 | 16 },
}
One or more string values.
Definition: selvalue.h:57

Parameters for the same selection method.