Implement pull for modular simulator
[alexxy/gromacs.git] / src / gromacs / pulling / pull.cpp
index cbef32a4029f512b7aa07b905fef558820837ee7..077bbb82ba5eac1d645fa233e891812bf971f5f7 100644 (file)
@@ -2449,6 +2449,20 @@ static void destroy_pull(struct pull_t* pull)
     delete pull;
 }
 
+void preparePrevStepPullComNewSimulation(const t_commrec*                       cr,
+                                         pull_t*                                pull_work,
+                                         ArrayRef<const real>                   masses,
+                                         ArrayRef<const RVec>                   x,
+                                         const matrix                           box,
+                                         PbcType                                pbcType,
+                                         std::optional<gmx::ArrayRef<double>>&& comPreviousStep)
+{
+    t_pbc pbc;
+    set_pbc(&pbc, pbcType, box);
+    initPullComFromPrevStep(cr, pull_work, masses, pbc, x);
+    updatePrevStepPullCom(pull_work, comPreviousStep);
+}
+
 void preparePrevStepPullCom(const t_inputrec*    ir,
                             pull_t*              pull_work,
                             ArrayRef<const real> masses,
@@ -2479,11 +2493,13 @@ void preparePrevStepPullCom(const t_inputrec*    ir,
     }
     else
     {
-        t_pbc pbc;
-        set_pbc(&pbc, ir->pbcType, state->box);
-        initPullComFromPrevStep(
-                cr, pull_work, masses, pbc, state->x.arrayRefWithPadding().unpaddedArrayRef());
-        updatePrevStepPullCom(pull_work, state);
+        preparePrevStepPullComNewSimulation(cr,
+                                            pull_work,
+                                            masses,
+                                            state->x.arrayRefWithPadding().unpaddedArrayRef(),
+                                            state->box,
+                                            ir->pbcType,
+                                            state->pull_com_prev_step);
     }
 }