Finish removing t_mdatoms from update module
authorejjordan <ejjordan@kth.se>
Wed, 21 Apr 2021 16:46:11 +0000 (18:46 +0200)
committerejjordan <ejjordan@kth.se>
Wed, 21 Apr 2021 16:46:18 +0000 (18:46 +0200)
Remove t_atoms from finish_update and only pass needed params.

Also cleaned up the includes and forward declares a bit.

src/gromacs/mdlib/tests/leapfrogtestrunners.cpp
src/gromacs/mdlib/update.cpp
src/gromacs/mdlib/update.h
src/gromacs/mdlib/update_vv.cpp
src/gromacs/mdrun/md.cpp

index 0db80fc685970f4340c463c7d46926a087e33c79..5badaad2725b988524ab51f93864d8dfa4a01b95 100644 (file)
@@ -87,8 +87,12 @@ void LeapFrogHostTestRunner::integrate(LeapFrogTestData* testData, int numSteps)
                 etrtNONE,
                 nullptr,
                 false);
-        testData->update_->finish_update(
-                testData->inputRecord_, &testData->mdAtoms_, &testData->state_, nullptr, false);
+        testData->update_->finish_update(testData->inputRecord_,
+                                         testData->mdAtoms_.havePartiallyFrozenAtoms,
+                                         testData->mdAtoms_.homenr,
+                                         &testData->state_,
+                                         nullptr,
+                                         false);
     }
     const auto xp = makeArrayRef(*testData->update_->xp()).subArray(0, testData->numAtoms_);
     for (int i = 0; i < testData->numAtoms_; i++)
index ac2c566d71e82d6c045f556cda80d39f85714748..c75ff3c6146810b1b5452548f5c366d69198d3a2 100644 (file)
 #include <memory>
 
 #include "gromacs/domdec/domdec_struct.h"
-#include "gromacs/fileio/confio.h"
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/gmxlib/nrnb.h"
 #include "gromacs/listed_forces/disre.h"
 #include "gromacs/listed_forces/orires.h"
 #include "gromacs/math/functions.h"
-#include "gromacs/math/invertmatrix.h"
 #include "gromacs/math/paddedvector.h"
 #include "gromacs/math/units.h"
 #include "gromacs/math/vec.h"
-#include "gromacs/math/vecdump.h"
 #include "gromacs/mdlib/boxdeformation.h"
 #include "gromacs/mdlib/constr.h"
 #include "gromacs/mdlib/gmx_omp_nthreads.h"
-#include "gromacs/mdlib/mdatoms.h"
 #include "gromacs/mdlib/stat.h"
 #include "gromacs/mdlib/tgroup.h"
 #include "gromacs/mdtypes/commrec.h"
@@ -68,9 +64,7 @@
 #include "gromacs/mdtypes/group.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
-#include "gromacs/mdtypes/mdatom.h"
 #include "gromacs/mdtypes/state.h"
-#include "gromacs/pbcutil/boxutilities.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/pulling/pull.h"
 #include "gromacs/random/tabulatednormaldistribution.h"
@@ -82,7 +76,6 @@
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/futil.h"
 #include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/gmxomp.h"
 #include "gromacs/utility/smalloc.h"
 
 using namespace gmx; // TODO: Remove when this file is moved into gmx namespace
@@ -136,11 +129,13 @@ public:
                        const t_commrec*                                 cr,
                        bool                                             haveConstraints);
 
-    void finish_update(const t_inputrec& inputRecord,
-                       const t_mdatoms*  md,
-                       t_state*          state,
-                       gmx_wallcycle*    wcycle,
-                       bool              haveConstraints);
+    void finish_update(const t_inputrec&                   inputRecord,
+                       bool                                havePartiallyFrozenAtoms,
+                       int                                 homenr,
+                       gmx::ArrayRef<const unsigned short> cFREEZE,
+                       t_state*                            state,
+                       gmx_wallcycle*                      wcycle,
+                       bool                                haveConstraints);
 
     void update_sd_second_half(const t_inputrec&                 inputRecord,
                                int64_t                           step,
@@ -248,12 +243,14 @@ void Update::update_coords(const t_inputrec&                 inputRecord,
 }
 
 void Update::finish_update(const t_inputrec& inputRecord,
-                           const t_mdatoms*  md,
+                           const bool        havePartiallyFrozenAtoms,
+                           const int         homenr,
                            t_state*          state,
                            gmx_wallcycle*    wcycle,
                            const bool        haveConstraints)
 {
-    return impl_->finish_update(inputRecord, md, state, wcycle, haveConstraints);
+    return impl_->finish_update(
+            inputRecord, havePartiallyFrozenAtoms, homenr, impl_->cFREEZE_, state, wcycle, haveConstraints);
 }
 
 void Update::update_sd_second_half(const t_inputrec&                 inputRecord,
@@ -1462,11 +1459,13 @@ void Update::Impl::update_sd_second_half(const t_inputrec&                 input
     }
 }
 
-void Update::Impl::finish_update(const t_inputrec& inputRecord,
-                                 const t_mdatoms*  md,
-                                 t_state*          state,
-                                 gmx_wallcycle*    wcycle,
-                                 const bool        haveConstraints)
+void Update::Impl::finish_update(const t_inputrec&                   inputRecord,
+                                 const bool                          havePartiallyFrozenAtoms,
+                                 const int                           homenr,
+                                 gmx::ArrayRef<const unsigned short> cFREEZE,
+                                 t_state*                            state,
+                                 gmx_wallcycle*                      wcycle,
+                                 const bool                          haveConstraints)
 {
     /* NOTE: Currently we always integrate to a temporary buffer and
      * then copy the results back here.
@@ -1474,11 +1473,10 @@ void Update::Impl::finish_update(const t_inputrec& inputRecord,
 
     wallcycle_start_nocount(wcycle, WallCycleCounter::Update);
 
-    const int homenr = md->homenr;
-    auto      xp     = makeConstArrayRef(xp_).subArray(0, homenr);
-    auto      x      = makeArrayRef(state->x).subArray(0, homenr);
+    auto xp = makeConstArrayRef(xp_).subArray(0, homenr);
+    auto x  = makeArrayRef(state->x).subArray(0, homenr);
 
-    if (md->havePartiallyFrozenAtoms && haveConstraints)
+    if (havePartiallyFrozenAtoms && haveConstraints)
     {
         /* We have atoms that are frozen along some, but not all dimensions,
          * then constraints will have moved them also along the frozen dimensions.
@@ -1488,7 +1486,7 @@ void Update::Impl::finish_update(const t_inputrec& inputRecord,
 
         for (int i = 0; i < homenr; i++)
         {
-            const int g = md->cFREEZE[i];
+            const int g = cFREEZE[i];
 
             for (int d = 0; d < DIM; d++)
             {
index 7fa36ae376ff791b17fe269dd0fc21ef1a588c0c..6771d60f3d06fc72f0896296d5408b2d6de0c0fa 100644 (file)
@@ -45,7 +45,6 @@
 #include "gromacs/mdtypes/md_enums.h"
 #include "gromacs/timing/wallcycle.h"
 #include "gromacs/utility/arrayref.h"
-#include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/real.h"
 
 class ekinstate_t;
@@ -56,7 +55,6 @@ struct t_fcdata;
 struct t_graph;
 struct t_grpopts;
 struct t_inputrec;
-struct t_mdatoms;
 struct t_nrnb;
 class t_state;
 enum class ParticleType;
@@ -145,13 +143,15 @@ public:
      * Copy the updated coordinates to the main coordinates buffer for the atoms that are not frozen.
      *
      * \param[in]  inputRecord      Input record.
-     * \param[in]  md               MD atoms data.
+     * \param[in]  havePartiallyFrozenAtoms  Whether atoms are frozen along 1 or 2 (not 3) dimensions?
+     * \param[in]  homenr                    The number of atoms on this processor.
      * \param[in]  state            System state object.
      * \param[in]  wcycle           Wall-clock cycle counter.
      * \param[in]  haveConstraints  If the system has constraints.
      */
     void finish_update(const t_inputrec& inputRecord,
-                       const t_mdatoms*  md,
+                       bool              havePartiallyFrozenAtoms,
+                       int               homenr,
                        t_state*          state,
                        gmx_wallcycle*    wcycle,
                        bool              haveConstraints);
index acc112e0d2cf524490ae32e6f2074ed2a7d19f36..fe874ca89bffda7eff86e2c8be109b4089fcd81b 100644 (file)
@@ -412,7 +412,8 @@ void integrateVVSecondStep(int64_t                                  step,
                                constr,
                                do_log,
                                do_ene);
-    upd->finish_update(*ir, mdatoms, state, wcycle, constr != nullptr);
+    upd->finish_update(
+            *ir, mdatoms->havePartiallyFrozenAtoms, mdatoms->homenr, state, wcycle, constr != nullptr);
 
     if (ir->eI == IntegrationAlgorithm::VVAK)
     {
@@ -467,7 +468,7 @@ void integrateVVSecondStep(int64_t                                  step,
          * to numerical errors, or are they important
          * physically? I'm thinking they are just errors, but not completely sure.
          * For now, will call without actually constraining, constr=NULL*/
-        upd->finish_update(*ir, mdatoms, state, wcycle, false);
+        upd->finish_update(*ir, mdatoms->havePartiallyFrozenAtoms, mdatoms->homenr, state, wcycle, false);
     }
     /* this factor or 2 correction is necessary
         because half of the constraint force is removed
index f5db890f8963a62adc30faf73542712e510cc34a..df33e9e78205f8be58675f6200d408f1c63430a8 100644 (file)
@@ -1609,7 +1609,8 @@ void gmx::LegacySimulator::do_md()
                                           constr,
                                           do_log,
                                           do_ene);
-                upd.finish_update(*ir, mdatoms, state, wcycle, constr != nullptr);
+                upd.finish_update(
+                        *ir, mdatoms->havePartiallyFrozenAtoms, mdatoms->homenr, state, wcycle, constr != nullptr);
             }
 
             if (ir->bPull && ir->pull->bSetPbcRefToPrevStepCOM)