Gromacs  2020.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Functions | Variables
#include "gmxpre.h"
#include <cctype>
#include <cstring>
#include <regex>
#include <string>
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
#include "keywords.h"
#include "parsetree.h"
#include "position.h"
#include "scanner.h"
#include "selelem.h"
#include "selmethod.h"
+ Include dependency graph for sm_keywords.cpp:

Description

Implements internal selection methods for numeric and string keyword evaluation.

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

Classes

struct  t_methoddata_kwint
 Data structure for integer keyword expression evaluation. More...
 
struct  t_methoddata_kwreal
 Data structure for real keyword expression evaluation. More...
 
class  anonymous_namespace{sm_keywords.cpp}::StringKeywordMatchItem
 Single item in the list of strings/regular expressions to match. More...
 
struct  anonymous_namespace{sm_keywords.cpp}::t_methoddata_kwstr
 Data structure for string keyword expression evaluation. More...
 
struct  t_methoddata_kweval
 Data structure for keyword evaluation in arbitrary groups. More...
 

Typedefs

typedef struct t_methoddata_kwint t_methoddata_kwint
 Data structure for integer keyword expression evaluation. More...
 
typedef struct t_methoddata_kwreal t_methoddata_kwreal
 Data structure for real keyword expression evaluation. More...
 

Functions

static void * init_data_kwint (int npar, gmx_ana_selparam_t *param)
 Allocates data for integer keyword evaluation. More...
 
static void * init_data_kwreal (int npar, gmx_ana_selparam_t *param)
 Allocates data for real keyword evaluation. More...
 
static void * init_data_kwstr (int npar, gmx_ana_selparam_t *param)
 Allocates data for string keyword evaluation. More...
 
static void init_kwint (const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
 /brief Initializes data for integer keyword evaluation. More...
 
static void init_kwreal (const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
 Initializes data for real keyword evaluation. More...
 
static void init_kwstr (const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
 Initializes data for string keyword evaluation. More...
 
static void free_data_kwstr (void *data)
 Frees the memory allocated for string keyword evaluation. More...
 
static void evaluate_keyword_int (const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 Evaluates integer selection keywords. More...
 
static void evaluate_keyword_real (const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 Evaluates real selection keywords. More...
 
static void evaluate_keyword_str (const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 Evaluates string selection keywords. More...
 
static void init_kweval (const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
 Initializes keyword evaluation for an arbitrary group. More...
 
static void init_output_kweval (const gmx_mtop_t *top, gmx_ana_selvalue_t *out, void *data)
 Initializes output for keyword evaluation in an arbitrary group. More...
 
static void free_data_kweval (void *data)
 Frees the data allocated for keyword evaluation in an arbitrary group. More...
 
static void init_frame_kweval (const gmx::SelMethodEvalContext &context, void *data)
 Initializes frame evaluation for keyword evaluation in an arbitrary group. More...
 
static void evaluate_kweval (const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 Evaluates keywords in an arbitrary group. More...
 
static void evaluate_kweval_pos (const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
 Evaluates keywords in an arbitrary set of positions. More...
 
void _gmx_selelem_set_kwstr_match_type (const gmx::SelectionTreeElementPointer &sel, gmx::SelectionStringMatchType matchType)
 Sets the string match type for string keyword evaluation. More...
 
static
gmx::SelectionTreeElementPointer 
init_evaluator_group (gmx_ana_selmethod_t *method, const gmx::SelectionParserParameterList &params, void *scanner)
 Initializes a selection element for evaluating a keyword in a given group. More...
 
static
gmx::SelectionTreeElementPointer 
init_evaluator_pos (gmx_ana_selmethod_t *method, const gmx::SelectionParserParameterList &params, void *scanner)
 Initializes a selection element for evaluating a keyword in given positions. More...
 
gmx::SelectionTreeElementPointer _gmx_sel_init_keyword_evaluator (gmx_ana_selmethod_t *method, const gmx::SelectionTreeElementPointer &child, void *scanner)
 Initializes a selection element for evaluating a keyword in a given group. More...
 

Variables

static gmx_ana_selparam_t smparams_keyword_int []
 Parameters for integer keyword evaluation. More...
 
static gmx_ana_selparam_t smparams_keyword_real []
 Parameters for real keyword evaluation. More...
 
static gmx_ana_selparam_t smparams_keyword_str []
 Parameters for string keyword evaluation. More...
 
gmx_ana_selmethod_t sm_keyword_int
 Selection method data for integer keyword evaluation. More...
 
gmx_ana_selmethod_t sm_keyword_real
 Selection method data for real keyword evaluation. More...
 
gmx_ana_selmethod_t sm_keyword_str
 Selection method data for string keyword evaluation. More...
 
static gmx_ana_selparam_t smparams_kweval_group []
 Parameters for keyword evaluation in an arbitrary group. More...
 
static gmx_ana_selparam_t smparams_kweval_pos []
 Parameters for keyword evaluation from positions. More...
 

Typedef Documentation

Data structure for integer keyword expression evaluation.

Data structure for real keyword expression evaluation.

Function Documentation

gmx::SelectionTreeElementPointer _gmx_sel_init_keyword_evaluator ( struct gmx_ana_selmethod_t method,
const gmx::SelectionTreeElementPointer child,
void *  scanner 
)

Initializes a selection element for evaluating a keyword in a given group.

Parameters
[in]methodKeyword selection method to evaluate.
[in]childThe group/positions to evaluate method in.
[in]scannerScanner data structure.
Returns
Pointer to the created selection element.

Creates a SEL_EXPRESSION selection element that evaluates the keyword method given by method in the group/positions given by child.

child should be a selection tree that evaluates to GROUP_VALUE or POS_VALUE.

void _gmx_selelem_set_kwstr_match_type ( const gmx::SelectionTreeElementPointer sel,
gmx::SelectionStringMatchType  matchType 
)

Sets the string match type for string keyword evaluation.

Parameters
[in,out]selSelection element to initialize.
[in]matchTypeMethod to use to match string values.

Sets the string matching method for string keyword matching.

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

Evaluates integer selection keywords.

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

Does a binary search to find which atoms match the ranges in the t_methoddata_kwint structure for this selection. Matching atoms are stored in out->u.g.

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

Evaluates real selection keywords.

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

Does a binary search to find which atoms match the ranges in the t_methoddata_kwreal structure for this selection. Matching atoms are stored in out->u.g.

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

Evaluates string selection keywords.

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

Does a linear search to find which atoms match the strings in the t_methoddata_kwstr structure for this selection. Wildcards are allowed in the strings. Matching atoms are stored in out->u.g.

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

Evaluates keywords in an arbitrary group.

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

Calls the evaluation function of the wrapped keyword with the given parameters, with the exception of using t_methoddata_kweval::g for the evaluation group.

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

Evaluates keywords in an arbitrary set of positions.

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

Calls the evaluation function of the wrapped keyword with the given parameters, with the exception of using t_methoddata_kweval::p for the evaluation positions.

static void free_data_kweval ( void *  data)
static

Frees the data allocated for keyword evaluation in an arbitrary group.

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

Frees the memory allocated for all the members of t_methoddata_kweval.

static void free_data_kwstr ( void *  data)
static

Frees the memory allocated for string keyword evaluation.

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

Allocates data for integer keyword evaluation.

Parameters
[in]nparNot used.
paramNot used.
Returns
Pointer to the allocated data (t_methoddata_kwint).

Allocates memory for a t_methoddata_kwint structure.

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

Allocates data for real keyword evaluation.

Parameters
[in]nparNot used.
paramNot used.
Returns
Pointer to the allocated data (t_methoddata_kwreal).

Allocates memory for a t_methoddata_kwreal structure.

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

Allocates data for string keyword evaluation.

Parameters
[in]nparNot used.
paramNot used.
Returns
Pointer to the allocated data (t_methoddata_kwstr).

Allocates memory for a t_methoddata_kwstr structure.

static gmx::SelectionTreeElementPointer init_evaluator_group ( gmx_ana_selmethod_t method,
const gmx::SelectionParserParameterList params,
void *  scanner 
)
static

Initializes a selection element for evaluating a keyword in a given group.

Parameters
[in]methodKeyword selection method to evaluate.
[in]paramsParameters to pass to initialization (the child group).
[in]scannerScanner data structure.
Returns
Pointer to the created selection element.

Implements _gmx_sel_init_keyword_evaluator() for GROUP_VALUE input selections.

static gmx::SelectionTreeElementPointer init_evaluator_pos ( gmx_ana_selmethod_t method,
const gmx::SelectionParserParameterList params,
void *  scanner 
)
static

Initializes a selection element for evaluating a keyword in given positions.

Parameters
[in]methodKeyword selection method to evaluate.
[in]paramsParameters to pass to initialization (the child positions).
[in]scannerScanner data structure.
Returns
Pointer to the created selection element.

Implements _gmx_sel_init_keyword_evaluator() for POS_VALUE input selections.

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

Initializes frame evaluation for keyword evaluation in an arbitrary group.

Parameters
[in]contextEvaluation context.
dataShould point to a t_methoddata_kweval.
static void init_kweval ( const gmx_mtop_t *  top,
int  npar,
gmx_ana_selparam_t param,
void *  data 
)
static

Initializes keyword evaluation for an arbitrary group.

Parameters
[in]topNot used.
[in]nparNot used.
[in]paramNot used.
[in]dataShould point to t_methoddata_kweval.
Returns
0 on success, a non-zero error code on return.

Calls the initialization method of the wrapped keyword.

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

/brief Initializes data for integer keyword evaluation.

Parameters
[in]topNot used.
[in]nparNot used (should be 2).
[in]paramMethod parameters (should point to smparams_keyword_int).
[in]dataShould point to t_methoddata_kwint.
static void init_kwreal ( const gmx_mtop_t *  top,
int  npar,
gmx_ana_selparam_t param,
void *  data 
)
static

Initializes data for real keyword evaluation.

Parameters
[in]topNot used.
[in]nparNot used (should be 2).
[in]paramMethod parameters (should point to smparams_keyword_real).
[in]dataShould point to t_methoddata_kwreal.
Returns
0 (the initialization always succeeds).
static void init_kwstr ( const gmx_mtop_t *  top,
int  npar,
gmx_ana_selparam_t param,
void *  data 
)
static

Initializes data for string keyword evaluation.

Parameters
[in]topNot used.
[in]nparNot used (should be 2).
[in]paramMethod parameters (should point to smparams_keyword_str).
[in]dataShould point to t_methoddata_kwstr.
static void init_output_kweval ( const gmx_mtop_t *  top,
gmx_ana_selvalue_t out,
void *  data 
)
static

Initializes output for keyword evaluation in an arbitrary group.

Parameters
[in]topNot used.
[in,out]outPointer to output data structure.
[in,out]dataShould point to t_methoddata_kweval.
Returns
0 for success.

Variable Documentation

gmx_ana_selmethod_t sm_keyword_int
Initial value:
= {
"kw_int",
8 ,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
{ nullptr, nullptr, 0, nullptr },
}
static void init_kwint(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
/brief Initializes data for integer keyword evaluation.
Definition: sm_keywords.cpp:441
One group of atoms.
Definition: selvalue.h:59
static void * init_data_kwint(int npar, gmx_ana_selparam_t *param)
Allocates data for integer keyword evaluation.
Definition: sm_keywords.cpp:433
static void evaluate_keyword_int(const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
Evaluates integer selection keywords.
Definition: sm_keywords.cpp:458
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_keyword_int[]
Parameters for integer keyword evaluation.
Definition: sm_keywords.cpp:272

Selection method data for integer keyword evaluation.

gmx_ana_selmethod_t sm_keyword_real
Initial value:
= {
"kw_real",
8 ,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
{ nullptr, nullptr, 0, nullptr },
}
static gmx_ana_selparam_t smparams_keyword_real[]
Parameters for real keyword evaluation.
Definition: sm_keywords.cpp:278
static void init_kwreal(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
Initializes data for real keyword evaluation.
Definition: sm_keywords.cpp:515
static void evaluate_keyword_real(const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
Evaluates real selection keywords.
Definition: sm_keywords.cpp:532
One group of atoms.
Definition: selvalue.h:59
constexpr int asize(T(&)[N])
Calculates the number of elements in a static array at compile time.
Definition: arraysize.h:51
static void * init_data_kwreal(int npar, gmx_ana_selparam_t *param)
Allocates data for real keyword evaluation.
Definition: sm_keywords.cpp:507

Selection method data for real keyword evaluation.

gmx_ana_selmethod_t sm_keyword_str
Initial value:
= {
"kw_str",
8 ,
nullptr,
nullptr,
nullptr,
nullptr,
{ nullptr, nullptr, 0, nullptr },
}
static void free_data_kwstr(void *data)
Frees the memory allocated for string keyword evaluation.
Definition: sm_keywords.cpp:629
static gmx_ana_selparam_t smparams_keyword_str[]
Parameters for string keyword evaluation.
Definition: sm_keywords.cpp:284
One group of atoms.
Definition: selvalue.h:59
static void * init_data_kwstr(int npar, gmx_ana_selparam_t *param)
Allocates data for string keyword evaluation.
Definition: sm_keywords.cpp:581
constexpr int asize(T(&)[N])
Calculates the number of elements in a static array at compile time.
Definition: arraysize.h:51
static void evaluate_keyword_str(const gmx::SelMethodEvalContext &context, gmx_ana_index_t *g, gmx_ana_selvalue_t *out, void *data)
Evaluates string selection keywords.
Definition: sm_keywords.cpp:644
static void init_kwstr(const gmx_mtop_t *top, int npar, gmx_ana_selparam_t *param, void *data)
Initializes data for string keyword evaluation.
Definition: sm_keywords.cpp:607

Selection method data for string keyword evaluation.

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

Parameters for integer keyword evaluation.

gmx_ana_selparam_t smparams_keyword_real[]
static
Initial value:
= {
{ nullptr, { REAL_VALUE, -1, { nullptr } }, nullptr, 32 | 4 },
{ nullptr, { REAL_VALUE, -1, { nullptr } }, nullptr, 8 | 16 },
}
One or more real values.
Definition: selvalue.h:56

Parameters for real keyword evaluation.

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

Parameters for string keyword evaluation.

gmx_ana_selparam_t smparams_kweval_group[]
static
Initial value:
= {
{ nullptr, { GROUP_VALUE, 1, { nullptr } }, nullptr, 4 },
}
One group of atoms.
Definition: selvalue.h:59

Parameters for keyword evaluation in an arbitrary group.

gmx_ana_selparam_t smparams_kweval_pos[]
static
Initial value:
= {
{ nullptr, { POS_VALUE, 1, { nullptr } }, nullptr, 4 },
}
One or more position values.
Definition: selvalue.h:58

Parameters for keyword evaluation from positions.