From 5f5143c95ca74d6ab0ebb9fd7f4b9eef2ea29862 Mon Sep 17 00:00:00 2001 From: Berk Hess Date: Tue, 30 Mar 2021 22:28:52 +0200 Subject: [PATCH] Use using for ArrayRef and RVec in pull code --- src/gromacs/pulling/pull.cpp | 121 ++++++++++++++++--------------- src/gromacs/pulling/pullutil.cpp | 104 +++++++++++++------------- 2 files changed, 111 insertions(+), 114 deletions(-) diff --git a/src/gromacs/pulling/pull.cpp b/src/gromacs/pulling/pull.cpp index 6d5ea22148..ba88e3aed5 100644 --- a/src/gromacs/pulling/pull.cpp +++ b/src/gromacs/pulling/pull.cpp @@ -90,6 +90,7 @@ extern template LocalAtomSet LocalAtomSetManager::add(ArrayRef 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 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 masses, - const dvec f_pull, - const int sign, - rvec* f) +static void apply_forces_grp(const pull_group_work_t& pgrp, + ArrayRef 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 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 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 pullGroups, - gmx::ArrayRef masses, + ArrayRef 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 pullGroups, const PullCoordVectorForces& forces, - gmx::ArrayRef masses, + ArrayRef 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 x, - gmx::ArrayRef v, - gmx_bool bMaster, - tensor vir, - double dt, - double t) +static void do_constraint(struct pull_t* pull, + t_pbc* pbc, + ArrayRef x, + ArrayRef 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 masses, - gmx::ForceWithVirial* forceWithVirial) +void apply_external_pull_coord_force(struct pull_t* pull, + int coord_index, + double coord_force, + ArrayRef 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 masses, - t_pbc* pbc, - const t_commrec* cr, - double t, - real lambda, - gmx::ArrayRef x, - gmx::ForceWithVirial* force, - real* dvdlambda) +real pull_potential(struct pull_t* pull, + ArrayRef masses, + t_pbc* pbc, + const t_commrec* cr, + double t, + real lambda, + ArrayRef 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 masses, - t_pbc* pbc, - const t_commrec* cr, - double dt, - double t, - gmx::ArrayRef x, - gmx::ArrayRef xp, - gmx::ArrayRef v, - tensor vir) +void pull_constraint(struct pull_t* pull, + ArrayRef masses, + t_pbc* pbc, + const t_commrec* cr, + double dt, + double t, + ArrayRef x, + ArrayRef xp, + ArrayRef 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 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 masses, + t_state* state, + const t_state* state_global, + const t_commrec* cr, + bool startingFromCheckpoint) { if (!ir->pull || !ir->pull->bSetPbcRefToPrevStepCOM) { diff --git a/src/gromacs/pulling/pullutil.cpp b/src/gromacs/pulling/pullutil.cpp index d332a93bc7..a1257ceb64 100644 --- a/src/gromacs/pulling/pullutil.cpp +++ b/src/gromacs/pulling/pullutil.cpp @@ -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 x, rvec x_pbc) +static void setPbcAtomCoords(const pull_group_work_t& pgrp, ArrayRef x, rvec x_pbc) { if (pgrp.pbcAtomSet != nullptr) { @@ -141,10 +144,7 @@ static void setPbcAtomCoords(const pull_group_work_t& pgrp, gmx::ArrayRef x, - gmx::ArrayRef x_pbc) +static void pull_set_pbcatoms(const t_commrec* cr, struct pull_t* pull, ArrayRef x, ArrayRef 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 masses, - t_pbc* pbc, - double t, - gmx::ArrayRef x) +static void make_cyl_refgrps(const t_commrec* cr, + pull_t* pull, + ArrayRef masses, + t_pbc* pbc, + double t, + ArrayRef 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 x, - gmx::ArrayRef xp, - gmx::ArrayRef 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 x, + ArrayRef xp, + ArrayRef 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 x, - gmx::ArrayRef xp, - gmx::ArrayRef 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 x, + ArrayRef xp, + ArrayRef 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 masses, - t_pbc* pbc, - double t, - gmx::ArrayRef x, - gmx::ArrayRef xp) +void pull_calc_coms(const t_commrec* cr, + pull_t* pull, + ArrayRef masses, + t_pbc* pbc, + double t, + ArrayRef x, + ArrayRef 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; /* Returns whether the pull group obeys the PBC restrictions */ -static bool pullGroupObeysPbcRestrictions(const pull_group_work_t& group, - const BoolVec& dimUsed, - gmx::ArrayRef 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 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 x, const t_pbc& pbc, real pbcMargin) +int pullCheckPbcWithinGroups(const pull_t& pull, ArrayRef x, const t_pbc& pbc, real pbcMargin) { if (pbc.pbcType == PbcType::No) { @@ -948,11 +948,7 @@ int pullCheckPbcWithinGroups(const pull_t& pull, gmx::ArrayRef return -1; } -bool pullCheckPbcWithinGroup(const pull_t& pull, - gmx::ArrayRef x, - const t_pbc& pbc, - int groupNr, - real pbcMargin) +bool pullCheckPbcWithinGroup(const pull_t& pull, ArrayRef 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 masses, - t_pbc* pbc, - gmx::ArrayRef x) +void initPullComFromPrevStep(const t_commrec* cr, + pull_t* pull, + ArrayRef masses, + t_pbc* pbc, + ArrayRef 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) -- 2.22.0