Moved constraint code into gmx namespace.
Used more forward declarations in both the old and new headers.
Removed typedef from type declarations.
Removed gmx_ prefix from some names, since it is no longer required
and we may as well avoid verbiage.
Renamed some types more consistently with newer coding styles, and
called them class now where they will be one shortly.
Added some const correctness.
Apparently this inspires uncrustify to change positions of some
comments. Go figure.
Replaced all gmx_bool in constraints code with bool.
Maths functions from vec.h (which are not in the top-level namespace)
now need namespace qualifications.
Added and fixed various Doxygen, which is primitive in some cases
where the code was particularly cryptic.
Noted policy on multiple authors within Doxygen comments.
Refs #2423
Change-Id: I41bf3a4b9a4fbbcb3a3a7a27dc922d563abedbcb
One or more contact persons who know about the contents of the module should be
listed using ``\author`` commands. This provides a point of contact if one
-has questions.
+has questions. Authors should be listed in chronological order of contributions,
+where possible.
Classes/structs
^^^^^^^^^^^^^^^
gmx_localtop_t *top_local,
t_forcerec *fr,
gmx_vsite_t *vsite,
- gmx_constr_t constr,
+ gmx::Constraints *constr,
t_nrnb *nrnb,
gmx_wallcycle *wcycle,
gmx_bool bVerbose)
namespace gmx
{
+class Constraints;
class MDAtoms;
} // namespace
gmx_localtop_t *top_local,
t_forcerec *fr,
gmx_vsite_t *vsite,
- struct gmx_constr *constr,
+ gmx::Constraints *constr,
t_nrnb *nrnb,
gmx_wallcycle *wcycle,
gmx_bool bVerbose);
int dd_make_local_constraints(gmx_domdec_t *dd, int at_start,
const struct gmx_mtop_t *mtop,
const int *cginfo,
- gmx_constr_t constr, int nrec,
+ gmx::Constraints *constr, int nrec,
t_ilist *il_local)
{
gmx_domdec_constraints_t *dc;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2005,2006,2007,2008,2009,2010,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2005,2006,2007,2008,2009,2010,2012,2013,2014,2015,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#ifndef GMX_DOMDEC_DOMDEC_CONSTRAINTS_H
#define GMX_DOMDEC_DOMDEC_CONSTRAINTS_H
-#include "gromacs/mdlib/constr.h"
+namespace gmx
+{
+class Constraints;
+}
struct gmx_domdec_t;
struct gmx_mtop_t;
int dd_make_local_constraints(struct gmx_domdec_t *dd, int at_start,
const struct gmx_mtop_t *mtop,
const int *cginfo,
- gmx_constr_t constr, int nrec,
+ gmx::Constraints *constr, int nrec,
struct t_ilist *il_local);
/*! \brief Initializes the data structures for constraint communication */
const gmx_mtop_t *mtop,
const t_inputrec *ir,
const t_commrec *cr,
- gmx_constr *constr,
+ gmx::Constraints *constr,
const t_state *globalState,
ObservablesHistory *oh,
const gmx_output_env_t *oenv,
struct t_inputrec;
class t_state;
+namespace gmx
+{
+class Constraints;
+}
+
/*! \brief Applies essential dynamics constrains as defined in the .edi input file.
*
* \param ir MD input parameter record.
const gmx_mtop_t *mtop,
const t_inputrec *ir,
const t_commrec *cr,
- struct gmx_constr *constr,
+ gmx::Constraints *constr,
const t_state *globalState,
ObservablesHistory *oh,
const gmx_output_env_t *oenv,
const t_atom * atom = molt->atoms.atom;
int numFlexibleConstraints;
- t_blocka atomToConstraints = make_at2con(0, molt->atoms.nr,
- molt->ilist, iparams,
- FALSE,
- &numFlexibleConstraints);
+ t_blocka atomToConstraints = gmx::make_at2con(0, molt->atoms.nr,
+ molt->ilist, iparams,
+ FALSE, &numFlexibleConstraints);
bool haveDecoupledMode = false;
for (int ftype = 0; ftype < F_NRE; ftype++)
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+/*! \internal \file
+ * \brief Defines the high-level constraint code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ */
#include "gmxpre.h"
#include "constr.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/txtdump.h"
-typedef struct gmx_constr {
- int ncon_tot; /* The total number of constraints */
- int nflexcon; /* The number of flexible constraints */
- int n_at2con_mt; /* The size of at2con = #moltypes */
- t_blocka *at2con_mt; /* A list of atoms to constraints */
- int n_at2settle_mt; /* The size of at2settle = #moltypes */
- int **at2settle_mt; /* A list of atoms to settles */
- gmx_bool bInterCGsettles;
- gmx_lincsdata_t lincsd; /* LINCS data */
- gmx_shakedata_t shaked; /* SHAKE data */
- gmx_settledata_t settled; /* SETTLE data */
- int maxwarn; /* The maximum number of warnings */
- int warncount_lincs;
- int warncount_settle;
- gmx_edsam_t ed; /* The essential dynamics data */
-
- /* Thread local working data */
- tensor *vir_r_m_dr_th; /* Thread virial contribution */
- bool *bSettleErrorHasOccurred; /* Did a settle error occur? */
-
- /* Only used for printing warnings */
- const gmx_mtop_t *warn_mtop; /* Pointer to the global topology */
-} t_gmx_constr;
-
-int n_flexible_constraints(struct gmx_constr *constr)
+namespace gmx
+{
+
+class Constraints
+{
+ public:
+ int ncon_tot; /* The total number of constraints */
+ int nflexcon; /* The number of flexible constraints */
+ int n_at2con_mt; /* The size of at2con = #moltypes */
+ t_blocka *at2con_mt; /* A list of atoms to constraints */
+ int n_at2settle_mt; /* The size of at2settle = #moltypes */
+ int **at2settle_mt; /* A list of atoms to settles */
+ bool bInterCGsettles;
+ Lincs *lincsd; /* LINCS data */
+ shakedata *shaked; /* SHAKE data */
+ settledata *settled; /* SETTLE data */
+ int maxwarn; /* The maximum number of warnings */
+ int warncount_lincs;
+ int warncount_settle;
+ gmx_edsam_t ed; /* The essential dynamics data */
+
+ /* Thread local working data */
+ tensor *vir_r_m_dr_th; /* Thread virial contribution */
+ bool *bSettleErrorHasOccurred; /* Did a settle error occur? */
+
+ /* Only used for printing warnings */
+ const gmx_mtop_t *warn_mtop; /* Pointer to the global topology */
+};
+
+int n_flexible_constraints(const Constraints *constr)
{
int nflexcon;
return nflexcon;
}
+//! Clears constraint quantities for atoms in nonlocal region.
static void clear_constraint_quantity_nonlocal(gmx_domdec_t *dd, rvec *q)
{
int nonlocal_at_start, nonlocal_at_end, at;
"adjust the lincs warning threshold in your mdp file\nor " : "\n");
}
+//! Writes out coordinates.
static void write_constr_pdb(const char *fn, const char *title,
const gmx_mtop_t *mtop,
int start, int homenr, const t_commrec *cr,
gmx_fio_fclose(out);
}
+//! Writes out domain contents to help diagnose crashes.
static void dump_confs(FILE *fplog, gmx_int64_t step, const gmx_mtop_t *mtop,
int start, int homenr, const t_commrec *cr,
rvec x[], rvec xprime[], matrix box)
fprintf(stderr, "Wrote pdb files with previous and current coordinates\n");
}
-gmx_bool constrain(FILE *fplog, gmx_bool bLog, gmx_bool bEner,
- struct gmx_constr *constr,
- t_idef *idef, const t_inputrec *ir,
- const t_commrec *cr,
- const gmx_multisim_t *ms,
- gmx_int64_t step, int delta_step,
- real step_scaling,
- t_mdatoms *md,
- rvec *x, rvec *xprime, rvec *min_proj,
- gmx_bool bMolPBC, matrix box,
- real lambda, real *dvdlambda,
- rvec *v, tensor *vir,
- t_nrnb *nrnb, int econq)
+bool constrain(FILE *fplog, bool bLog, bool bEner,
+ Constraints *constr,
+ t_idef *idef, const t_inputrec *ir,
+ const t_commrec *cr,
+ const gmx_multisim_t *ms,
+ gmx_int64_t step, int delta_step,
+ real step_scaling,
+ t_mdatoms *md,
+ rvec *x, rvec *xprime, rvec *min_proj,
+ bool bMolPBC, matrix box,
+ real lambda, real *dvdlambda,
+ rvec *v, tensor *vir,
+ t_nrnb *nrnb, int econq)
{
- gmx_bool bOK, bDump;
+ bool bOK, bDump;
int start, homenr;
tensor vir_r_m_dr;
real scaled_delta_t;
return bOK;
}
-real *constr_rmsd_data(struct gmx_constr *constr)
+real *constr_rmsd_data(Constraints *constr)
{
if (constr->lincsd)
{
}
}
-real constr_rmsd(struct gmx_constr *constr)
+real constr_rmsd(const Constraints *constr)
{
if (constr->lincsd)
{
t_blocka make_at2con(int start, int natoms,
const t_ilist *ilist, const t_iparams *iparams,
- gmx_bool bDynamics, int *nflexiblecons)
+ bool bDynamics, int *nflexiblecons)
{
int *count, ncon, con, con_tot, nflexcon, ftype, i, a;
t_iatom *ia;
t_blocka at2con;
- gmx_bool bFlexCon;
+ bool bFlexCon;
snew(count, natoms);
nflexcon = 0;
return at2con;
}
+//! Returns the index of the settle to which each atom belongs.
static int *make_at2settle(int natoms, const t_ilist *ilist)
{
int *at2s;
return at2s;
}
-void set_constraints(struct gmx_constr *constr,
+void set_constraints(Constraints *constr,
gmx_localtop_t *top, const t_inputrec *ir,
const t_mdatoms *md, const t_commrec *cr)
{
}
}
-gmx_constr_t init_constraints(FILE *fplog,
+Constraints *init_constraints(FILE *fplog,
const gmx_mtop_t *mtop, const t_inputrec *ir,
bool doEssentialDynamics,
const t_commrec *cr)
return nullptr;
}
- struct gmx_constr *constr;
+ Constraints *constr;
snew(constr, 1);
return constr;
}
-/* Put a pointer to the essential dynamics constraints into the constr struct */
-void saveEdsamPointer(gmx_constr_t constr, gmx_edsam_t ed)
+void saveEdsamPointer(Constraints *constr, gmx_edsam *ed)
{
constr->ed = ed;
}
-const t_blocka *atom2constraints_moltype(gmx_constr_t constr)
+const t_blocka *atom2constraints_moltype(const Constraints *constr)
{
return constr->at2con_mt;
}
-const int **atom2settle_moltype(gmx_constr_t constr)
+const int **atom2settle_moltype(const Constraints *constr)
{
return (const int **)constr->at2settle_mt;
}
-gmx_bool inter_charge_group_constraints(const gmx_mtop_t *mtop)
+bool inter_charge_group_constraints(const gmx_mtop_t *mtop)
{
const gmx_moltype_t *molt;
const t_block *cgs;
const t_ilist *il;
int *at2cg, cg, a, ftype, i;
- gmx_bool bInterCG;
+ bool bInterCG;
bInterCG = FALSE;
for (size_t mb = 0; mb < mtop->molblock.size() && !bInterCG; mb++)
return bInterCG;
}
-gmx_bool inter_charge_group_settles(const gmx_mtop_t *mtop)
+bool inter_charge_group_settles(const gmx_mtop_t *mtop)
{
const gmx_moltype_t *molt;
const t_block *cgs;
const t_ilist *il;
int *at2cg, cg, a, ftype, i;
- gmx_bool bInterCG;
+ bool bInterCG;
bInterCG = FALSE;
for (size_t mb = 0; mb < mtop->molblock.size() && !bInterCG; mb++)
return bInterCG;
}
+
+} // namespace
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+/*! \libinternal \file
+ * \brief Declares interface to constraint code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ * \inlibraryapi
+ */
-#ifndef GMX_MBLIB_CONSTR_H
-#define GMX_MBLIB_CONSTR_H
+#ifndef GMX_MDLIB_CONSTR_H
+#define GMX_MDLIB_CONSTR_H
#include <cstdio>
union t_iparams;
class t_state;
-/* Abstract type for constraints */
-typedef struct gmx_constr *gmx_constr_t;
+namespace gmx
+{
+
+class Constraints;
enum
{
econqForceDispl /* Constrain forces (mass-weighted 1/0 for freeze) */
};
-int n_flexible_constraints(gmx_constr *constr);
-/* Returns the total number of flexible constraints in the system */
+/*! \brief Returns the total number of flexible constraints in the system. */
+int n_flexible_constraints(const Constraints *constr);
+/*! \brief Generate a fatal error because of too many LINCS/SETTLE warnings. */
void too_many_constraint_warnings(int eConstrAlg, int warncount);
-/* Generate a fatal error because of too many LINCS/SETTLE warnings */
-
-
-gmx_bool constrain(FILE *log, gmx_bool bLog, gmx_bool bEner,
- gmx_constr_t constr,
- t_idef *idef,
- const t_inputrec *ir,
- const t_commrec *cr,
- const gmx_multisim_t *ms,
- gmx_int64_t step, int delta_step,
- real step_scaling,
- t_mdatoms *md,
- rvec *x, rvec *xprime, rvec *min_proj,
- gmx_bool bMolPBC, matrix box,
- real lambda, real *dvdlambda,
- rvec *v, tensor *vir,
- t_nrnb *nrnb, int econq);
-/*
+
+/*! \brief Applies constraints to coordinates.
+ *
* When econq=econqCoord constrains coordinates xprime using th
* directions in x, min_proj is not used.
*
* Return TRUE if OK, FALSE in case of shake error
*
*/
-
-gmx_constr_t init_constraints(FILE *log,
+bool constrain(FILE *log, bool bLog, bool bEner,
+ Constraints *constr,
+ t_idef *idef,
+ const t_inputrec *ir,
+ const t_commrec *cr,
+ const gmx_multisim_t *ms,
+ gmx_int64_t step, int delta_step,
+ real step_scaling,
+ t_mdatoms *md,
+ rvec *x, rvec *xprime, rvec *min_proj,
+ bool bMolPBC, matrix box,
+ real lambda, real *dvdlambda,
+ rvec *v, tensor *vir,
+ t_nrnb *nrnb, int econq);
+
+/*! \brief Initialize constraints stuff */
+Constraints *init_constraints(FILE *log,
const gmx_mtop_t *mtop, const t_inputrec *ir,
bool doEssentialDynamics,
const t_commrec *cr);
-/* Initialize constraints stuff */
-void saveEdsamPointer(gmx_constr_t constr,
+/*! \brief Put a pointer to the essential dynamics constraints into the constr struct. */
+void saveEdsamPointer(Constraints *constr,
gmx_edsam *ed);
-/* Put a pointer to the essential dynamics constraints into the constr struct */
-void set_constraints(gmx_constr_t constr,
+/*! \brief Set up all the local constraints for this rank. */
+void set_constraints(Constraints *constr,
gmx_localtop_t *top,
const t_inputrec *ir,
const t_mdatoms *md,
const t_commrec *cr);
-/* Set up all the local constraints for the node */
/* The at2con t_blocka struct returned by the routines below
* contains a list of constraints per atom.
* after the F_CONSTR constraints.
*/
+/*! \brief Returns a block struct to go from atoms to constraints */
t_blocka make_at2con(int start, int natoms,
const t_ilist *ilist, const t_iparams *iparams,
- gmx_bool bDynamics, int *nflexiblecons);
-/* Returns a block struct to go from atoms to constraints */
+ bool bDynamics, int *nflexiblecons);
-const t_blocka *atom2constraints_moltype(gmx_constr_t constr);
-/* Returns the an array of atom to constraints lists for the moltypes */
+/*! \brief Returns an array of atom to constraints lists for the moltypes */
+const t_blocka *atom2constraints_moltype(const Constraints *constr);
-const int **atom2settle_moltype(gmx_constr_t constr);
-/* Returns the an array of atom to settle for the moltypes */
+/*! \brief Returns an array of atom to settles lists for the moltypes */
+const int **atom2settle_moltype(const Constraints *constr);
-#define constr_iatomptr(nconstr, iatom_constr, iatom_constrnc, con) ((con) < (nconstr) ? (iatom_constr)+(con)*3 : (iatom_constrnc)+(con-nconstr)*3)
-/* Macro for getting the constraint iatoms for a constraint number con
+/*! \brief Macro for getting the constraint iatoms for a constraint number con
* which comes from a list where F_CONSTR and F_CONSTRNC constraints
- * are concatenated.
- */
+ * are concatenated. */
+#define constr_iatomptr(nconstr, iatom_constr, iatom_constrnc, con) ((con) < (nconstr) ? (iatom_constr)+(con)*3 : (iatom_constrnc)+(con-nconstr)*3)
-gmx_bool inter_charge_group_constraints(const gmx_mtop_t *mtop);
-/* Returns if there are inter charge group constraints */
+/*! \brief Returns whether there are inter charge group constraints */
+bool inter_charge_group_constraints(const gmx_mtop_t *mtop);
-gmx_bool inter_charge_group_settles(const gmx_mtop_t *mtop);
-/* Returns if there are inter charge group settles */
+/*! \brief Returns whether there are inter charge group settles */
+bool inter_charge_group_settles(const gmx_mtop_t *mtop);
-real *constr_rmsd_data(gmx_constr_t constr);
-/* Return the data for determining constraint RMS relative deviations.
- * Returns NULL when LINCS is not used.
- */
+/*! \brief Return the data for determining constraint RMS relative deviations.
+ * Returns NULL when LINCS is not used. */
+real *constr_rmsd_data(Constraints *constr);
+
+/*! \brief Return the RMSD of the constraint */
+real constr_rmsd(const Constraints *constr);
-real constr_rmsd(gmx_constr_t constr);
-/* Return the RMSD of the constraint */
+} // namespace
#endif
#include "gromacs/utility/real.h"
#include "gromacs/utility/smalloc.h"
+namespace gmx
+{
+
+//! Recursing function to help find all adjacent constraints.
static void constr_recur(const t_blocka *at2con,
const t_ilist *ilist, const t_iparams *iparams,
gmx_bool bTopB,
}
}
+//! Find the interaction radius needed for constraints for this molecule type.
static real constr_r_max_moltype(const gmx_moltype_t *molt,
const t_iparams *iparams,
const t_inputrec *ir)
return rmax;
}
+
+} // namespace
struct gmx_mtop_t;
struct t_inputrec;
+namespace gmx
+{
+
/*! \brief Returns an estimate of the maximum distance between atoms
* required for LINCS. */
real constr_r_max(FILE *fplog, const gmx_mtop_t *mtop, const t_inputrec *ir);
+} // namespace
+
#endif
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-/* This file is completely threadsafe - keep it that way! */
+/*! \internal \file
+ * \brief Defines LINCS code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ */
#include "gmxpre.h"
#include "lincs.h"
using namespace gmx; // TODO: Remove when this file is moved into gmx namespace
-typedef struct {
- int b0; /* first constraint for this task */
- int b1; /* b1-1 is the last constraint for this task */
- int ntriangle; /* the number of constraints in triangles */
- int *triangle; /* the list of triangle constraints */
- int *tri_bits; /* the bits tell if the matrix element should be used */
- int tri_alloc; /* allocation size of triangle and tri_bits */
- int nind; /* number of indices */
- int *ind; /* constraint index for updating atom data */
- int nind_r; /* number of indices */
- int *ind_r; /* constraint index for updating atom data */
- int ind_nalloc; /* allocation size of ind and ind_r */
- tensor vir_r_m_dr; /* temporary variable for virial calculation */
- real dhdlambda; /* temporary variable for lambda derivative */
-} lincs_task_t;
-
-typedef struct gmx_lincsdata {
- int ncg; /* the global number of constraints */
- int ncg_flex; /* the global number of flexible constraints */
- int ncg_triangle; /* the global number of constraints in triangles */
- int nIter; /* the number of iterations */
- int nOrder; /* the order of the matrix expansion */
- int max_connect; /* the maximum number of constrains connected to a single atom */
-
- int nc_real; /* the number of real constraints */
- int nc; /* the number of constraints including padding for SIMD */
- int nc_alloc; /* the number we allocated memory for */
- int ncc; /* the number of constraint connections */
- int ncc_alloc; /* the number we allocated memory for */
- real matlam; /* the FE lambda value used for filling blc and blmf */
- int *con_index; /* mapping from topology to LINCS constraints */
- real *bllen0; /* the reference distance in topology A */
- real *ddist; /* the reference distance in top B - the r.d. in top A */
- int *bla; /* the atom pairs involved in the constraints */
- real *blc; /* 1/sqrt(invmass1 + invmass2) */
- real *blc1; /* as blc, but with all masses 1 */
- int *blnr; /* index into blbnb and blmf */
- int *blbnb; /* list of constraint connections */
- int ntriangle; /* the local number of constraints in triangles */
- int ncc_triangle; /* the number of constraint connections in triangles */
- gmx_bool bCommIter; /* communicate before each LINCS interation */
- real *blmf; /* matrix of mass factors for constraint connections */
- real *blmf1; /* as blmf, but with all masses 1 */
- real *bllen; /* the reference bond length */
- int *nlocat; /* the local atom count per constraint, can be NULL */
-
- int ntask; /* The number of tasks = #threads for LINCS */
- lincs_task_t *task; /* LINCS thread division */
- gmx_bitmask_t *atf; /* atom flags for thread parallelization */
- int atf_nalloc; /* allocation size of atf */
- gmx_bool bTaskDep; /* are the LINCS tasks interdependent? */
- gmx_bool bTaskDepTri; /* are there triangle constraints that cross task borders? */
- /* arrays for temporary storage in the LINCS algorithm */
- rvec *tmpv;
- real *tmpncc;
- real *tmp1;
- real *tmp2;
- real *tmp3;
- real *tmp4;
- real *mlambda; /* the Lagrange multipliers * -1 */
- /* storage for the constraint RMS relative deviation output */
- real rmsd_data[3];
-} t_gmx_lincsdata;
-
-/* Define simd_width for memory allocation used for SIMD code */
+namespace gmx
+{
+
+//! Unit of work within LINCS.
+struct Task
+{
+ //! First constraint for this task.
+ int b0;
+ //! b1-1 is the last constraint for this task.
+ int b1;
+ //! The number of constraints in triangles.
+ int ntriangle;
+ //! The list of triangle constraints.
+ int *triangle;
+ //! The bits tell if the matrix element should be used.
+ int *tri_bits;
+ //! Allocation size of triangle and tri_bits.
+ int tri_alloc;
+ //! Number of indices.
+ int nind;
+ //! Constraint index for updating atom data.
+ int *ind;
+ //! Number of indices.
+ int nind_r;
+ //! Constraint index for updating atom data.
+ int *ind_r;
+ //! Allocation size of ind and ind_r.
+ int ind_nalloc;
+ //! Temporary variable for virial calculation.
+ tensor vir_r_m_dr;
+ //! Temporary variable for lambda derivative.
+ real dhdlambda;
+};
+
+/*! \brief Data for LINCS algorithm.
+ */
+class Lincs
+{
+ public:
+ //! The global number of constraints.
+ int ncg;
+ //! The global number of flexible constraints.
+ int ncg_flex;
+ //! The global number of constraints in triangles.
+ int ncg_triangle;
+ //! The number of iterations.
+ int nIter;
+ //! The order of the matrix expansion.
+ int nOrder;
+ //! The maximum number of constraints connected to a single atom.
+ int max_connect;
+
+ //! The number of real constraints.
+ int nc_real;
+ //! The number of constraints including padding for SIMD.
+ int nc;
+ //! The number we allocated memory for.
+ int nc_alloc;
+ //! The number of constraint connections.
+ int ncc;
+ //! The number we allocated memory for.
+ int ncc_alloc;
+ //! The FE lambda value used for filling blc and blmf.
+ real matlam;
+ //! mapping from topology to LINCS constraints.
+ int *con_index;
+ //! The reference distance in topology A.
+ real *bllen0;
+ //! The reference distance in top B - the r.d. in top A.
+ real *ddist;
+ //! The atom pairs involved in the constraints.
+ int *bla;
+ //! 1/sqrt(invmass1 invmass2).
+ real *blc;
+ //! As blc, but with all masses 1.
+ real *blc1;
+ //! Index into blbnb and blmf.
+ int *blnr;
+ //! List of constraint connections.
+ int *blbnb;
+ //! The local number of constraints in triangles.
+ int ntriangle;
+ //! The number of constraint connections in triangles.
+ int ncc_triangle;
+ //! Communicate before each LINCS interation.
+ bool bCommIter;
+ //! Matrix of mass factors for constraint connections.
+ real *blmf;
+ //! As blmf, but with all masses 1.
+ real *blmf1;
+ //! The reference bond length.
+ real *bllen;
+ //! The local atom count per constraint, can be NULL.
+ int *nlocat;
+
+ /*! \brief The number of tasks used for LINCS work.
+ *
+ * \todo This is mostly used to loop over \c task, which would
+ * be nicer to do with range-based for loops, but the thread
+ * index is used for constructing bit masks and organizing the
+ * virial output buffer, so other things need to change,
+ * first. */
+ int ntask;
+ /*! \brief LINCS thread division */
+ Task *task;
+ //! Atom flags for thread parallelization.
+ gmx_bitmask_t *atf;
+ //! Allocation size of atf
+ int atf_nalloc;
+ //! Are the LINCS tasks interdependent?
+ bool bTaskDep;
+ //! Are there triangle constraints that cross task borders?
+ bool bTaskDepTri;
+ //! Arrays for temporary storage in the LINCS algorithm.
+ /*! @{ */
+ rvec *tmpv;
+ real *tmpncc;
+ real *tmp1;
+ real *tmp2;
+ real *tmp3;
+ real *tmp4;
+ /*! @} */
+ //! The Lagrange multipliers times -1.
+ real *mlambda;
+ //! Storage for the constraint RMS relative deviation output.
+ real rmsd_data[3];
+};
+
+/*! \brief Define simd_width for memory allocation used for SIMD code */
#if GMX_SIMD_HAVE_REAL
static const int simd_width = GMX_SIMD_REAL_WIDTH;
#else
static const int simd_width = 1;
#endif
-/* Align to 128 bytes, consistent with the current implementation of
+/*! \brief Align to 128 bytes, consistent with the current implementation of
AlignedAllocator, which currently forces 128 byte alignment. */
static const int align_bytes = 128;
-real *lincs_rmsd_data(struct gmx_lincsdata *lincsd)
+real *lincs_rmsd_data(Lincs *lincsd)
{
return lincsd->rmsd_data;
}
-real lincs_rmsd(struct gmx_lincsdata *lincsd)
+real lincs_rmsd(const Lincs *lincsd)
{
if (lincsd->rmsd_data[0] > 0)
{
}
}
-/* Do a set of nrec LINCS matrix multiplications.
+/*! \brief Do a set of nrec LINCS matrix multiplications.
+ *
* This function will return with up to date thread-local
* constraint data, without an OpenMP barrier.
*/
-static void lincs_matrix_expand(const gmx_lincsdata *lincsd,
- const lincs_task_t *li_task,
+static void lincs_matrix_expand(const Lincs *lincsd,
+ const Task *li_task,
const real *blcc,
real *rhs1, real *rhs2, real *sol)
{
swap = rhs1;
rhs1 = rhs2;
rhs2 = swap;
- } /* nrec*(ncons+2*nrtot) flops */
+ } /* nrec*(ncons+2*nrtot) flops */
if (lincsd->ntriangle > 0)
{
swap = rhs1;
rhs1 = rhs2;
rhs2 = swap;
- } /* nrec*(ntriangle + ncc_triangle*2) flops */
+ } /* nrec*(ntriangle + ncc_triangle*2) flops */
if (lincsd->bTaskDepTri)
{
}
}
+//! Update atomic coordinates when an index is not required.
static void lincs_update_atoms_noind(int ncons, const int *bla,
real prefac,
const real *fac, rvec *r,
x[j][0] += tmp0*im2;
x[j][1] += tmp1*im2;
x[j][2] += tmp2*im2;
- } /* 16 ncons flops */
+ } /* 16 ncons flops */
}
else
{
}
}
+//! Update atomic coordinates when an index is required.
static void lincs_update_atoms_ind(int ncons, const int *ind, const int *bla,
real prefac,
const real *fac, rvec *r,
x[j][0] += tmp0*im2;
x[j][1] += tmp1*im2;
x[j][2] += tmp2*im2;
- } /* 16 ncons flops */
+ } /* 16 ncons flops */
}
else
{
x[j][0] += tmp0;
x[j][1] += tmp1;
x[j][2] += tmp2;
- } /* 16 ncons flops */
+ } /* 16 ncons flops */
}
}
-static void lincs_update_atoms(gmx_lincsdata *li, int th,
+//! Update coordinates for atoms.
+static void lincs_update_atoms(Lincs *li, int th,
real prefac,
const real *fac, rvec *r,
const real *invmass,
}
#if GMX_SIMD_HAVE_REAL
-/* Calculate the constraint distance vectors r to project on from x.
+/*! \brief Calculate the constraint distance vectors r to project on from x.
+ *
* Determine the right-hand side of the matrix equation using quantity f.
* This function only differs from calc_dr_x_xp_simd below in that
- * no constraint length is subtracted and no PBC is used for f.
- */
+ * no constraint length is subtracted and no PBC is used for f. */
static void gmx_simdcall
calc_dr_x_f_simd(int b0,
int b1,
}
#endif // GMX_SIMD_HAVE_REAL
-/* LINCS projection, works on derivatives of the coordinates */
+/*! \brief LINCS projection, works on derivatives of the coordinates. */
static void do_lincsp(rvec *x, rvec *f, rvec *fp, t_pbc *pbc,
- gmx_lincsdata *lincsd, int th,
+ Lincs *lincsd, int th,
real *invmass,
- int econq, gmx_bool bCalcDHDL,
- gmx_bool bCalcVir, tensor rmdf)
+ int econq, bool bCalcDHDL,
+ bool bCalcVir, tensor rmdf)
{
int b0, b1, b;
int *bla, *blnr, *blbnb;
pbc_simd,
r, rhs1, sol);
-#else // GMX_SIMD_HAVE_REAL
+#else // GMX_SIMD_HAVE_REAL
/* Compute normalized i-j vectors */
if (pbc)
rvec_sub(x[bla[2*b]], x[bla[2*b+1]], dx);
unitv(dx, r[b]);
- } /* 16 ncons flops */
+ } /* 16 ncons flops */
}
for (b = b0; b < b1; b++)
/* 7 flops */
}
-#endif // GMX_SIMD_HAVE_REAL
+#endif // GMX_SIMD_HAVE_REAL
if (lincsd->bTaskDep)
{
for (n = blnr[b]; n < blnr[b+1]; n++)
{
- blcc[n] = blmf[n]*iprod(r[b], r[blbnb[n]]);
- } /* 6 nr flops */
+ blcc[n] = blmf[n]*::iprod(r[b], r[blbnb[n]]);
+ } /* 6 nr flops */
}
/* Together: 23*ncons + 6*nrtot flops */
rmdf[i][j] += tmp1*r[b][j];
}
}
- } /* 23 ncons flops */
+ } /* 23 ncons flops */
}
}
#if GMX_SIMD_HAVE_REAL
-/* Calculate the constraint distance vectors r to project on from x.
- * Determine the right-hand side of the matrix equation using coordinates xp.
- */
+/*! \brief Calculate the constraint distance vectors r to project on from x.
+ *
+ * Determine the right-hand side of the matrix equation using coordinates xp. */
static void gmx_simdcall
calc_dr_x_xp_simd(int b0,
int b1,
}
#endif // GMX_SIMD_HAVE_REAL
-/* Determine the distances and right-hand side for the next iteration */
+/*! \brief Determine the distances and right-hand side for the next iteration. */
gmx_unused static void calc_dist_iter(
int b0,
int b1,
real wfac,
real * gmx_restrict rhs,
real * gmx_restrict sol,
- gmx_bool * bWarn)
+ bool * bWarn)
{
int b;
rvec_sub(xp[bla[2*b]], xp[bla[2*b+1]], dx);
}
len2 = len*len;
- dlen2 = 2*len2 - norm2(dx);
+ dlen2 = 2*len2 - ::norm2(dx);
if (dlen2 < wfac*len2)
{
/* not race free - see detailed comment in caller */
}
rhs[b] = mvb;
sol[b] = mvb;
- } /* 20*ncons flops */
+ } /* 20*ncons flops */
}
#if GMX_SIMD_HAVE_REAL
-/* As the function above, but using SIMD intrinsics */
+/*! \brief As calc_dist_iter(), but using SIMD intrinsics. */
static void gmx_simdcall
calc_dist_iter_simd(int b0,
int b1,
real wfac,
real * gmx_restrict rhs,
real * gmx_restrict sol,
- gmx_bool * bWarn)
+ bool * bWarn)
{
SimdReal min_S(GMX_REAL_MIN);
SimdReal two_S(2.0);
}
#endif // GMX_SIMD_HAVE_REAL
+//! Implements LINCS constraining.
static void do_lincs(rvec *x, rvec *xp, matrix box, t_pbc *pbc,
- gmx_lincsdata *lincsd, int th,
+ Lincs *lincsd, int th,
const real *invmass,
const t_commrec *cr,
- gmx_bool bCalcDHDL,
- real wangle, gmx_bool *bWarn,
+ bool bCalcDHDL,
+ real wangle, bool *bWarn,
real invdt, rvec * gmx_restrict v,
- gmx_bool bCalcVir, tensor vir_r_m_dr)
+ bool bCalcVir, tensor vir_r_m_dr)
{
int b0, b1, b, i, j, n, iter;
int *bla, *blnr, *blbnb;
pbc_simd,
r, rhs1, sol);
-#else // GMX_SIMD_HAVE_REAL
+#else // GMX_SIMD_HAVE_REAL
if (pbc)
{
unitv(dx, r[b]);
pbc_dx_aiuc(pbc, xp[bla[2*b]], xp[bla[2*b+1]], dx);
- mvb = blc[b]*(iprod(r[b], dx) - bllen[b]);
+ mvb = blc[b]*(::iprod(r[b], dx) - bllen[b]);
rhs1[b] = mvb;
sol[b] = mvb;
}
/* Together: 26*ncons + 6*nrtot flops */
}
-#endif // GMX_SIMD_HAVE_REAL
+#endif // GMX_SIMD_HAVE_REAL
if (lincsd->bTaskDep)
{
{
for (n = blnr[b]; n < blnr[b+1]; n++)
{
- blcc[n] = blmf[n]*iprod(r[b], r[blbnb[n]]);
+ blcc[n] = blmf[n]*::iprod(r[b], r[blbnb[n]]);
}
}
/* Together: 26*ncons + 6*nrtot flops */
{
mlambda[b] = blc[b]*sol[b];
}
-#endif // GMX_SIMD_HAVE_REAL
+#endif // GMX_SIMD_HAVE_REAL
/* Update the coordinates */
lincs_update_atoms(lincsd, th, 1.0, mlambda, r, invmass, xp);
calc_dist_iter(b0, b1, bla, xp, bllen, blc, pbc, wfac,
rhs1, sol, bWarn);
/* 20*ncons flops */
-#endif // GMX_SIMD_HAVE_REAL
+#endif // GMX_SIMD_HAVE_REAL
lincs_matrix_expand(lincsd, &lincsd->task[th], blcc, rhs1, rhs2, sol);
/* nrec*(ncons+2*nrtot) flops */
blc_sol[b] = mvb;
mlambda[b] += mvb;
}
-#endif // GMX_SIMD_HAVE_REAL
+#endif // GMX_SIMD_HAVE_REAL
/* Update the coordinates */
lincs_update_atoms(lincsd, th, 1.0, blc_sol, r, invmass, xp);
vir_r_m_dr[i][j] -= tmp1*r[b][j];
}
}
- } /* 22 ncons flops */
+ } /* 22 ncons flops */
}
/* Total:
*/
}
-/* Sets the elements in the LINCS matrix for task li_task */
-static void set_lincs_matrix_task(gmx_lincsdata *li,
- lincs_task_t *li_task,
+/*! \brief Sets the elements in the LINCS matrix for task task. */
+static void set_lincs_matrix_task(Lincs *li,
+ Task *li_task,
const real *invmass,
int *ncc_triangle,
int *nCrossTaskTriangles)
}
}
-/* Sets the elements in the LINCS matrix */
-static void set_lincs_matrix(gmx_lincsdata *li, real *invmass, real lambda)
+/*! \brief Sets the elements in the LINCS matrix. */
+static void set_lincs_matrix(Lincs *li, real *invmass, real lambda)
{
int i;
const real invsqrt2 = 0.7071067811865475244;
li->matlam = lambda;
}
+//! Finds all triangles of atoms that share constraints to a central atom.
static int count_triangle_constraints(const t_ilist *ilist,
const t_blocka *at2con)
{
int ncon1, ncon_tot;
int c0, a00, a01, n1, c1, a10, a11, ac1, n2, c2, a20, a21;
int ncon_triangle;
- gmx_bool bTriangle;
+ bool bTriangle;
t_iatom *ia1, *ia2, *iap;
ncon1 = ilist[F_CONSTR].nr/3;
return ncon_triangle;
}
-static gmx_bool more_than_two_sequential_constraints(const t_ilist *ilist,
- const t_blocka *at2con)
+//! Finds sequences of sequential constraints.
+static bool more_than_two_sequential_constraints(const t_ilist *ilist,
+ const t_blocka *at2con)
{
t_iatom *ia1, *ia2, *iap;
int ncon1, ncon_tot, c;
int a1, a2;
- gmx_bool bMoreThanTwoSequentialConstraints;
+ bool bMoreThanTwoSequentialConstraints;
ncon1 = ilist[F_CONSTR].nr/3;
ncon_tot = ncon1 + ilist[F_CONSTRNC].nr/3;
return bMoreThanTwoSequentialConstraints;
}
+//! Sorting helper function to compare two integers.
static int int_comp(const void *a, const void *b)
{
return (*(int *)a) - (*(int *)b);
}
-gmx_lincsdata_t init_lincs(FILE *fplog, const gmx_mtop_t *mtop,
- int nflexcon_global, const t_blocka *at2con,
- gmx_bool bPLINCS, int nIter, int nProjOrder)
+Lincs *init_lincs(FILE *fplog, const gmx_mtop_t *mtop,
+ int nflexcon_global, const t_blocka *at2con,
+ bool bPLINCS, int nIter, int nProjOrder)
{
- gmx_lincsdata *li;
- gmx_bool bMoreThanTwoSeq;
+ Lincs *li;
+ bool bMoreThanTwoSeq;
if (fplog)
{
return li;
}
-/* Sets up the work division over the threads */
-static void lincs_thread_setup(gmx_lincsdata *li, int natoms)
+/*! \brief Sets up the work division over the threads. */
+static void lincs_thread_setup(Lincs *li, int natoms)
{
- lincs_task_t *li_m;
+ Task *li_m;
int th;
gmx_bitmask_t *atf;
int a;
for (th = 0; th < li->ntask; th++)
{
- lincs_task_t *li_task;
+ Task *li_task;
int b;
li_task = &li->task[th];
{
try
{
- lincs_task_t *li_task;
+ Task *li_task;
gmx_bitmask_t mask;
int b;
li_m->nind = 0;
for (th = 0; th < li->ntask; th++)
{
- lincs_task_t *li_task;
+ Task *li_task;
int b;
li_task = &li->task[th];
}
}
-/* There is no realloc with alignment, so here we make one for reals.
+/*! \brief There is no realloc with alignment, so here we make one for reals.
* Note that this function does not preserve the contents of the memory.
*/
static void resize_real_aligned(real **ptr, int nelem)
snew_aligned(*ptr, nelem, align_bytes);
}
-static void assign_constraint(gmx_lincsdata *li,
+//! Assign a constraint.
+static void assign_constraint(Lincs *li,
int constraint_index,
int a1, int a2,
real lenA, real lenB,
li->nc++;
}
-/* Check if constraint with topology index constraint_index is connected
- * to other constraints, and if so add those connected constraints to our task.
- */
-static void check_assign_connected(gmx_lincsdata *li,
+/*! \brief Check if constraint with topology index constraint_index is connected
+ * to other constraints, and if so add those connected constraints to our task. */
+static void check_assign_connected(Lincs *li,
const t_iatom *iatom,
const t_idef *idef,
int bDynamics,
}
}
-/* Check if constraint with topology index constraint_index is involved
+/*! \brief Check if constraint with topology index constraint_index is involved
* in a constraint triangle, and if so add the other two constraints
- * in the triangle to our task.
- */
-static void check_assign_triangle(gmx_lincsdata *li,
+ * in the triangle to our task. */
+static void check_assign_triangle(Lincs *li,
const t_iatom *iatom,
const t_idef *idef,
int bDynamics,
}
}
-static void set_matrix_indices(gmx_lincsdata *li,
- const lincs_task_t *li_task,
+//! Sets matrix indices.
+static void set_matrix_indices(Lincs *li,
+ const Task *li_task,
const t_blocka *at2con,
- gmx_bool bSortMatrix)
+ bool bSortMatrix)
{
int b;
void set_lincs(const t_idef *idef,
const t_mdatoms *md,
- gmx_bool bDynamics,
+ bool bDynamics,
const t_commrec *cr,
- gmx_lincsdata *li)
+ Lincs *li)
{
int natoms, nflexcon;
t_blocka at2con;
con = 0;
for (th = 0; th < li->ntask; th++)
{
- lincs_task_t *li_task;
+ Task *li_task;
li_task = &li->task[th];
*/
ncon_target = ((ncon_assign*(th + 1))/li->ntask - li->nc_real + GMX_SIMD_REAL_WIDTH - 1) & ~(GMX_SIMD_REAL_WIDTH - 1);
}
-#endif // GMX_SIMD==2 && GMX_SIMD_HAVE_REAL
+#endif // GMX_SIMD==2 && GMX_SIMD_HAVE_REAL
/* Continue filling the arrays where we left off with the previous task,
* including padding for SIMD.
assert(li->nc_real == ncon_assign);
- gmx_bool bSortMatrix;
+ bool bSortMatrix;
/* Without DD we order the blbnb matrix to optimize memory access.
* With DD the overhead of sorting is more than the gain during access.
{
try
{
- lincs_task_t *li_task;
+ Task *li_task;
li_task = &li->task[th];
set_lincs_matrix(li, md->invmass, md->lambda);
}
+//! Issues a warning when LINCS constraints cannot be satisfied.
static void lincs_warning(FILE *fplog,
gmx_domdec_t *dd, rvec *x, rvec *xprime, t_pbc *pbc,
int ncons, int *bla, real *bllen, real wangle,
}
d0 = norm(v0);
d1 = norm(v1);
- cosine = iprod(v0, v1)/(d0*d1);
+ cosine = ::iprod(v0, v1)/(d0*d1);
if (cosine < wfac)
{
sprintf(buf, " %6d %6d %5.1f %8.4f %8.4f %8.4f\n",
}
}
-static void cconerr(const gmx_lincsdata *lincsd,
+//! Determine how well the constraints have been satisfied.
+static void cconerr(const Lincs *lincsd,
rvec *x, t_pbc *pbc,
real *ncons_loc, real *ssd, real *max, int *imax)
{
{
rvec_sub(x[bla[2*b]], x[bla[2*b+1]], dx);
}
- r2 = norm2(dx);
+ r2 = ::norm2(dx);
len = r2*gmx::invsqrt(r2);
d = std::abs(len/bllen[b]-1);
if (d > ma && (nlocat == nullptr || nlocat[b]))
*imax = im;
}
-gmx_bool constrain_lincs(FILE *fplog, gmx_bool bLog, gmx_bool bEner,
- const t_inputrec *ir,
- gmx_int64_t step,
- gmx_lincsdata *lincsd, t_mdatoms *md,
- const t_commrec *cr,
- const gmx_multisim_t *ms,
- rvec *x, rvec *xprime, rvec *min_proj,
- matrix box, t_pbc *pbc,
- real lambda, real *dvdlambda,
- real invdt, rvec *v,
- gmx_bool bCalcVir, tensor vir_r_m_dr,
- int econq,
- t_nrnb *nrnb,
- int maxwarn, int *warncount)
+bool constrain_lincs(FILE *fplog, bool bLog, bool bEner,
+ const t_inputrec *ir,
+ gmx_int64_t step,
+ Lincs *lincsd, t_mdatoms *md,
+ const t_commrec *cr,
+ const gmx_multisim_t *ms,
+ rvec *x, rvec *xprime, rvec *min_proj,
+ matrix box, t_pbc *pbc,
+ real lambda, real *dvdlambda,
+ real invdt, rvec *v,
+ bool bCalcVir, tensor vir_r_m_dr,
+ int econq,
+ t_nrnb *nrnb,
+ int maxwarn, int *warncount)
{
gmx_bool bCalcDHDL;
char buf[STRLEN], buf2[22], buf3[STRLEN];
int i, p_imax;
real ncons_loc, p_ssd, p_max = 0;
rvec dx;
- gmx_bool bOK, bWarn;
+ bool bOK, bWarn;
bOK = TRUE;
return bOK;
}
+
+} // namespace
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+/*! \libinternal \file
+ * \brief Declares interface to LINCS code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ * \inlibraryapi
+ */
#ifndef GMX_MDLIB_LINCS_H
#define GMX_MDLIB_LINCS_H
struct t_nrnb;
struct t_pbc;
+namespace gmx
+{
+
/* Abstract type for LINCS that is defined only in the file that uses it */
-typedef struct gmx_lincsdata *gmx_lincsdata_t;
+class Lincs;
-real *lincs_rmsd_data(gmx_lincsdata_t lincsd);
-/* Return the data for determining constraint RMS relative deviations */
+/*! \brief Return the data for determining constraint RMS relative deviations. */
+real *lincs_rmsd_data(Lincs *lincsd);
-real lincs_rmsd(gmx_lincsdata_t lincsd);
-/* Return the RMSD of the constraint */
+/*! \brief Return the RMSD of the constraint. */
+real lincs_rmsd(const Lincs *lincsd);
-gmx_lincsdata_t init_lincs(FILE *fplog, const gmx_mtop_t *mtop,
- int nflexcon_global, const t_blocka *at2con,
- gmx_bool bPLINCS, int nIter, int nProjOrder);
-/* Initializes and returns the lincs data struct */
+/*! \brief Initializes and returns the lincs data struct. */
+Lincs *init_lincs(FILE *fplog, const gmx_mtop_t *mtop,
+ int nflexcon_global, const t_blocka *at2con,
+ bool bPLINCS, int nIter, int nProjOrder);
+/*! \brief Initialize lincs stuff */
void set_lincs(const t_idef *idef, const t_mdatoms *md,
- gmx_bool bDynamics, const t_commrec *cr,
- gmx_lincsdata_t li);
-/* Initialize lincs stuff */
+ bool bDynamics, const t_commrec *cr,
+ Lincs *li);
-gmx_bool
-constrain_lincs(FILE *log, gmx_bool bLog, gmx_bool bEner,
+/*! \brief Applies LINCS constraints.
+ *
+ * \returns true if the constraining succeeded. */
+bool
+constrain_lincs(FILE *log, bool bLog, bool bEner,
const t_inputrec *ir,
gmx_int64_t step,
- gmx_lincsdata_t lincsd, t_mdatoms *md,
+ Lincs *lincsd, t_mdatoms *md,
const t_commrec *cr,
const gmx_multisim_t *ms,
rvec *x, rvec *xprime, rvec *min_proj,
matrix box, t_pbc *pbc,
real lambda, real *dvdlambda,
real invdt, rvec *v,
- gmx_bool bCalcVir, tensor vir_r_m_dr,
+ bool bCalcVir, tensor vir_r_m_dr,
int econ,
t_nrnb *nrnb,
int maxwarn, int *warncount);
-/* Returns if the constraining succeeded */
+
+} // namespace
#endif
t_state *state, t_mdatoms *mdatoms,
t_nrnb *nrnb, t_vcm *vcm, gmx_wallcycle_t wcycle,
gmx_enerdata_t *enerd, tensor force_vir, tensor shake_vir, tensor total_vir,
- tensor pres, rvec mu_tot, struct gmx_constr *constr,
+ tensor pres, rvec mu_tot, gmx::Constraints *constr,
gmx::SimulationSignaller *signalCoordinator,
matrix box, int *totalNumberOfBondedInteractions,
gmx_bool *bSumEkinhOld, int flags)
#include "gromacs/mdlib/vcm.h"
#include "gromacs/timing/wallcycle.h"
-struct gmx_constr;
struct gmx_ekindata_t;
struct gmx_enerdata_t;
struct gmx_global_stat;
namespace gmx
{
+class Constraints;
class MDLogger;
class SimulationSignaller;
}
t_state *state, t_mdatoms *mdatoms,
t_nrnb *nrnb, t_vcm *vcm, gmx_wallcycle_t wcycle,
gmx_enerdata_t *enerd, tensor force_vir, tensor shake_vir, tensor total_vir,
- tensor pres, rvec mu_tot, gmx_constr *constr,
+ tensor pres, rvec mu_tot, gmx::Constraints *constr,
gmx::SimulationSignaller *signalCoordinator,
matrix box, int *totalNumberOfBondedInteractions,
gmx_bool *bSumEkinhOld, int flags);
}
}
-void upd_mdebin(t_mdebin *md,
- gmx_bool bDoDHDL,
- gmx_bool bSum,
- double time,
- real tmass,
- gmx_enerdata_t *enerd,
- t_state *state,
- t_lambda *fep,
- t_expanded *expand,
- matrix box,
- tensor svir,
- tensor fvir,
- tensor vir,
- tensor pres,
- gmx_ekindata_t *ekind,
- rvec mu_tot,
- gmx_constr_t constr)
+void upd_mdebin(t_mdebin *md,
+ gmx_bool bDoDHDL,
+ gmx_bool bSum,
+ double time,
+ real tmass,
+ gmx_enerdata_t *enerd,
+ t_state *state,
+ t_lambda *fep,
+ t_expanded *expand,
+ matrix box,
+ tensor svir,
+ tensor fvir,
+ tensor vir,
+ tensor pres,
+ gmx_ekindata_t *ekind,
+ rvec mu_tot,
+ const gmx::Constraints *constr)
{
int i, j, k, kk, n, gid;
real crmsd[2], tmp6[6];
add_ebin(md->ebin, md->ie, md->f_nre, ecopy, bSum);
if (md->nCrmsd)
{
- crmsd[0] = constr_rmsd(constr);
+ crmsd[0] = gmx::constr_rmsd(constr);
add_ebin(md->ebin, md->iconrmsd, md->nCrmsd, crmsd, FALSE);
}
if (md->bDynBox)
#include "gromacs/mdtypes/forcerec.h"
class energyhistory_t;
-struct gmx_constr;
struct gmx_ekindata_t;
struct gmx_mtop_t;
struct gmx_output_env_t;
namespace gmx
{
class Awh;
+class Constraints;
}
/* The functions & data structures here determine the content for outputting
tensor pres,
gmx_ekindata_t *ekind,
rvec mu_tot,
- gmx_constr *constr);
+ const gmx::Constraints *constr);
void upd_mdebin_step(t_mdebin *md);
/* Updates only the step count in md */
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+/*! \internal \file
+ * \brief Defines SETTLE code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ */
#include "gmxpre.h"
#include "settle.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
-using namespace gmx; // TODO: Remove when this file is moved into gmx namespace
+namespace gmx
+{
-typedef struct
+struct settleparam_t
{
real mO;
real mH;
real invdOH;
real invdHH;
matrix invmat;
-} settleparam_t;
+};
-typedef struct gmx_settledata
+struct settledata
{
settleparam_t massw; /* Parameters for SETTLE for coordinates */
settleparam_t mass1; /* Parameters with all masses 1, for forces */
int nalloc; /* Allocation size of ow1, hw2, hw3, virfac */
bool bUseSimd; /* Use SIMD intrinsics code, if possible */
-} t_gmx_settledata;
+};
+//! Initializes a projection matrix.
static void init_proj_matrix(real invmO, real invmH, real dOH, real dHH,
matrix inverseCouplingMatrix)
{
msmul(inverseCouplingMatrix, 1/invmO, inverseCouplingMatrix);
}
+//! Initializes settle parameters.
static void settleparam_init(settleparam_t *p,
real mO, real mH, real invmO, real invmH,
real dOH, real dHH)
}
}
-gmx_settledata_t settle_init(const gmx_mtop_t *mtop)
+settledata *settle_init(const gmx_mtop_t *mtop)
{
/* Check that we have only one settle type */
int settle_type = -1;
}
GMX_RELEASE_ASSERT(settle_type >= 0, "settle_init called without settles");
- gmx_settledata_t settled;
+ settledata *settled;
snew(settled, 1);
return settled;
}
-void settle_free(gmx_settledata_t settled)
+void settle_free(settledata *settled)
{
sfree_aligned(settled->ow1);
sfree_aligned(settled->hw2);
sfree(settled);
}
-void settle_set_constraints(gmx_settledata_t settled,
+void settle_set_constraints(settledata *settled,
const t_ilist *il_settle,
const t_mdatoms *mdatoms)
{
}
}
-void settle_proj(gmx_settledata_t settled, int econq,
+void settle_proj(settledata *settled, int econq,
int nsettle, t_iatom iatoms[],
const t_pbc *pbc,
rvec x[],
}
-/* The actual settle code, templated for real/SimdReal and for optimization */
+/*! \brief The actual settle code, templated for real/SimdReal and for optimization */
template<typename T, typename TypeBool, int packSize,
typename TypePbc,
bool bCorrectVelocity,
bool bCalcVirial>
-static void settleTemplate(const gmx_settledata_t settled,
+static void settleTemplate(const settledata *settled,
int settleStart, int settleEnd,
const TypePbc pbc,
const real *x, real *xprime,
assert(settleStart % packSize == 0);
assert(settleEnd % packSize == 0);
- TypeBool bError = TypeBool(false);
+ TypeBool bError = TypeBool(false);
- settleparam_t *p = &settled->massw;
- T wh = T(p->wh);
- T rc = T(p->rc);
- T ra = T(p->ra);
- T rb = T(p->rb);
- T irc2 = T(p->irc2);
- T mO = T(p->mO);
- T mH = T(p->mH);
+ const settleparam_t *p = &settled->massw;
+ T wh = T(p->wh);
+ T rc = T(p->rc);
+ T ra = T(p->ra);
+ T rb = T(p->rb);
+ T irc2 = T(p->irc2);
+ T mO = T(p->mO);
+ T mH = T(p->mH);
- T almost_zero = T(1e-12);
+ T almost_zero = T(1e-12);
- T sum_r_m_dr[DIM][DIM];
+ T sum_r_m_dr[DIM][DIM];
if (bCalcVirial)
{
*bErrorHasOccurred = anyTrue(bError);
}
-/* Wrapper template function that divides the settles over threads
+/*! \brief Wrapper template function that divides the settles over threads
* and instantiates the core template with instantiated booleans.
*/
template<typename T, typename TypeBool, int packSize, typename TypePbc>
-static void settleTemplateWrapper(gmx_settledata_t settled,
+static void settleTemplateWrapper(settledata *settled,
int nthread, int thread,
TypePbc pbc,
const real x[], real xprime[],
}
}
-void csettle(gmx_settledata_t settled,
+void csettle(settledata *settled,
int nthread, int thread,
const t_pbc *pbc,
const real x[], real xprime[],
bErrorHasOccurred);
}
}
+
+} // namespace
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+/*! \libinternal \file
+ * \brief Declares interface to SETTLE code.
+ *
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ * \inlibraryapi
+ */
#ifndef GMX_MDLIB_SETTLE_H
#define GMX_MDLIB_SETTLE_H
struct t_mdatoms;
struct t_pbc;
+namespace gmx
+{
+
/* Abstract type for SETTLE that is defined only in the file that uses it */
-typedef struct gmx_settledata *gmx_settledata_t;
+struct settledata;
-gmx_settledata_t settle_init(const gmx_mtop_t *mtop);
-/* Initializes and returns a structure with SETTLE parameters */
+/*! \brief Initializes and returns a structure with SETTLE parameters */
+settledata *settle_init(const gmx_mtop_t *mtop);
-void settle_free(gmx_settledata_t settled);
+//! Cleans up.
+void settle_free(settledata *settled);
-void settle_set_constraints(gmx_settledata_t settled,
+/*! \brief Set up the indices for the settle constraints */
+void settle_set_constraints(settledata *settled,
const t_ilist *il_settle,
const t_mdatoms *mdatoms);
-/* Set up the indices for the settle constraints */
-void csettle(gmx_settledata_t settled, /* The SETTLE structure */
+/*! \brief Constrain coordinates using SETTLE.
+ * Can be called on any number of threads.
+ */
+void csettle(settledata *settled, /* The SETTLE structure */
int nthread, /* The number of threads used */
int thread, /* Our thread index */
const t_pbc *pbc, /* PBC data pointer, can be NULL */
tensor vir_r_m_dr, /* sum r x m delta_r */
bool *bErrorHasOccurred /* True if a settle error occurred */
);
-/* Constrain coordinates using SETTLE.
- * Can be called on any number of threads.
- */
-void settle_proj(gmx_settledata_t settled, int econq,
+/*! \brief Analytical algorithm to subtract the components of derivatives
+ * of coordinates working on settle type constraint.
+ */
+void settle_proj(settledata *settled, int econq,
int nsettle, t_iatom iatoms[],
const t_pbc *pbc, /* PBC data pointer, can be NULL */
rvec x[],
rvec *der, rvec *derp,
int CalcVirAtomEnd, tensor vir_r_m_dder);
-/* Analytical algorithm to subtract the components of derivatives
- * of coordinates working on settle type constraint.
- */
+
+} // namespace
#endif
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+/*! \internal \file
+ * \brief Defines SHAKE code.
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ */
#include "gmxpre.h"
#include "shake.h"
#include "gromacs/gmxlib/nrnb.h"
#include "gromacs/math/functions.h"
#include "gromacs/math/vec.h"
+#include "gromacs/mdlib/constr.h"
#include "gromacs/mdlib/splitter.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
-typedef struct gmx_shakedata
+namespace gmx
+{
+
+struct shakedata
{
rvec *rij;
real *half_of_reduced_mass;
* constraint distance. */
real *scaled_lagrange_multiplier;
int lagr_nalloc; /* The allocation size of scaled_lagrange_multiplier */
-} t_gmx_shakedata;
+};
-gmx_shakedata_t shake_init()
+shakedata *shake_init()
{
- gmx_shakedata_t d;
+ shakedata *d;
snew(d, 1);
int blocknr;
} t_sortblock;
+//! Compares sort blocks.
static int pcomp(const void *p1, const void *p2)
{
int db;
}
}
+//! Prints sortblocks
static void pr_sortblock(FILE *fp, const char *title, int nsb, t_sortblock sb[])
{
int i;
}
}
-static void resizeLagrangianData(gmx_shakedata *shaked, int ncons)
+//! Reallocates a vector.
+static void resizeLagrangianData(shakedata *shaked, int ncons)
{
if (ncons > shaked->lagr_nalloc)
{
}
void
-make_shake_sblock_serial(gmx_shakedata *shaked,
+make_shake_sblock_serial(shakedata *shaked,
const t_idef *idef, const t_mdatoms *md)
{
int i, j, m, ncons;
}
void
-make_shake_sblock_dd(gmx_shakedata *shaked,
+make_shake_sblock_dd(shakedata *shaked,
const t_ilist *ilcon, const t_block *cgs,
const gmx_domdec_t *dd)
{
*nerror = error;
}
+//! Implements RATTLE (ie. SHAKE for velocity verlet integrators)
static void
crattle(int iatom[], int ncon, int *nnit, int maxnit,
real constraint_distance_squared[], real vp[], real rij[], real m2[], real omega,
*nerror = error;
}
-static int vec_shakef(FILE *fplog, gmx_shakedata_t shaked,
+//! Applies SHAKE
+static int vec_shakef(FILE *fplog, shakedata *shaked,
const real invmass[], int ncon,
t_iparams ip[], t_iatom *iatom,
real tol, rvec x[], rvec prime[], real omega,
- gmx_bool bFEP, real lambda, real scaled_lagrange_multiplier[],
+ bool bFEP, real lambda, real scaled_lagrange_multiplier[],
real invdt, rvec *v,
- gmx_bool bCalcVir, tensor vir_r_m_dr, int econq)
+ bool bCalcVir, tensor vir_r_m_dr, int econq)
{
rvec *rij;
real *half_of_reduced_mass, *distance_squared_tolerance, *constraint_distance_squared;
return nit;
}
+//! Check that constraints are satisfied.
static void check_cons(FILE *log, int nc, rvec x[], rvec prime[], rvec v[],
t_iparams ip[], t_iatom *iatom,
const real invmass[], int econq)
}
}
-static gmx_bool
-bshakef(FILE *log, gmx_shakedata_t shaked,
+//! Applies SHAKE.
+static bool
+bshakef(FILE *log, shakedata *shaked,
const real invmass[],
const t_idef *idef, const t_inputrec *ir, rvec x_s[], rvec prime[],
t_nrnb *nrnb, real lambda, real *dvdlambda,
- real invdt, rvec *v, gmx_bool bCalcVir, tensor vir_r_m_dr,
- gmx_bool bDumpOnError, int econq)
+ real invdt, rvec *v, bool bCalcVir, tensor vir_r_m_dr,
+ bool bDumpOnError, int econq)
{
t_iatom *iatoms;
real *lam, dt_2, dvdl;
bool
constrain_shake(FILE *log,
- gmx_shakedata_t shaked,
+ shakedata *shaked,
const real invmass[],
const t_idef *idef,
const t_inputrec *ir,
real *dvdlambda,
real invdt,
rvec *v,
- gmx_bool bCalcVir,
+ bool bCalcVir,
tensor vir_r_m_dr,
- gmx_bool bDumpOnError,
+ bool bDumpOnError,
int econq)
{
if (shaked->nblocks == 0)
}
return bOK;
}
+
+} // namespace
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+/*! \libinternal \file
+ * \brief Declares interface to SHAKE code.
+ *
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
+ * \author Berk Hess <hess@kth.se>
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdlib
+ * \inlibraryapi
+ */
#ifndef GMX_MDLIB_SHAKE_H
#define GMX_MDLIB_SHAKE_H
-#include "gromacs/mdlib/constr.h"
#include "gromacs/topology/block.h"
#include "gromacs/topology/idef.h"
struct gmx_domdec_t;
struct t_inputrec;
+struct t_mdatoms;
+struct t_nrnb;
+
+namespace gmx
+{
/* Abstract type for SHAKE that is defined only in the file that uses it */
-typedef struct gmx_shakedata *gmx_shakedata_t;
+struct shakedata;
-gmx_shakedata_t shake_init();
-/* Initializes and return the SHAKE data structure */
+/*! \brief Initializes and return the SHAKE data structure */
+shakedata *shake_init();
+//! Make SHAKE blocks when not using DD.
void
-make_shake_sblock_serial(gmx_shakedata *shaked,
+make_shake_sblock_serial(shakedata *shaked,
const t_idef *idef, const t_mdatoms *md);
+//! Make SHAKE blocks when using DD.
void
-make_shake_sblock_dd(gmx_shakedata *shaked,
+make_shake_sblock_dd(shakedata *shaked,
const t_ilist *ilcon, const t_block *cgs,
const gmx_domdec_t *dd);
+/*! \brief Shake all the atoms blockwise. It is assumed that all the constraints
+ * in the idef->shakes field are sorted, to ascending block nr. The
+ * sblock array points into the idef->shakes.iatoms field, with block 0
+ * starting
+ * at sblock[0] and running to ( < ) sblock[1], block n running from
+ * sblock[n] to sblock[n+1]. Array sblock should be large enough.
+ * Return TRUE when OK, FALSE when shake-error
+ */
bool
constrain_shake(FILE *log, /* Log file */
- gmx_shakedata_t shaked, /* Total number of atoms */
+ shakedata *shaked, /* Total number of atoms */
const real invmass[], /* Atomic masses */
const t_idef *idef, /* The interaction def */
const t_inputrec *ir, /* Input record */
real *dvdlambda, /* FEP force */
real invdt, /* 1/delta_t */
rvec *v, /* Also constrain v if v!=NULL */
- gmx_bool bCalcVir, /* Calculate r x m delta_r */
+ bool bCalcVir, /* Calculate r x m delta_r */
tensor vir_r_m_dr, /* sum r x m delta_r */
- gmx_bool bDumpOnError, /* Dump debugging stuff on error*/
+ bool bDumpOnError, /* Dump debugging stuff on error*/
int econq); /* which type of constraint is occurring */
-/* Shake all the atoms blockwise. It is assumed that all the constraints
- * in the idef->shakes field are sorted, to ascending block nr. The
- * sblock array points into the idef->shakes.iatoms field, with block 0
- * starting
- * at sblock[0] and running to ( < ) sblock[1], block n running from
- * sblock[n] to sblock[n+1]. Array sblock should be large enough.
- * Return TRUE when OK, FALSE when shake-error
- */
+/*! \brief Regular iterative shake */
void cshake(const int iatom[], int ncon, int *nnit, int maxnit,
const real dist2[], real xp[], const real rij[], const real m2[], real omega,
const real invmass[], const real tt[], real lagr[], int *nerror);
-/* Regular iterative shake */
+
+} // namespace
#endif
}
static void init_adir(FILE *log, gmx_shellfc_t *shfc,
- gmx_constr_t constr, t_idef *idef, t_inputrec *ir,
+ gmx::Constraints *constr, t_idef *idef, t_inputrec *ir,
const t_commrec *cr,
const gmx_multisim_t *ms,
int dd_ac1,
constrain(log, FALSE, FALSE, constr, idef, ir, cr, ms, step, 0, 1.0, md,
x, xnold, nullptr, bMolPBC, box,
lambda[efptBONDED], &(dvdlambda[efptBONDED]),
- nullptr, nullptr, nrnb, econqCoord);
+ nullptr, nullptr, nrnb, gmx::econqCoord);
constrain(log, FALSE, FALSE, constr, idef, ir, cr, ms, step, 0, 1.0, md,
x, xnew, nullptr, bMolPBC, box,
lambda[efptBONDED], &(dvdlambda[efptBONDED]),
- nullptr, nullptr, nrnb, econqCoord);
+ nullptr, nullptr, nrnb, gmx::econqCoord);
for (n = 0; n < end; n++)
{
constrain(log, FALSE, FALSE, constr, idef, ir, cr, ms, step, 0, 1.0, md,
x_old, xnew, acc_dir, bMolPBC, box,
lambda[efptBONDED], &(dvdlambda[efptBONDED]),
- nullptr, nullptr, nrnb, econqDeriv_FlexCon);
+ nullptr, nullptr, nrnb, gmx::econqDeriv_FlexCon);
}
void relax_shell_flexcon(FILE *fplog, const t_commrec *cr,
gmx_int64_t mdstep, t_inputrec *inputrec,
gmx_bool bDoNS, int force_flags,
gmx_localtop_t *top,
- gmx_constr_t constr,
+ gmx::Constraints *constr,
gmx_enerdata_t *enerd, t_fcdata *fcd,
t_state *state, PaddedRVecVector *f,
tensor force_vir,
#include "gromacs/mdlib/vsite.h"
#include "gromacs/timing/wallcycle.h"
-struct gmx_constr;
struct gmx_enerdata_t;
struct gmx_groups_t;
struct gmx_multisim_t;
struct t_inputrec;
class t_state;
+namespace gmx
+{
+class Constraints;
+}
+
/* Initialization function, also predicts the initial shell postions.
*/
gmx_shellfc_t *init_shell_flexcon(FILE *fplog,
gmx_int64_t mdstep, t_inputrec *inputrec,
gmx_bool bDoNS, int force_flags,
gmx_localtop_t *top,
- gmx_constr *constr,
+ gmx::Constraints *constr,
gmx_enerdata_t *enerd, t_fcdata *fcd,
t_state *state, PaddedRVecVector *f,
tensor force_vir,
}
-void do_constrain_first(FILE *fplog, gmx_constr_t constr,
+void do_constrain_first(FILE *fplog, Constraints *constr,
t_inputrec *ir, t_mdatoms *md,
t_state *state, const t_commrec *cr,
const gmx_multisim_t *ms,
#include "gromacs/timing/walltime_accounting.h"
#include "gromacs/utility/arrayref.h"
-struct gmx_constr;
struct gmx_localtop_t;
struct gmx_multisim_t;
struct gmx_output_env_t;
namespace gmx
{
+class Constraints;
class IMDOutputProvider;
class MDLogger;
}
tensor fvir, tensor svir, rvec mu_tot,
t_inputrec *inputrec,
gmx_ekindata_t *ekind,
- gmx_constr *constr, t_vcm *vcm,
+ gmx::Constraints *constr, t_vcm *vcm,
int nsig, real *sig,
int *totalNumberOfBondedInteractions,
gmx_bool bSumEkinhOld, int flags);
void initialize_lambdas(FILE *fplog, t_inputrec *ir, int *fep_state, gmx::ArrayRef<real> lambda, double *lam0);
-void do_constrain_first(FILE *log, gmx_constr *constr,
+void do_constrain_first(FILE *log, gmx::Constraints *constr,
t_inputrec *inputrec, t_mdatoms *md,
t_state *state, const t_commrec *cr,
const gmx_multisim_t *ms,
const t_commrec *cr, gmx_enerdata_t *enerd,
tensor fvir, tensor svir, rvec mu_tot,
t_inputrec *inputrec,
- gmx_ekindata_t *ekind, gmx_constr_t constr,
+ gmx_ekindata_t *ekind, gmx::Constraints *constr,
t_vcm *vcm,
int nsig, real *sig,
int *totalNumberOfBondedInteractions,
ie = add_binr(rb, nener, copyenerd);
if (constr)
{
- rmsd_data = constr_rmsd_data(constr);
+ rmsd_data = gmx::constr_rmsd_data(constr);
if (rmsd_data)
{
irmsd = add_binr(rb, 2, rmsd_data);
mdatoms.homenr = numSettles * atomsPerSettle;
// Finally make the settle data structures
- gmx_settledata_t settled = settle_init(&mtop);
+ settledata *settled = settle_init(&mtop);
settle_set_constraints(settled, &mtop.moltype[0].ilist[F_SETTLE], &mdatoms);
// Copy the original positions from the array of doubles to a vector of reals
#include "testutils/refdata.h"
#include "testutils/testasserts.h"
+namespace gmx
+{
namespace
{
{
// We need to allow for the requested tolerance plus rounding
// errors due to the absolute size of the coordinate values
- gmx::test::FloatingPointTolerance constraintTolerance =
- gmx::test::absoluteTolerance(std::sqrt(constrainedDistancesSquared[i])*ShakeTest::tolerance_ + coordMax*GMX_REAL_EPS);
+ test::FloatingPointTolerance constraintTolerance =
+ test::absoluteTolerance(std::sqrt(constrainedDistancesSquared[i])*ShakeTest::tolerance_ + coordMax*GMX_REAL_EPS);
// Assert that the constrained distances are within the required tolerance
EXPECT_FLOAT_EQ_TOL(std::sqrt(constrainedDistancesSquared[i]),
std::sqrt(finalDistancesSquared[i]),
}
} // namespace
+} // namespace
t_nrnb *nrnb,
gmx_wallcycle_t wcycle,
gmx_update_t *upd,
- gmx_constr_t constr,
+ gmx::Constraints *constr,
gmx_bool bFirstHalf,
gmx_bool bCalcVir)
{
gmx_update_t *upd,
int UpdatePart,
const t_commrec *cr, /* these shouldn't be here -- need to think about it */
- gmx_constr_t constr)
+ gmx::Constraints *constr)
{
gmx_bool bDoConstr = (nullptr != constr);
}
extern gmx_bool update_randomize_velocities(t_inputrec *ir, gmx_int64_t step, const t_commrec *cr,
- t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx_constr_t constr)
+ t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx::Constraints *constr)
{
real rate = (ir->delta_t)/ir->opts.tau_t[0];
#include "gromacs/utility/real.h"
class ekinstate_t;
-struct gmx_constr;
struct gmx_ekindata_t;
struct gmx_enerdata_t;
struct gmx_multisim_t;
/* Abstract type for update */
struct gmx_update_t;
+namespace gmx
+{
+class Constraints;
+}
+
/* Initialize the stochastic dynamics struct */
gmx_update_t *init_update(const t_inputrec *ir);
gmx_update_t *upd,
int bUpdatePart,
const t_commrec *cr, /* these shouldn't be here -- need to think about it */
- gmx_constr *constr);
+ gmx::Constraints *constr);
/* Return TRUE if OK, FALSE in case of Shake Error */
-extern gmx_bool update_randomize_velocities(t_inputrec *ir, gmx_int64_t step, const t_commrec *cr, t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx_constr *constr);
+extern gmx_bool update_randomize_velocities(t_inputrec *ir, gmx_int64_t step, const t_commrec *cr, t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx::Constraints *constr);
void update_constraints(gmx_int64_t step,
real *dvdlambda, /* FEP stuff */
t_nrnb *nrnb,
gmx_wallcycle_t wcycle,
gmx_update_t *upd,
- gmx_constr *constr,
+ gmx::Constraints *constr,
gmx_bool bFirstHalf,
gmx_bool bCalcVir);
#include "gromacs/utility/real.h"
class energyhistory_t;
-struct gmx_constr;
struct gmx_mtop_t;
struct gmx_membed_t;
struct gmx_multisim_t;
namespace gmx
{
+class Constraints;
class IMDOutputProvider;
class MDLogger;
class MDAtoms;
//! Handles virtual sites.
gmx_vsite_t *vsite;
//! Handles constraints.
- gmx_constr *constr;
+ Constraints *constr;
//! Handles writing output files.
IMDOutputProvider *outputProvider;
//! Contains user input mdp options.
t_nrnb *nrnb, rvec mu_tot,
t_forcerec *fr, gmx_enerdata_t **enerd,
t_graph **graph, gmx::MDAtoms *mdAtoms, gmx_global_stat_t *gstat,
- gmx_vsite_t *vsite, gmx_constr_t constr, gmx_shellfc_t **shellfc,
+ gmx_vsite_t *vsite, gmx::Constraints *constr, gmx_shellfc_t **shellfc,
int nfile, const t_filenm fnm[],
gmx_mdoutf_t *outf, t_mdebin **mdebin,
gmx_wallcycle_t wcycle)
*shellfc = init_shell_flexcon(stdout,
top_global,
- n_flexible_constraints(constr),
+ gmx::n_flexible_constraints(constr),
ir->nstcalcenergy,
DOMAINDECOMP(cr));
}
nullptr,
fr->bMolPBC, ems->s.box,
ems->s.lambda[efptFEP], &dvdl_constr,
- nullptr, nullptr, nrnb, econqCoord);
+ nullptr, nullptr, nrnb, gmx::econqCoord);
}
}
gmx_bool bMolPBC,
em_state_t *ems1, real a, const PaddedRVecVector *force,
em_state_t *ems2,
- gmx_constr_t constr, gmx_localtop_t *top,
+ gmx::Constraints *constr, gmx_localtop_t *top,
t_nrnb *nrnb, gmx_wallcycle_t wcycle,
gmx_int64_t count)
as_rvec_array(s1->x.data()), as_rvec_array(s2->x.data()),
nullptr, bMolPBC, s2->box,
s2->lambda[efptBONDED], &dvdl_constr,
- nullptr, nullptr, nrnb, econqCoord);
+ nullptr, nullptr, nrnb, gmx::econqCoord);
wallcycle_stop(wcycle, ewcCONSTR);
// We should move this check to the different minimizers
gmx_mtop_t *top_global, t_inputrec *ir,
em_state_t *ems, gmx_localtop_t *top,
gmx::MDAtoms *mdAtoms, t_forcerec *fr,
- gmx_vsite_t *vsite, gmx_constr_t constr,
+ gmx_vsite_t *vsite, gmx::Constraints *constr,
t_nrnb *nrnb, gmx_wallcycle_t wcycle)
{
/* Repartition the domain decomposition */
//! Handles virtual sites.
gmx_vsite_t *vsite;
//! Handles constraints.
- gmx_constr_t constr;
+ gmx::Constraints *constr;
//! Handles strange things.
t_fcdata *fcd;
//! Molecular graph for SHAKE.
as_rvec_array(ems->s.x.data()), f_rvec, f_rvec,
fr->bMolPBC, ems->s.box,
ems->s.lambda[efptBONDED], &dvdl_constr,
- nullptr, &shake_vir, nrnb, econqForceDispl);
+ nullptr, &shake_vir, nrnb, gmx::econqForceDispl);
enerd->term[F_DVDL_CONSTR] += dvdl_constr;
m_add(force_vir, shake_vir, vir);
wallcycle_stop(wcycle, ewcCONSTR);
gmx_ddbox_t ddbox = {0};
int npme_major, npme_minor;
t_nrnb *nrnb;
- t_forcerec *fr = nullptr;
- t_fcdata *fcd = nullptr;
- real ewaldcoeff_q = 0;
- real ewaldcoeff_lj = 0;
- gmx_vsite_t *vsite = nullptr;
- gmx_constr_t constr;
+ t_forcerec *fr = nullptr;
+ t_fcdata *fcd = nullptr;
+ real ewaldcoeff_q = 0;
+ real ewaldcoeff_lj = 0;
+ gmx_vsite_t *vsite = nullptr;
int nChargePerturbed = -1, nTypePerturbed = 0;
gmx_wallcycle_t wcycle;
gmx_walltime_accounting_t walltime_accounting = nullptr;
/* Let init_constraints know whether we have essential dynamics constraints.
* TODO: inputrec should tell us whether we use an algorithm, not a file option or the checkpoint
*/
- bool doEdsam = (opt2fn_null("-ei", nfile, fnm) != nullptr || observablesHistory.edsamHistory);
+ bool doEdsam = (opt2fn_null("-ei", nfile, fnm) != nullptr || observablesHistory.edsamHistory);
- constr = init_constraints(fplog, &mtop, inputrec, doEdsam, cr);
+ Constraints *constr = init_constraints(fplog, &mtop, inputrec, doEdsam, cr);
if (DOMAINDECOMP(cr))
{