From 69d97fa60cf04a6364f9714baf031337fd048151 Mon Sep 17 00:00:00 2001
From: Axel Kohlmeyer <akohlmey@gmail.com>
Date: Wed, 12 Jul 2017 11:26:16 -0400
Subject: [PATCH] fix enforce2d has to be defined after fixes with
 enforce2d_flag set

this check currently only applies to rigid fixes and is needed
so that their respective enforce2d function is called _after_
the post force functions. this is required in combination with
commit a9ff593763c74082df4df53d268e2ddcc172a3fb to allow rigid
fixes use the langevin option correctly for 2d systems
---
 src/fix_enforce2d.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/fix_enforce2d.cpp b/src/fix_enforce2d.cpp
index 21a99e3c16..336fd12556 100644
--- a/src/fix_enforce2d.cpp
+++ b/src/fix_enforce2d.cpp
@@ -66,12 +66,21 @@ void FixEnforce2D::init()
     if (modify->fix[i]->enforce2d_flag) nfixlist++;
 
   if (nfixlist) {
+    int myindex = -1;
     delete [] flist;
     flist = new Fix*[nfixlist];
     nfixlist = 0;
     for (int i = 0; i < modify->nfix; i++) {
-      if (modify->fix[i]->enforce2d_flag) 
-        flist[nfixlist++] = modify->fix[i];
+      if (modify->fix[i]->enforce2d_flag) {
+        if (myindex < 0)
+          flist[nfixlist++] = modify->fix[i];
+        else {
+          char msg[256];
+          sprintf(msg,"Fix enforce2d must be defined after fix %s",modify->fix[i]->style);
+          error->all(FLERR,msg);
+        }
+      }
+      if (modify->fix[i] == this) myindex = i;
     }
   }
 }
-- 
GitLab