namespace gmx
{
-template <typename T> class ArrayRefWithPadding;
+template<typename T>
+class ArrayRefWithPadding;
//! Describes supported flavours of constrained updates.
enum class ConstraintVariable : int
{
- Positions, /* Constrain positions (mass weighted) */
- Velocities, /* Constrain velocities (mass weighted) */
- Derivative, /* Constrain a derivative (mass weighted), *
- * for instance velocity or acceleration, *
- * constraint virial can not be calculated. */
- Deriv_FlexCon, /* As Derivative, but only output flex. con. */
- Force, /* Constrain forces (non mass-weighted) */
+ Positions, /* Constrain positions (mass weighted) */
+ Velocities, /* Constrain velocities (mass weighted) */
+ Derivative, /* Constrain a derivative (mass weighted), *
+ * for instance velocity or acceleration, *
+ * constraint virial can not be calculated. */
+ Deriv_FlexCon, /* As Derivative, but only output flex. con. */
+ Force, /* Constrain forces (non mass-weighted) */
// TODO What does this do? Improve the comment.
- ForceDispl /* Like Force, but free particles will have mass
- * 1 and frozen particles mass 0 */
+ ForceDispl /* Like Force, but free particles will have mass
+ * 1 and frozen particles mass 0 */
};
/*! \libinternal
* \brief Handles constraints */
class Constraints
{
- private:
- /*! \brief Constructor
- *
- * Private to enforce use of makeConstraints() factory
- * function. */
- Constraints(const gmx_mtop_t &mtop,
- const t_inputrec &ir,
- pull_t *pull_work,
- FILE *log,
- const t_mdatoms &md,
- const t_commrec *cr,
- const gmx_multisim_t *ms,
- t_nrnb *nrnb,
- gmx_wallcycle *wcycle,
- bool pbcHandlingRequired,
- int numConstraints,
- int numSettles);
- public:
- /*! \brief This member type helps implement a factory
- * function, because its objects can access the private
- * constructor. */
- struct CreationHelper;
-
- ~Constraints();
-
- /*! \brief Returns the total number of flexible constraints in the system. */
- int numFlexibleConstraints() const;
-
- /*! \brief Returns whether the system contains perturbed constraints */
- bool havePerturbedConstraints() const;
-
- /*! \brief Set up all the local constraints for the domain.
- *
- * \todo Make this a callback that is called automatically
- * once a new domain has been made. */
- void setConstraints(const gmx_localtop_t &top,
- const t_mdatoms &md);
-
- /*! \brief Applies constraints to coordinates.
- *
- * When econq=ConstraintVariable::Positions constrains
- * coordinates xprime using th directions in x, min_proj is
- * not used.
- *
- * When econq=ConstraintVariable::Derivative, calculates the
- * components xprime in the constraint directions and
- * subtracts these components from min_proj. So when
- * min_proj=xprime, the constraint components are projected
- * out.
- *
- * When econq=ConstraintVariable::Deriv_FlexCon, the same is
- * done as with ConstraintVariable::Derivative, but only the
- * components of the flexible constraints are stored.
- *
- * delta_step is used for determining the constraint reference lengths
- * when lenA != lenB or will the pull code with a pulling rate.
- * step + delta_step is the step at which the final configuration
- * is meant to be; for update delta_step = 1.
- *
- * step_scaling can be used to update coordinates based on the time
- * step multiplied by this factor. Thus, normally 1.0 is passed. The
- * SD1 integrator uses 0.5 in one of its calls, to correct positions
- * for half a step of changed velocities.
- *
- * If v!=NULL also constrain v by adding the constraint corrections / dt.
- *
- * If vir!=NULL calculate the constraint virial.
- *
- * Return whether the application of constraints succeeded without error.
- */
- bool apply(bool bLog,
- bool bEner,
- int64_t step,
- int delta_step,
- real step_scaling,
- rvec *x,
- rvec *xprime,
- rvec *min_proj,
- const matrix box,
- real lambda,
- real *dvdlambda,
- rvec *v,
- tensor *vir,
- ConstraintVariable econq);
- //! Links the essentialdynamics and constraint code.
- void saveEdsamPointer(gmx_edsam *ed);
- //! Getter for use by domain decomposition.
- ArrayRef<const t_blocka> atom2constraints_moltype() const;
- //! Getter for use by domain decomposition.
- ArrayRef < const std::vector < int>> atom2settle_moltype() const;
-
- /*! \brief Return the data for reduction for determining
- * constraint RMS relative deviations, or an empty ArrayRef
- * when not supported for any active constraints. */
- ArrayRef<real> rmsdData() const;
- /*! \brief Return the RMSD of the constraints when available. */
- real rmsd() const;
-
- /*! \brief Get the total number of constraints.
- *
- * \returns Total number of constraints, including SETTLE and LINCS/SHAKE constraints.
- */
- int numConstraintsTotal();
-
- private:
- //! Implementation type.
- class Impl;
- //! Implementation object.
- PrivateImplPointer<Impl> impl_;
+private:
+ /*! \brief Constructor
+ *
+ * Private to enforce use of makeConstraints() factory
+ * function. */
+ Constraints(const gmx_mtop_t& mtop,
+ const t_inputrec& ir,
+ pull_t* pull_work,
+ FILE* log,
+ const t_mdatoms& md,
+ const t_commrec* cr,
+ const gmx_multisim_t* ms,
+ t_nrnb* nrnb,
+ gmx_wallcycle* wcycle,
+ bool pbcHandlingRequired,
+ int numConstraints,
+ int numSettles);
+
+public:
+ /*! \brief This member type helps implement a factory
+ * function, because its objects can access the private
+ * constructor. */
+ struct CreationHelper;
+
+ ~Constraints();
+
+ /*! \brief Returns the total number of flexible constraints in the system. */
+ int numFlexibleConstraints() const;
+
+ /*! \brief Returns whether the system contains perturbed constraints */
+ bool havePerturbedConstraints() const;
+
+ /*! \brief Set up all the local constraints for the domain.
+ *
+ * \todo Make this a callback that is called automatically
+ * once a new domain has been made. */
+ void setConstraints(const gmx_localtop_t& top, const t_mdatoms& md);
+
+ /*! \brief Applies constraints to coordinates.
+ *
+ * When econq=ConstraintVariable::Positions constrains
+ * coordinates xprime using th directions in x, min_proj is
+ * not used.
+ *
+ * When econq=ConstraintVariable::Derivative, calculates the
+ * components xprime in the constraint directions and
+ * subtracts these components from min_proj. So when
+ * min_proj=xprime, the constraint components are projected
+ * out.
+ *
+ * When econq=ConstraintVariable::Deriv_FlexCon, the same is
+ * done as with ConstraintVariable::Derivative, but only the
+ * components of the flexible constraints are stored.
+ *
+ * delta_step is used for determining the constraint reference lengths
+ * when lenA != lenB or will the pull code with a pulling rate.
+ * step + delta_step is the step at which the final configuration
+ * is meant to be; for update delta_step = 1.
+ *
+ * step_scaling can be used to update coordinates based on the time
+ * step multiplied by this factor. Thus, normally 1.0 is passed. The
+ * SD1 integrator uses 0.5 in one of its calls, to correct positions
+ * for half a step of changed velocities.
+ *
+ * If v!=NULL also constrain v by adding the constraint corrections / dt.
+ *
+ * If vir!=NULL calculate the constraint virial.
+ *
+ * Return whether the application of constraints succeeded without error.
+ */
+ bool apply(bool bLog,
+ bool bEner,
+ int64_t step,
+ int delta_step,
+ real step_scaling,
+ rvec* x,
+ rvec* xprime,
+ rvec* min_proj,
+ const matrix box,
+ real lambda,
+ real* dvdlambda,
+ rvec* v,
+ tensor* vir,
+ ConstraintVariable econq);
+ //! Links the essentialdynamics and constraint code.
+ void saveEdsamPointer(gmx_edsam* ed);
+ //! Getter for use by domain decomposition.
+ ArrayRef<const t_blocka> atom2constraints_moltype() const;
+ //! Getter for use by domain decomposition.
+ ArrayRef<const std::vector<int>> atom2settle_moltype() const;
+
+ /*! \brief Return the data for reduction for determining
+ * constraint RMS relative deviations, or an empty ArrayRef
+ * when not supported for any active constraints. */
+ ArrayRef<real> rmsdData() const;
+ /*! \brief Return the RMSD of the constraints when available. */
+ real rmsd() const;
+
+ /*! \brief Get the total number of constraints.
+ *
+ * \returns Total number of constraints, including SETTLE and LINCS/SHAKE constraints.
+ */
+ int numConstraintsTotal();
+
+private:
+ //! Implementation type.
+ class Impl;
+ //! Implementation object.
+ PrivateImplPointer<Impl> impl_;
};
/*! \brief Generate a fatal error because of too many LINCS/SETTLE warnings. */
-[[ noreturn ]] void too_many_constraint_warnings(int eConstrAlg, int warncount);
+[[noreturn]] void too_many_constraint_warnings(int eConstrAlg, int warncount);
/*! \brief Returns whether constraint with parameter \p iparamsIndex is a flexible constraint */
-static inline bool isConstraintFlexible(const t_iparams *iparams,
- int iparamsIndex)
+static inline bool isConstraintFlexible(const t_iparams* iparams, int iparamsIndex)
{
GMX_ASSERT(iparams != nullptr, "Need a valid iparams array");
- return (iparams[iparamsIndex].constr.dA == 0 &&
- iparams[iparamsIndex].constr.dB == 0);
+ return (iparams[iparamsIndex].constr.dA == 0 && iparams[iparamsIndex].constr.dB == 0);
};
/* The at2con t_blocka struct returned by the routines below
};
/*! \brief Returns the flexible constraint treatment depending on whether the integrator is dynamic */
-FlexibleConstraintTreatment
-flexibleConstraintTreatment(bool haveDynamicsIntegrator);
+FlexibleConstraintTreatment flexibleConstraintTreatment(bool haveDynamicsIntegrator);
/*! \brief Returns a block struct to go from atoms to constraints
*
* the order in F_CONSTRNC offset by the number of constraints in F_CONSTR.
*
* \param[in] moltype The molecule data
- * \param[in] iparams Interaction parameters, can be null when flexibleConstraintTreatment=Include
- * \param[in] flexibleConstraintTreatment The flexible constraint treatment, see enum above
- * \returns a block struct with all constraints for each atom
+ * \param[in] iparams Interaction parameters, can be null when
+ * flexibleConstraintTreatment=Include \param[in] flexibleConstraintTreatment The flexible
+ * constraint treatment, see enum above \returns a block struct with all constraints for each atom
*/
-t_blocka make_at2con(const gmx_moltype_t &moltype,
- gmx::ArrayRef<const t_iparams> iparams,
- FlexibleConstraintTreatment flexibleConstraintTreatment);
+t_blocka make_at2con(const gmx_moltype_t& moltype,
+ gmx::ArrayRef<const t_iparams> iparams,
+ FlexibleConstraintTreatment flexibleConstraintTreatment);
/*! \brief Returns a block struct to go from atoms to constraints
*
*
* \param[in] numAtoms The number of atoms to construct the list for
* \param[in] ilist Interaction list, size F_NRE
- * \param[in] iparams Interaction parameters, can be null when flexibleConstraintTreatment=Include
- * \param[in] flexibleConstraintTreatment The flexible constraint treatment, see enum above
- * \returns a block struct with all constraints for each atom
+ * \param[in] iparams Interaction parameters, can be null when
+ * flexibleConstraintTreatment=Include \param[in] flexibleConstraintTreatment The flexible
+ * constraint treatment, see enum above \returns a block struct with all constraints for each atom
*/
-t_blocka make_at2con(int numAtoms,
- const t_ilist *ilist,
- const t_iparams *iparams,
- FlexibleConstraintTreatment flexibleConstraintTreatment);
+t_blocka make_at2con(int numAtoms,
+ const t_ilist* ilist,
+ const t_iparams* iparams,
+ FlexibleConstraintTreatment flexibleConstraintTreatment);
/*! \brief Returns an array of atom to constraints lists for the moltypes */
-const t_blocka *atom2constraints_moltype(const Constraints *constr);
+const t_blocka* atom2constraints_moltype(const Constraints* constr);
//! Return the number of flexible constraints in the \c ilist and \c iparams.
-int countFlexibleConstraints(const t_ilist *ilist,
- const t_iparams *iparams);
+int countFlexibleConstraints(const t_ilist* ilist, const t_iparams* iparams);
/*! \brief Returns the constraint iatoms for a constraint number con
* which comes from a list where F_CONSTR and F_CONSTRNC constraints
* are concatenated. */
-inline const int *
-constr_iatomptr(gmx::ArrayRef<const int> iatom_constr,
- gmx::ArrayRef<const int> iatom_constrnc,
- int con)
+inline const int* constr_iatomptr(gmx::ArrayRef<const int> iatom_constr,
+ gmx::ArrayRef<const int> iatom_constrnc,
+ int con)
{
- if (con*3 < iatom_constr.ssize())
+ if (con * 3 < iatom_constr.ssize())
{
- return iatom_constr.data() + con*3;
+ return iatom_constr.data() + con * 3;
}
else
{
- return iatom_constrnc.data() + con*3 - iatom_constr.size();
+ return iatom_constrnc.data() + con * 3 - iatom_constr.size();
}
};
/*! \brief Returns whether there are inter charge group constraints */
-bool inter_charge_group_constraints(const gmx_mtop_t &mtop);
+bool inter_charge_group_constraints(const gmx_mtop_t& mtop);
/*! \brief Returns whether there are inter charge group settles */
-bool inter_charge_group_settles(const gmx_mtop_t &mtop);
+bool inter_charge_group_settles(const gmx_mtop_t& mtop);
/*! \brief Constrain the initial coordinates and velocities */
-void do_constrain_first(FILE *log, gmx::Constraints *constr,
- const t_inputrec *inputrec, const t_mdatoms *md,
- int natoms,
+void do_constrain_first(FILE* log,
+ gmx::Constraints* constr,
+ const t_inputrec* inputrec,
+ const t_mdatoms* md,
+ int natoms,
ArrayRefWithPadding<RVec> x,
ArrayRefWithPadding<RVec> v,
- const matrix box,
- real lambda);
+ const matrix box,
+ real lambda);
-} // namespace gmx
+} // namespace gmx
#endif