Use using for ArrayRef and RVec in pull code
authorBerk Hess <hess@kth.se>
Tue, 30 Mar 2021 20:28:52 +0000 (22:28 +0200)
committerPaul Bauer <paul.bauer.q@gmail.com>
Wed, 31 Mar 2021 07:21:02 +0000 (07:21 +0000)
src/gromacs/pulling/pull.cpp
src/gromacs/pulling/pullutil.cpp

index 6d5ea22148c886d7c377ba22a4bfa942ffa953a3..ba88e3aed5547d8f5686c7fda800c10878643bbc 100644 (file)
@@ -90,6 +90,7 @@ extern template LocalAtomSet LocalAtomSetManager::add<void, void>(ArrayRef<const
 } // namespace gmx
 
 using gmx::ArrayRef;
+using gmx::RVec;
 
 static int groupPbcFromParams(const t_pull_group& params, bool setPbcRefToPrevStepCOM)
 {
@@ -180,13 +181,13 @@ double pull_conversion_factor_internal2userinput(const t_pull_coord* pcrd)
 }
 
 /* Apply forces in a mass weighted fashion for part of the pull group */
-static void apply_forces_grp_part(const pull_group_work_t&  pgrp,
-                                  int                       ind_start,
-                                  int                       ind_end,
-                                  gmx::ArrayRef<const real> masses,
-                                  const dvec                f_pull,
-                                  const int                 sign,
-                                  rvec*                     f)
+static void apply_forces_grp_part(const pull_group_work_t& pgrp,
+                                  int                      ind_start,
+                                  int                      ind_end,
+                                  ArrayRef<const real>     masses,
+                                  const dvec               f_pull,
+                                  const int                sign,
+                                  rvec*                    f)
 {
     const double inv_wm = pgrp.mwscale;
 
@@ -208,11 +209,11 @@ static void apply_forces_grp_part(const pull_group_work_t&  pgrp,
 }
 
 /* Apply forces in a mass weighted fashion */
-static void apply_forces_grp(const pull_group_work_t&  pgrp,
-                             gmx::ArrayRef<const real> masses,
-                             const dvec                f_pull,
-                             const int                 sign,
-                             rvec*                     f)
+static void apply_forces_grp(const pull_group_work_t& pgrp,
+                             ArrayRef<const real>     masses,
+                             const dvec               f_pull,
+                             const int                sign,
+                             rvec*                    f)
 {
     auto localAtomIndices = pgrp.atomSet.localIndex();
 
@@ -248,13 +249,13 @@ static void apply_forces_grp(const pull_group_work_t&  pgrp,
 }
 
 /* Apply forces in a mass weighted fashion to a cylinder group */
-static void apply_forces_cyl_grp(const pull_group_work_t&  pgrp,
-                                 const double              dv_corr,
-                                 gmx::ArrayRef<const real> masses,
-                                 const dvec                f_pull,
-                                 double                    f_scal,
-                                 const int                 sign,
-                                 rvec*                     f)
+static void apply_forces_cyl_grp(const pull_group_work_t& pgrp,
+                                 const double             dv_corr,
+                                 ArrayRef<const real>     masses,
+                                 const dvec               f_pull,
+                                 double                   f_scal,
+                                 const int                sign,
+                                 rvec*                    f)
 {
     const double inv_wm = pgrp.mwscale;
 
@@ -297,7 +298,7 @@ static void apply_forces_cyl_grp(const pull_group_work_t&  pgrp,
  */
 static void apply_forces_vec_torque(const pull_coord_work_t&          pcrd,
                                     ArrayRef<const pull_group_work_t> pullGroups,
-                                    gmx::ArrayRef<const real>         masses,
+                                    ArrayRef<const real>              masses,
                                     rvec*                             f)
 {
     const PullCoordSpatialData& spatialData = pcrd.spatialData;
@@ -331,7 +332,7 @@ static void apply_forces_vec_torque(const pull_coord_work_t&          pcrd,
 static void apply_forces_coord(const pull_coord_work_t&          pcrd,
                                ArrayRef<const pull_group_work_t> pullGroups,
                                const PullCoordVectorForces&      forces,
-                               gmx::ArrayRef<const real>         masses,
+                               ArrayRef<const real>              masses,
                                rvec*                             f)
 {
     /* Here it would be more efficient to use one large thread-parallel
@@ -807,14 +808,14 @@ void clear_pull_forces(pull_t* pull)
 }
 
 /* Apply constraint using SHAKE */
-static void do_constraint(struct pull_t*           pull,
-                          t_pbc*                   pbc,
-                          gmx::ArrayRef<gmx::RVec> x,
-                          gmx::ArrayRef<gmx::RVec> v,
-                          gmx_bool                 bMaster,
-                          tensor                   vir,
-                          double                   dt,
-                          double                   t)
+static void do_constraint(struct pull_t* pull,
+                          t_pbc*         pbc,
+                          ArrayRef<RVec> x,
+                          ArrayRef<RVec> v,
+                          gmx_bool       bMaster,
+                          tensor         vir,
+                          double         dt,
+                          double         t)
 {
 
     dvec*    r_ij;   /* x[i] com of i in prev. step. Obeys constr. -> r_ij[i] */
@@ -1527,11 +1528,11 @@ static void check_external_potential_registration(const struct pull_t* pull)
  * potential energy is added either to the pull term or to a term
  * specific to the external module.
  */
-void apply_external_pull_coord_force(struct pull_t*            pull,
-                                     int                       coord_index,
-                                     double                    coord_force,
-                                     gmx::ArrayRef<const real> masses,
-                                     gmx::ForceWithVirial*     forceWithVirial)
+void apply_external_pull_coord_force(struct pull_t*        pull,
+                                     int                   coord_index,
+                                     double                coord_force,
+                                     ArrayRef<const real>  masses,
+                                     gmx::ForceWithVirial* forceWithVirial)
 {
     pull_coord_work_t* pcrd;
 
@@ -1595,15 +1596,15 @@ static PullCoordVectorForces do_pull_pot_coord(const pull_t&      pull,
     return pullCoordForces;
 }
 
-real pull_potential(struct pull_t*                 pull,
-                    gmx::ArrayRef<const real>      masses,
-                    t_pbc*                         pbc,
-                    const t_commrec*               cr,
-                    double                         t,
-                    real                           lambda,
-                    gmx::ArrayRef<const gmx::RVec> x,
-                    gmx::ForceWithVirial*          force,
-                    real*                          dvdlambda)
+real pull_potential(struct pull_t*        pull,
+                    ArrayRef<const real>  masses,
+                    t_pbc*                pbc,
+                    const t_commrec*      cr,
+                    double                t,
+                    real                  lambda,
+                    ArrayRef<const RVec>  x,
+                    gmx::ForceWithVirial* force,
+                    real*                 dvdlambda)
 {
     real V = 0;
 
@@ -1659,16 +1660,16 @@ real pull_potential(struct pull_t*                 pull,
     return (MASTER(cr) ? V : 0.0);
 }
 
-void pull_constraint(struct pull_t*            pull,
-                     gmx::ArrayRef<const real> masses,
-                     t_pbc*                    pbc,
-                     const t_commrec*          cr,
-                     double                    dt,
-                     double                    t,
-                     gmx::ArrayRef<gmx::RVec>  x,
-                     gmx::ArrayRef<gmx::RVec>  xp,
-                     gmx::ArrayRef<gmx::RVec>  v,
-                     tensor                    vir)
+void pull_constraint(struct pull_t*       pull,
+                     ArrayRef<const real> masses,
+                     t_pbc*               pbc,
+                     const t_commrec*     cr,
+                     double               dt,
+                     double               t,
+                     ArrayRef<RVec>       x,
+                     ArrayRef<RVec>       xp,
+                     ArrayRef<RVec>       v,
+                     tensor               vir)
 {
     assert(pull != nullptr);
 
@@ -2399,13 +2400,13 @@ static void destroy_pull(struct pull_t* pull)
     delete pull;
 }
 
-void preparePrevStepPullCom(const t_inputrec*         ir,
-                            pull_t*                   pull_work,
-                            gmx::ArrayRef<const real> masses,
-                            t_state*                  state,
-                            const t_state*            state_global,
-                            const t_commrec*          cr,
-                            bool                      startingFromCheckpoint)
+void preparePrevStepPullCom(const t_inputrec*    ir,
+                            pull_t*              pull_work,
+                            ArrayRef<const real> masses,
+                            t_state*             state,
+                            const t_state*       state_global,
+                            const t_commrec*     cr,
+                            bool                 startingFromCheckpoint)
 {
     if (!ir->pull || !ir->pull->bSetPbcRefToPrevStepCOM)
     {
index d332a93bc7bf16fc95f831f996966204bd3835d1..a1257ceb64f39a3886547b889a80083a42eef9b0 100644 (file)
@@ -64,6 +64,9 @@
 
 #include "pull_internal.h"
 
+using gmx::ArrayRef;
+using gmx::RVec;
+
 #if GMX_MPI
 
 // Helper function to deduce MPI datatype from the type of data
@@ -120,7 +123,7 @@ static void pullAllReduce(const t_commrec* cr, pull_comm_t* comm, int n, T* data
 /* Copies the coordinates of the PBC atom of pgrp to x_pbc.
  * When those coordinates are not available on this rank, clears x_pbc.
  */
-static void setPbcAtomCoords(const pull_group_work_t& pgrp, gmx::ArrayRef<const gmx::RVec> x, rvec x_pbc)
+static void setPbcAtomCoords(const pull_group_work_t& pgrp, ArrayRef<const RVec> x, rvec x_pbc)
 {
     if (pgrp.pbcAtomSet != nullptr)
     {
@@ -141,10 +144,7 @@ static void setPbcAtomCoords(const pull_group_work_t& pgrp, gmx::ArrayRef<const
     }
 }
 
-static void pull_set_pbcatoms(const t_commrec*               cr,
-                              struct pull_t*                 pull,
-                              gmx::ArrayRef<const gmx::RVec> x,
-                              gmx::ArrayRef<gmx::RVec>       x_pbc)
+static void pull_set_pbcatoms(const t_commrec* cr, struct pull_t* pull, ArrayRef<const RVec> x, ArrayRef<RVec> x_pbc)
 {
     int numPbcAtoms = 0;
     for (size_t g = 0; g < pull->group.size(); g++)
@@ -171,12 +171,12 @@ static void pull_set_pbcatoms(const t_commrec*               cr,
     }
 }
 
-static void make_cyl_refgrps(const t_commrec*               cr,
-                             pull_t*                        pull,
-                             gmx::ArrayRef<const real>      masses,
-                             t_pbc*                         pbc,
-                             double                         t,
-                             gmx::ArrayRef<const gmx::RVec> x)
+static void make_cyl_refgrps(const t_commrec*     cr,
+                             pull_t*              pull,
+                             ArrayRef<const real> masses,
+                             t_pbc*               pbc,
+                             double               t,
+                             ArrayRef<const RVec> x)
 {
     pull_comm_t* comm = &pull->comm;
 
@@ -385,15 +385,15 @@ static double atan2_0_2pi(double y, double x)
     return a;
 }
 
-static void sum_com_part(const pull_group_work_t*       pgrp,
-                         int                            ind_start,
-                         int                            ind_end,
-                         gmx::ArrayRef<const gmx::RVec> x,
-                         gmx::ArrayRef<const gmx::RVec> xp,
-                         gmx::ArrayRef<const real>      mass,
-                         const t_pbc*                   pbc,
-                         const rvec                     x_pbc,
-                         ComSums*                       sum_com)
+static void sum_com_part(const pull_group_work_t* pgrp,
+                         int                      ind_start,
+                         int                      ind_end,
+                         ArrayRef<const RVec>     x,
+                         ArrayRef<const RVec>     xp,
+                         ArrayRef<const real>     mass,
+                         const t_pbc*             pbc,
+                         const rvec               x_pbc,
+                         ComSums*                 sum_com)
 {
     double sum_wm   = 0;
     double sum_wwm  = 0;
@@ -467,15 +467,15 @@ static void sum_com_part(const pull_group_work_t*       pgrp,
     }
 }
 
-static void sum_com_part_cosweight(const pull_group_work_t*       pgrp,
-                                   int                            ind_start,
-                                   int                            ind_end,
-                                   int                            cosdim,
-                                   real                           twopi_box,
-                                   gmx::ArrayRef<const gmx::RVec> x,
-                                   gmx::ArrayRef<const gmx::RVec> xp,
-                                   gmx::ArrayRef<const real>      mass,
-                                   ComSums*                       sum_com)
+static void sum_com_part_cosweight(const pull_group_work_t* pgrp,
+                                   int                      ind_start,
+                                   int                      ind_end,
+                                   int                      cosdim,
+                                   real                     twopi_box,
+                                   ArrayRef<const RVec>     x,
+                                   ArrayRef<const RVec>     xp,
+                                   ArrayRef<const real>     mass,
+                                   ComSums*                 sum_com)
 {
     /* Cosine weighting geometry */
     double sum_cm  = 0;
@@ -520,13 +520,13 @@ static void sum_com_part_cosweight(const pull_group_work_t*       pgrp,
 }
 
 /* calculates center of mass of selection index from all coordinates x */
-void pull_calc_coms(const t_commrec*               cr,
-                    pull_t*                        pull,
-                    gmx::ArrayRef<const real>      masses,
-                    t_pbc*                         pbc,
-                    double                         t,
-                    gmx::ArrayRef<const gmx::RVec> x,
-                    gmx::ArrayRef<gmx::RVec>       xp)
+void pull_calc_coms(const t_commrec*     cr,
+                    pull_t*              pull,
+                    ArrayRef<const real> masses,
+                    t_pbc*               pbc,
+                    double               t,
+                    ArrayRef<const RVec> x,
+                    ArrayRef<RVec>       xp)
 {
     real         twopi_box = 0;
     pull_comm_t* comm;
@@ -821,12 +821,12 @@ void pull_calc_coms(const t_commrec*               cr,
 using BoolVec = gmx::BasicVector<bool>;
 
 /* Returns whether the pull group obeys the PBC restrictions */
-static bool pullGroupObeysPbcRestrictions(const pull_group_work_t&       group,
-                                          const BoolVec&                 dimUsed,
-                                          gmx::ArrayRef<const gmx::RVec> x,
-                                          const t_pbc&                   pbc,
-                                          const gmx::RVec&               x_pbc,
-                                          const real                     pbcMargin)
+static bool pullGroupObeysPbcRestrictions(const pull_group_work_t& group,
+                                          const BoolVec&           dimUsed,
+                                          ArrayRef<const RVec>     x,
+                                          const t_pbc&             pbc,
+                                          const RVec&              x_pbc,
+                                          const real               pbcMargin)
 {
     /* Determine which dimensions are relevant for PBC */
     BoolVec dimUsesPbc       = { false, false, false };
@@ -909,7 +909,7 @@ static bool pullGroupObeysPbcRestrictions(const pull_group_work_t&       group,
     return true;
 }
 
-int pullCheckPbcWithinGroups(const pull_t& pull, gmx::ArrayRef<const gmx::RVec> x, const t_pbc& pbc, real pbcMargin)
+int pullCheckPbcWithinGroups(const pull_t& pull, ArrayRef<const RVec> x, const t_pbc& pbc, real pbcMargin)
 {
     if (pbc.pbcType == PbcType::No)
     {
@@ -948,11 +948,7 @@ int pullCheckPbcWithinGroups(const pull_t& pull, gmx::ArrayRef<const gmx::RVec>
     return -1;
 }
 
-bool pullCheckPbcWithinGroup(const pull_t&                  pull,
-                             gmx::ArrayRef<const gmx::RVec> x,
-                             const t_pbc&                   pbc,
-                             int                            groupNr,
-                             real                           pbcMargin)
+bool pullCheckPbcWithinGroup(const pull_t& pull, ArrayRef<const RVec> x, const t_pbc& pbc, int groupNr, real pbcMargin)
 {
     if (pbc.pbcType == PbcType::No)
     {
@@ -1032,11 +1028,11 @@ void allocStatePrevStepPullCom(t_state* state, const pull_t* pull)
     }
 }
 
-void initPullComFromPrevStep(const t_commrec*               cr,
-                             pull_t*                        pull,
-                             gmx::ArrayRef<const real>      masses,
-                             t_pbc*                         pbc,
-                             gmx::ArrayRef<const gmx::RVec> x)
+void initPullComFromPrevStep(const t_commrec*     cr,
+                             pull_t*              pull,
+                             ArrayRef<const real> masses,
+                             t_pbc*               pbc,
+                             ArrayRef<const RVec> x)
 {
     pull_comm_t* comm   = &pull->comm;
     size_t       ngroup = pull->group.size();
@@ -1065,7 +1061,7 @@ void initPullComFromPrevStep(const t_commrec*               cr,
                        "Groups with no atoms, or only one atom, should not "
                        "use the COM from the previous step as reference.");
 
-            gmx::RVec x_pbc = { 0, 0, 0 };
+            RVec x_pbc = { 0, 0, 0 };
             copy_rvec(comm->pbcAtomBuffer[g], x_pbc);
 
             if (debug)