Merge release-5-0 into master
[alexxy/gromacs.git] / src / gromacs / selection / evaluate.cpp
index 721acc5d26824d978413ebafc6400af4f8143a69..9191823b8db5bc04269f2c13501dfc3966a10f6e 100644 (file)
@@ -498,7 +498,16 @@ _gmx_sel_evaluate_static(gmx_sel_evaluate_t                      * /* data */,
                          const gmx::SelectionTreeElementPointer &sel,
                          gmx_ana_index_t                        *g)
 {
-    gmx_ana_index_intersection(sel->v.u.g, &sel->u.cgrp, g);
+    if (sel->flags & SEL_UNSORTED)
+    {
+        // This only works if g contains all the atoms, but that is currently
+        // the only supported case.
+        gmx_ana_index_copy(sel->v.u.g, &sel->u.cgrp, false);
+    }
+    else
+    {
+        gmx_ana_index_intersection(sel->v.u.g, &sel->u.cgrp, g);
+    }
 }