2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 /*! \defgroup module_listed_forces Interactions between lists of particles
36 * \ingroup group_mdrun
38 * \brief Handles computing energies and forces for listed
41 * Located here is the code for
42 * - computing energies and forces for interactions between a small
43 number of particles, e.g bonds, position restraints and listed
44 non-bonded interactions (e.g. 1-4).
45 * - high-level functions used by mdrun for computing a set of such
47 * - managing thread-wise decomposition, thread-local buffer output,
48 and reduction of output data across threads.
50 * \author Mark Abraham <mark.j.abraham@gmail.com>
53 /*! \libinternal \file
55 * \brief This file contains declarations of high-level functions used
56 * by mdrun to compute energies and forces for listed interactions.
58 * Clients of libgromacs that want to evaluate listed interactions
59 * should call functions declared here.
61 * \author Mark Abraham <mark.j.abraham@gmail.com>
64 * \ingroup module_listed_forces
66 #ifndef GMX_LISTED_FORCES_LISTED_FORCES_H
67 #define GMX_LISTED_FORCES_LISTED_FORCES_H
69 #include "gromacs/math/vectypes.h"
70 #include "gromacs/topology/ifunc.h"
71 #include "gromacs/utility/basedefinitions.h"
73 struct gmx_enerdata_t;
74 struct gmx_grppairener_t;
75 struct gmx_multisim_t;
93 //! Type of CPU function to compute a bonded interaction.
94 using BondedFunction = real (*)(int nbonds,
95 const t_iatom iatoms[],
96 const t_iparams iparams[],
108 //! Getter for finding a callable CPU function to compute an \c ftype interaction.
109 BondedFunction bondedFunction(int ftype);
111 /*! \brief Calculates all listed force interactions.
113 * Note that pbc_full is used only for position restraints, and is
114 * not initialized if there are none. */
115 void calc_listed(const t_commrec* cr,
116 const gmx_multisim_t* ms,
117 struct gmx_wallcycle* wcycle,
121 gmx::ForceOutputs* forceOutputs,
122 const t_forcerec* fr,
123 const struct t_pbc* pbc,
124 const struct t_pbc* pbc_full,
125 const struct t_graph* g,
126 gmx_enerdata_t* enerd,
130 struct t_fcdata* fcd,
132 const gmx::StepWorkload& stepWork);
134 /*! \brief As calc_listed(), but only determines the potential energy
135 * for the perturbed interactions.
137 * The shift forces in fr are not affected. */
138 void calc_listed_lambda(const t_idef* idef,
140 const t_forcerec* fr,
141 const struct t_pbc* pbc,
142 const struct t_graph* g,
143 gmx_grppairener_t* grpp,
148 struct t_fcdata* fcd,
149 int* global_atom_index);
151 /*! \brief Do all aspects of energy and force calculations for mdrun
152 * on the set of listed interactions */
153 void do_force_listed(struct gmx_wallcycle* wcycle,
155 const t_lambda* fepvals,
157 const gmx_multisim_t* ms,
161 gmx::ForceOutputs* forceOutputs,
162 const t_forcerec* fr,
163 const struct t_pbc* pbc,
164 const struct t_graph* graph,
165 gmx_enerdata_t* enerd,
169 struct t_fcdata* fcd,
170 int* global_atom_index,
171 const gmx::StepWorkload& stepWork);
173 /*! \brief Returns true if there are position, distance or orientation restraints. */
174 bool haveRestraints(const t_idef& idef, const t_fcdata& fcd);
176 /*! \brief Returns true if there are CPU (i.e. not GPU-offloaded) bonded interactions to compute. */
177 bool haveCpuBondeds(const t_forcerec& fr);
179 /*! \brief Returns true if there are listed interactions to compute.
181 * NOTE: the current implementation returns true if there are position restraints
182 * or any bonded interactions computed on the CPU.
184 bool haveCpuListedForces(const t_forcerec& fr, const t_idef& idef, const t_fcdata& fcd);