3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
32 * \brief Evaluation functions for sel_evalfunc().
34 * This is an implementation header: there should be no need to use it outside
36 * Users should only use SelectionCollection::evaluate() to evaluate
39 * The functions defined in this header file are all the possible values
40 * for the gmx::SelectionTreeElement::evaluate field (in addition to NULL).
42 * \author Teemu Murtola <teemu.murtola@cbr.su.se>
43 * \ingroup module_selection
45 #ifndef GMX_SELECTION_EVALUATE_H
46 #define GMX_SELECTION_EVALUATE_H
48 #include "gromacs/legacyheaders/typedefs.h"
50 #include "gromacs/selection/indexutil.h"
54 struct gmx_sel_mempool_t;
57 * Data structure for passing information required during evaluation.
59 typedef struct gmx_sel_evaluate_t
61 /** Memory pool for intermediate values. */
62 struct gmx_sel_mempool_t *mp;
63 /** Index group that contains all the atoms. */
64 gmx_ana_index_t *gall;
65 /** Topology information. */
73 /*! \name Utility functions
76 /** Initializes an evaluation data structure. */
78 _gmx_sel_evaluate_init(gmx_sel_evaluate_t *data,
79 struct gmx_sel_mempool_t *mp, gmx_ana_index_t *gall,
80 t_topology *top, t_trxframe *fr, t_pbc *pbc);
81 /** Evaluates the children of a general selection element. */
83 _gmx_sel_evaluate_children(gmx_sel_evaluate_t *data,
84 const gmx::SelectionTreeElementPointer &sel,
86 /** Evaluates the children of a \ref SEL_EXPRESSION element. */
88 _gmx_sel_evaluate_method_params(gmx_sel_evaluate_t *data,
89 const gmx::SelectionTreeElementPointer &sel,
93 /*! \name Misc. evaluation functions
96 /** Evaluates a root selection element. */
98 _gmx_sel_evaluate_root(gmx_sel_evaluate_t *data,
99 const gmx::SelectionTreeElementPointer &sel,
101 /** Evaluates a static group selection element. */
103 _gmx_sel_evaluate_static(gmx_sel_evaluate_t *data,
104 const gmx::SelectionTreeElementPointer &sel,
106 /** Evaluates an arithmetic expression element. */
108 _gmx_sel_evaluate_arithmetic(gmx_sel_evaluate_t *data,
109 const gmx::SelectionTreeElementPointer &sel,
113 /*! \name Subexpression evaluation functions
116 /** Evaluates a subexpression when there is only one reference. */
118 _gmx_sel_evaluate_subexpr_simple(gmx_sel_evaluate_t *data,
119 const gmx::SelectionTreeElementPointer &sel,
121 /** Evaluates a subexpression when the evaluation group is static. */
123 _gmx_sel_evaluate_subexpr_staticeval(gmx_sel_evaluate_t *data,
124 const gmx::SelectionTreeElementPointer &sel,
126 /** Evaluates a subexpression. */
128 _gmx_sel_evaluate_subexpr(gmx_sel_evaluate_t *data,
129 const gmx::SelectionTreeElementPointer &sel,
131 /** Evaluates a subexpression reference when there are no other references. */
133 _gmx_sel_evaluate_subexprref_simple(gmx_sel_evaluate_t *data,
134 const gmx::SelectionTreeElementPointer &sel,
136 /** Evaluates a subexpression reference. */
138 _gmx_sel_evaluate_subexprref(gmx_sel_evaluate_t *data,
139 const gmx::SelectionTreeElementPointer &sel,
143 /*! \name Method evaluation functions
147 /** Evaluates a method expression. */
149 _gmx_sel_evaluate_method(gmx_sel_evaluate_t *data,
150 const gmx::SelectionTreeElementPointer &sel,
152 /** Evaluates a modifier expression. */
154 _gmx_sel_evaluate_modifier(gmx_sel_evaluate_t *data,
155 const gmx::SelectionTreeElementPointer &sel,
159 /*! \name Boolean evaluation functions
162 /** Evaluates a boolean NOT element. */
164 _gmx_sel_evaluate_not(gmx_sel_evaluate_t *data,
165 const gmx::SelectionTreeElementPointer &sel,
167 /** Evaluates a boolean AND element with short-circuiting. */
169 _gmx_sel_evaluate_and(gmx_sel_evaluate_t *data,
170 const gmx::SelectionTreeElementPointer &sel,
172 /** Evaluates a boolean OR element with short-circuiting. */
174 _gmx_sel_evaluate_or(gmx_sel_evaluate_t *data,
175 const gmx::SelectionTreeElementPointer &sel,