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 Implementation of functions in evaluate.h.
35 * One of the major bottlenecks for selection performance is that all the
36 * evaluation is carried out for atoms.
37 * There are several cases when the evaluation could be done for residues
38 * or molecules instead, including keywords that select by residue and
39 * cases where residue centers are used as reference positions.
40 * Implementing this would require a mechanism for recognizing whether
41 * something can be evaluated by residue/molecule instead by atom, and
42 * converting selections by residue/molecule into selections by atom
55 #include <indexutil.h>
57 #include <selection.h>
58 #include <selmethod.h>
61 #include "selcollection.h"
65 * \param[out] data Evaluation data structure to initialize.
66 * \param[in] gall Index group with all the atoms.
67 * \param[in] top Topology structure for evaluation.
68 * \param[in] fr New frame for evaluation.
69 * \param[in] pbc New PBC information for evaluation.
72 _gmx_sel_evaluate_init(gmx_sel_evaluate_t
*data
, gmx_ana_index_t
*gall
,
73 t_topology
*top
, t_trxframe
*fr
, t_pbc
*pbc
)
82 * Recursively initializes the flags for evaluation.
84 * \param[in,out] sel Selection element to clear.
86 * The \ref SEL_INITFRAME flag is set for \ref SEL_EXPRESSION elements whose
87 * method defines the \p init_frame callback (see sel_framefunc()), and
88 * cleared for other elements.
90 * The \ref SEL_EVALFRAME flag is cleared for all elements.
93 init_frame_eval(t_selelem
*sel
)
97 sel
->flags
&= ~(SEL_INITFRAME
| SEL_EVALFRAME
);
98 if (sel
->type
== SEL_EXPRESSION
)
100 if (sel
->u
.expr
.method
&& sel
->u
.expr
.method
->init_frame
)
102 sel
->flags
|= SEL_INITFRAME
;
105 if (sel
->child
&& sel
->type
!= SEL_SUBEXPRREF
)
107 init_frame_eval(sel
->child
);
114 * \param[in,out] sc The selection collection to evaluate.
115 * \param[in] fr Frame for which the evaluation should be carried out.
116 * \param[in] pbc PBC data, or NULL if no PBC should be used.
117 * \returns 0 on successful evaluation, a non-zero error code on error.
119 * This functions sets the global variables for topology, frame and PBC,
120 * clears some information in the selection to initialize the evaluation
121 * for a new frame, and evaluates \p sel and all the selections pointed by
122 * the \p next pointers of \p sel.
124 * This is the only function that user code should call if they want to
125 * evaluate a selection for a new frame.
128 gmx_ana_selcollection_evaluate(gmx_ana_selcollection_t
*sc
,
129 t_trxframe
*fr
, t_pbc
*pbc
)
131 gmx_sel_evaluate_t data
;
136 _gmx_sel_evaluate_init(&data
, &sc
->gall
, sc
->top
, fr
, pbc
);
137 init_frame_eval(sc
->root
);
141 /* Clear the evaluation group of subexpressions */
142 if (sel
->child
&& sel
->child
->type
== SEL_SUBEXPR
)
144 sel
->child
->u
.cgrp
.isize
= 0;
145 if (sel
->child
->v
.type
== GROUP_VALUE
)
147 sel
->child
->child
->v
.u
.g
->isize
= 0;
152 rc
= sel
->evaluate(&data
, sel
, NULL
);
160 /* Update selection information */
161 for (g
= 0; g
< sc
->nr
; ++g
)
163 gmx_ana_selection_t
*sel
= sc
->sel
[g
];
165 if (sel
->m
!= sel
->orgm
)
167 for (i
= 0; i
< sel
->p
.nr
; ++i
)
169 sel
->m
[i
] = sel
->orgm
[sel
->p
.m
.refid
[i
]];
170 sel
->q
[i
] = sel
->orgq
[sel
->p
.m
.refid
[i
]];
175 sel
->cfrac
= _gmx_selelem_estimate_coverfrac(sel
->selelem
);
176 sel
->avecfrac
+= sel
->cfrac
;
183 * \param[in,out] sc The selection collection to evaluate.
184 * \param[in] nframes Total number of frames.
185 * \returns 0 on successful evaluation, a non-zero error code on error.
188 gmx_ana_selcollection_evaluate_fin(gmx_ana_selcollection_t
*sc
, int nframes
)
193 for (g
= 0; g
< sc
->nr
; ++g
)
195 sel
= sc
->sel
[g
]->selelem
;
198 gmx_ana_index_copy(sc
->sel
[g
]->g
, sel
->v
.u
.g
, FALSE
);
199 sc
->sel
[g
]->g
->name
= NULL
;
200 gmx_ana_indexmap_update(&sc
->sel
[g
]->p
.m
, sc
->sel
[g
]->g
, sc
->bMaskOnly
);
201 sc
->sel
[g
]->p
.nr
= sc
->sel
[g
]->p
.m
.nr
;
204 if (sc
->sel
[g
]->bCFracDyn
)
206 sc
->sel
[g
]->avecfrac
/= nframes
;
213 * \param[in] data Data for the current frame.
214 * \param[in] sel Selection element being evaluated.
215 * \param[in] g Group for which \p sel should be evaluated
216 * (not used, can be NULL).
217 * \returns 0 on success, a non-zero error code on error.
219 * Evaluates the first child element in the group defined by \p sel->u.cgrp.
220 * If \p sel->u.cgrp is empty, nothing is done.
221 * The value of \p sel is not touched (root elements do not evaluate to
224 * This function can be used as \c t_selelem::evaluate for \ref SEL_ROOT
228 _gmx_sel_evaluate_root(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
232 if (sel
->u
.cgrp
.isize
== 0 || !sel
->child
->evaluate
)
237 rc
= sel
->child
->evaluate(data
, sel
->child
,
238 sel
->u
.cgrp
.isize
< 0 ? NULL
: &sel
->u
.cgrp
);
244 * \param[in] data Data for the current frame.
245 * \param[in] sel Selection element being evaluated.
246 * \param[in] g Group for which \p sel should be evaluated.
247 * \returns 0 for success.
249 * Sets the value of \p sel to the intersection of \p g and \p sel->u.cgrp.
251 * This function can be used as \c t_selelem::evaluate for \ref SEL_CONST
252 * elements with value type \ref GROUP_VALUE.
255 _gmx_sel_evaluate_static(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
257 gmx_ana_index_intersection(sel
->v
.u
.g
, &sel
->u
.cgrp
, g
);
262 /*********************************************************************
263 * SUBEXPRESSION EVALUATION
264 *********************************************************************/
267 * \param[in] data Data for the current frame.
268 * \param[in] sel Selection element being evaluated.
269 * \param[in] g Group for which \p sel should be evaluated.
270 * \returns 0 on success, a non-zero error code on error.
272 * Evaluates the child element (there should be exactly one) in \p g.
273 * The number of values is copied from the child to \p sel->v.nr, but
274 * otherwise the value of \p sel is not touched.
276 * This function is used as \c t_selelem::evaluate for \ref SEL_SUBEXPR
277 * elements that are used only once, and hence do not need full subexpression
281 _gmx_sel_evaluate_subexpr_pass(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
285 if (sel
->child
->evaluate
)
287 rc
= sel
->child
->evaluate(data
, sel
->child
, g
);
293 sel
->v
.nr
= sel
->child
->v
.nr
;
298 * \param[in] data Data for the current frame.
299 * \param[in] sel Selection element being evaluated.
300 * \param[in] g Group for which \p sel should be evaluated.
301 * \returns 0 on success, a non-zero error code on error.
303 * Finds the part of \p g for which the subexpression
304 * has not yet been evaluated by comparing \p g to \p sel->u.cgrp.
305 * If the part is not empty, the child expression is evaluated for this
306 * part, and the results merged to the old values of the child.
307 * The value of \p sel itself is undefined after the call.
310 * The call to gmx_ana_index_difference() can take quite a lot of unnecessary
311 * time if the subexpression is evaluated either several times for the same
312 * group or for completely distinct groups.
315 _gmx_sel_evaluate_subexpr(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
317 gmx_ana_index_t gmiss
;
320 if (sel
->u
.cgrp
.isize
== 0)
323 /* We need to check for the presence because the compiler may clear
325 if (sel
->child
->evaluate
)
327 rc
= sel
->child
->evaluate(data
, sel
->child
, g
);
333 /* We need to keep the name for the cgrp across the copy to avoid
334 * problems if g has a name set. */
335 name
= sel
->u
.cgrp
.name
;
336 gmx_ana_index_copy(&sel
->u
.cgrp
, g
, FALSE
);
337 sel
->u
.cgrp
.name
= name
;
342 if (sel
->v
.type
== GROUP_VALUE
)
344 gmx_ana_index_set(&gmiss
, 0, sel
->child
->v
.u
.g
->index
+ sel
->child
->v
.u
.g
->isize
, NULL
, 0);
348 gmx_ana_index_set(&gmiss
, 0, sel
->u
.cgrp
.index
+ sel
->u
.cgrp
.isize
, NULL
, 0);
350 gmx_ana_index_difference(&gmiss
, g
, &sel
->u
.cgrp
);
354 /* We use the value of sel to store the old value of the child before
355 * evaluating the missing values. */
356 if (sel
->v
.type
== GROUP_VALUE
)
358 atom_id
*tmp
= sel
->child
->v
.u
.g
->index
;
359 sel
->child
->v
.u
.g
->index
= sel
->v
.u
.g
->index
;
360 sel
->v
.u
.g
->index
= tmp
;
361 sel
->v
.u
.g
->isize
= sel
->child
->v
.u
.g
->isize
;
362 sel
->child
->v
.u
.g
->isize
= 0;
366 void *tmp
= sel
->child
->v
.u
.ptr
;
367 sel
->child
->v
.u
.ptr
= sel
->v
.u
.ptr
;
370 /* Evaluate the missing values for the child */
371 rc
= sel
->child
->evaluate(data
, sel
->child
, &gmiss
);
376 /* Merge the missing values to the existing ones. */
377 if (sel
->v
.type
== GROUP_VALUE
)
379 gmx_ana_index_merge(sel
->child
->v
.u
.g
, sel
->child
->v
.u
.g
, sel
->v
.u
.g
);
380 gmx_ana_index_merge(&sel
->u
.cgrp
, &sel
->u
.cgrp
, &gmiss
);
386 i
= sel
->u
.cgrp
.isize
- 1;
388 /* TODO: This switch is kind of ugly, but it may be difficult to
389 * do this portably without C++ templates. */
393 for (k
= sel
->u
.cgrp
.isize
+ gmiss
.isize
- 1; k
>= 0; k
--)
395 if (i
< 0 || (j
>= 0 && sel
->u
.cgrp
.index
[i
] < gmiss
.index
[j
]))
397 sel
->child
->v
.u
.i
[k
] = sel
->child
->v
.u
.i
[j
--];
401 sel
->child
->v
.u
.i
[k
] = sel
->v
.u
.i
[i
--];
407 for (k
= sel
->u
.cgrp
.isize
+ gmiss
.isize
- 1; k
>= 0; k
--)
409 if (i
< 0 || (j
>= 0 && sel
->u
.cgrp
.index
[i
] < gmiss
.index
[j
]))
411 sel
->child
->v
.u
.r
[k
] = sel
->child
->v
.u
.r
[j
--];
415 sel
->child
->v
.u
.r
[k
] = sel
->v
.u
.r
[i
--];
421 for (k
= sel
->u
.cgrp
.isize
+ gmiss
.isize
- 1; k
>= 0; k
--)
423 if (i
< 0 || (j
>= 0 && sel
->u
.cgrp
.index
[i
] < gmiss
.index
[j
]))
425 sel
->child
->v
.u
.s
[k
] = sel
->child
->v
.u
.s
[j
--];
429 sel
->child
->v
.u
.s
[k
] = sel
->v
.u
.s
[i
--];
435 /* TODO: Implement this */
436 gmx_impl("position subexpressions not implemented properly");
441 gmx_bug("internal error");
444 /* TODO: With some additional storage, we could do a merge here */
445 sel
->u
.cgrp
.isize
+= gmiss
.isize
;
446 gmx_ana_index_sort(&sel
->u
.cgrp
);
453 * \param[in] data Data for the current frame.
454 * \param[in] sel Selection element being evaluated.
455 * \param[in] g Group for which \p sel should be evaluated.
456 * \returns 0 for success.
458 * This function is used as \c t_selelem:evaluate for \ref SEL_SUBEXPRREF
459 * elements for which the actual value is evaluated directly by the
460 * subexpression, but for which the number of values needs to be passed
464 _gmx_sel_evaluate_subexprref_pass(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
466 sel
->v
.nr
= sel
->child
->child
->v
.nr
;
469 sel
->u
.param
->val
.nr
= sel
->v
.nr
;
470 if (sel
->u
.param
->nvalptr
)
472 *sel
->u
.param
->nvalptr
= sel
->u
.param
->val
.nr
;
479 * \param[in] data Data for the current frame.
480 * \param[in] sel Selection element being evaluated.
481 * \param[in] g Group for which \p sel should be evaluated.
482 * \returns 0 on success, a non-zero error code on error.
484 * If the value type is \ref POS_VALUE, the value of the child is simply
485 * copied to set the value of \p sel (the child subexpression should
486 * already have been evaluated by its root).
487 * If the value type is something else, the child is evaluated for the
488 * group \p g, and the value of the child is then copied.
489 * There should be only one child element.
491 * This function is used as \c t_selelem::evaluate for \ref SEL_SUBEXPRREF
495 _gmx_sel_evaluate_subexprref(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
500 /* We need to check for the presence because the compiler may clear
502 if (g
&& sel
->child
->evaluate
)
506 rc
= sel
->child
->evaluate(data
, sel
->child
, g
);
512 expr
= sel
->child
->child
;
518 sel
->v
.nr
= expr
->v
.nr
;
519 memcpy(sel
->v
.u
.i
, expr
->v
.u
.i
, sel
->v
.nr
*sizeof(*sel
->v
.u
.i
));
523 sel
->v
.nr
= g
->isize
;
524 /* Extract the values corresponding to g */
525 for (i
= j
= 0; i
< g
->isize
; ++i
, ++j
)
527 while (sel
->child
->u
.cgrp
.index
[j
] < g
->index
[i
])
531 sel
->v
.u
.i
[i
] = expr
->v
.u
.i
[j
];
539 sel
->v
.nr
= expr
->v
.nr
;
540 memcpy(sel
->v
.u
.r
, expr
->v
.u
.r
, sel
->v
.nr
*sizeof(*sel
->v
.u
.r
));
544 sel
->v
.nr
= g
->isize
;
545 /* Extract the values corresponding to g */
546 for (i
= j
= 0; i
< g
->isize
; ++i
, ++j
)
548 while (sel
->child
->u
.cgrp
.index
[j
] < g
->index
[i
])
552 sel
->v
.u
.r
[i
] = expr
->v
.u
.r
[j
];
560 sel
->v
.nr
= expr
->v
.nr
;
561 memcpy(sel
->v
.u
.s
, expr
->v
.u
.s
, sel
->v
.nr
*sizeof(*sel
->v
.u
.s
));
565 sel
->v
.nr
= g
->isize
;
566 /* Extract the values corresponding to g */
567 for (i
= j
= 0; i
< g
->isize
; ++i
, ++j
)
569 while (sel
->child
->u
.cgrp
.index
[j
] < g
->index
[i
])
573 sel
->v
.u
.s
[i
] = expr
->v
.u
.s
[j
];
579 /* Currently, there is no need to do anything fancy here,
580 * but some future extensions may need a more flexible
582 gmx_ana_pos_copy(sel
->v
.u
.p
, expr
->v
.u
.p
, FALSE
);
588 gmx_ana_index_copy(sel
->v
.u
.g
, expr
->v
.u
.g
, FALSE
);
592 gmx_ana_index_intersection(sel
->v
.u
.g
, expr
->v
.u
.g
, g
);
596 default: /* should not be reached */
597 gmx_bug("invalid subexpression reference type");
600 /* Store the number of values if needed */
603 sel
->u
.param
->val
.nr
= sel
->v
.nr
;
604 if (sel
->u
.param
->nvalptr
)
606 *sel
->u
.param
->nvalptr
= sel
->u
.param
->val
.nr
;
612 /********************************************************************
613 * METHOD EXPRESSION EVALUATION
614 ********************************************************************/
617 * \param[in] data Data for the current frame.
618 * \param[in] sel Selection element being evaluated.
619 * \param[in] g Group for which \p sel should be evaluated.
620 * \returns 0 on success, a non-zero error code on error.
622 * Evaluates each child of a \ref SEL_EXPRESSION element.
623 * The value of \p sel is not touched.
625 * This function is not used as \c t_selelem::evaluate,
626 * but is used internally.
629 _gmx_sel_evaluate_method_params(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
637 if (child
->evaluate
&& !(child
->flags
& SEL_EVALFRAME
))
639 if (child
->flags
& SEL_ATOMVAL
)
641 rc
= child
->evaluate(data
, child
, g
);
645 rc
= child
->evaluate(data
, child
, NULL
);
646 child
->flags
|= SEL_EVALFRAME
;
659 * \param[in] data Data for the current frame.
660 * \param[in] sel Selection element being evaluated.
661 * \param[in] g Group for which \p sel should be evaluated.
662 * \returns 0 on success, a non-zero error code on error.
664 * Evaluates all child selections (using _gmx_sel_evaluate_method_params())
665 * to evaluate any parameter values.
666 * If this is the first time this expression is evaluated for
667 * the frame, sel_framefunc() callback is called if one is provided.
668 * If a reference position calculation has been initialized for this element,
669 * the positions are also updated, and sel_updatefunc_pos() is used to
670 * evaluate the value. Otherwise, sel_updatefunc() is used.
672 * This function is used as \c t_selelem::evaluate for \ref SEL_EXPRESSION
676 _gmx_sel_evaluate_method(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
680 rc
= _gmx_sel_evaluate_method_params(data
, sel
, g
);
685 if (sel
->flags
& SEL_INITFRAME
)
687 rc
= sel
->u
.expr
.method
->init_frame(data
->top
, data
->fr
, data
->pbc
,
689 sel
->flags
&= ~SEL_INITFRAME
;
697 gmx_ana_poscalc_update(sel
->u
.expr
.pc
, sel
->u
.expr
.pos
, g
,
698 data
->fr
->x
, data
->pbc
);
699 rc
= sel
->u
.expr
.method
->pupdate(data
->top
, data
->fr
, data
->pbc
,
700 sel
->u
.expr
.pos
, &sel
->v
,
705 rc
= sel
->u
.expr
.method
->update(data
->top
, data
->fr
, data
->pbc
, g
,
706 &sel
->v
, sel
->u
.expr
.mdata
);
712 * \param[in] data Data for the current frame.
713 * \param[in] sel Selection element being evaluated.
714 * \param[in] g Group for which \p sel should be evaluated.
715 * \returns 0 on success, a non-zero error code on error.
717 * Evaluates all child selections (using _gmx_sel_evaluate_method_params())
718 * to evaluate any parameter values.
719 * If this is the first time this expression is evaluated for
720 * the frame, sel_framefunc() callback is called if one is provided.
721 * The modifier is then evaluated using sel_updatefunc_pos().
723 * This function is used as \c t_selelem::evaluate for \ref SEL_MODIFIER
727 _gmx_sel_evaluate_modifier(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
731 rc
= _gmx_sel_evaluate_method_params(data
, sel
, g
);
736 if (sel
->flags
& SEL_INITFRAME
)
738 rc
= sel
->u
.expr
.method
->init_frame(data
->top
, data
->fr
, data
->pbc
,
740 sel
->flags
&= ~SEL_INITFRAME
;
746 if (sel
->child
->v
.type
!= POS_VALUE
)
748 gmx_bug("non-position valued modifiers not implemented");
751 rc
= sel
->u
.expr
.method
->pupdate(data
->top
, data
->fr
, data
->pbc
,
753 &sel
->v
, sel
->u
.expr
.mdata
);
758 /********************************************************************
759 * BOOLEAN EXPRESSION EVALUATION
760 ********************************************************************/
763 * \param[in] data Data for the current frame.
764 * \param[in] sel Selection element being evaluated.
765 * \param[in] g Group for which \p sel should be evaluated.
766 * \returns 0 on success, a non-zero error code on error.
768 * Evaluates the child element (there should be only one) in the group
769 * \p g, and then sets the value of \p sel to the complement of the
772 * This function is used as \c t_selelem::evaluate for \ref SEL_BOOLEAN
773 * elements with \ref BOOL_NOT.
776 _gmx_sel_evaluate_not(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
780 rc
= sel
->child
->evaluate(data
, sel
->child
, g
);
785 gmx_ana_index_difference(sel
->v
.u
.g
, g
, sel
->child
->v
.u
.g
);
790 * \param[in] data Data for the current frame.
791 * \param[in] sel Selection element being evaluated.
792 * \param[in] g Group for which \p sel should be evaluated.
793 * \returns 0 on success, a non-zero error code on error.
795 * Short-circuiting evaluation of logical AND expressions.
797 * Starts by evaluating the first child element in the group \p g.
798 * The each following child element is evaluated in the intersection
799 * of all the previous values until all children have been evaluated
800 * or the intersection becomes empty.
801 * The value of \p sel is set to the intersection of all the (evaluated)
804 * If the first child does not have an evaluation function, it is skipped
805 * and the evaluation is started at the second child.
806 * This happens if the first child is a constant expression and during
807 * compilation it was detected that the evaluation group is always a subset
808 * of the constant group
809 * (currently, the compiler never detects this).
811 * This function is used as \c t_selelem::evaluate for \ref SEL_BOOLEAN
812 * elements with \ref BOOL_AND.
815 _gmx_sel_evaluate_and(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
821 /* Skip the first child if it does not have an evaluation function. */
822 if (!child
->evaluate
)
826 rc
= child
->evaluate(data
, child
, g
);
831 gmx_ana_index_copy(sel
->v
.u
.g
, child
->v
.u
.g
, FALSE
);
833 while (child
&& sel
->v
.u
.g
->isize
> 0)
835 rc
= child
->evaluate(data
, child
, sel
->v
.u
.g
);
840 gmx_ana_index_intersection(sel
->v
.u
.g
, sel
->v
.u
.g
, child
->v
.u
.g
);
847 * \param[in] data Data for the current frame.
848 * \param[in] sel Selection element being evaluated.
849 * \param[in] g Group for which \p sel should be evaluated.
850 * \returns 0 on success, a non-zero error code on error.
852 * Short-circuiting evaluation of logical OR expressions.
854 * Starts by evaluating the first child element in the group \p g.
855 * For each subsequent child, finds the part of \p g that is not
856 * included the value of any previous child, and evaluates the child
857 * in that group until the last child is evaluated or all of \p g
858 * is included in some child value.
859 * The value of \p sel is set to the union of all the (evaluated)
862 * If the first child does not have an evaluation function, its value is
863 * used without evaluation.
864 * This happens if the first child is a constant expression, the selection
865 * has been compiled, and the evaluation group is the same for each frame.
866 * In this case, the compiler has taken care of that the child value is a
867 * subset of \p g, making it unnecessary to evaluate it.
869 * This function is used as \c t_selelem::evaluate for \ref SEL_BOOLEAN
870 * elements with \ref BOOL_OR.
873 _gmx_sel_evaluate_or(gmx_sel_evaluate_t
*data
, t_selelem
*sel
, gmx_ana_index_t
*g
)
876 gmx_ana_index_t tmp
, tmp2
;
882 rc
= child
->evaluate(data
, child
, g
);
888 gmx_ana_index_partition(sel
->v
.u
.g
, &tmp
, g
, child
->v
.u
.g
);
890 while (child
&& tmp
.isize
> 0)
893 rc
= child
->evaluate(data
, child
, &tmp
);
898 gmx_ana_index_partition(&tmp
, &tmp2
, &tmp
, child
->v
.u
.g
);
899 sel
->v
.u
.g
->isize
+= tmp
.isize
;
900 tmp
.isize
= tmp2
.isize
;
901 tmp
.index
= tmp2
.index
;
904 gmx_ana_index_sort(sel
->v
.u
.g
);