Fix bug in selection subexpression handling.
authorTeemu Murtola <teemu.murtola@gmail.com>
Sat, 6 Apr 2013 04:17:57 +0000 (07:17 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Sun, 7 Apr 2013 04:08:04 +0000 (07:08 +0300)
commit076c4dec9135e5486e9e2a43b88cd3255cfa011e
treeb609c116fbf299222a5e4e9566e950f3949fc640
parentee0af4246c484292e29b1ad8269003d242b7020c
Fix bug in selection subexpression handling.

Did not work correctly if
1. a static expression was passed to a SPAR_ATOMVAL parameter,
2. other parameters to the same selection method were dynamic
   (so that the expression would not be completely eliminated during
   compilation), and
3. the evaluation group of the SEL_EXPRESSION element was dynamic
   (so that the SPAR_ATOMVAL expression could be evaluated for a
   different group during evaluation and compilation).
In this case, the static atom-valued parameter got evaluated during
compilation for the maximal evaluation group and replaced by a constant.
During evaluation, if the evaluation group was smaller, the values for
that expression were no longer correct.
See #1216 for what kinds of concrete selections this applies to.

Subexpression handling in the selections is starting to (again) get very
messy, but that is a topic for a larger-scale refactoring...

Fixes #1216.

Change-Id: Ic6b7f9b8df661a9c78d7862b981a07e65a7ebdbf
src/gromacs/selection/compiler.cpp
src/gromacs/selection/evaluate.cpp
src/gromacs/selection/tests/refdata/SelectionCollectionDataTest_HandlesDynamicAtomValuedParameters.xml [new file with mode: 0644]
src/gromacs/selection/tests/selectioncollection.cpp