2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013-2020, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
37 #ifndef GMX_MDLIB_FORCEREC_H
38 #define GMX_MDLIB_FORCEREC_H
40 #include "gromacs/mdlib/force_flags.h"
41 #include "gromacs/mdlib/tgroup.h"
42 #include "gromacs/mdlib/vsite.h"
43 #include "gromacs/mdtypes/forcerec.h"
44 #include "gromacs/timing/wallcycle.h"
45 #include "gromacs/utility/arrayref.h"
47 struct gmx_device_info_t;
53 struct gmx_gpu_info_t;
59 class PhysicalNodeCommunicator;
62 //! Destroy a forcerec.
63 void done_forcerec(t_forcerec* fr, int numMolBlocks);
65 /*! \brief Print the contents of the forcerec to a file
67 * \param[in] fplog The log file to print to
68 * \param[in] fr The forcerec structure
70 void pr_forcerec(FILE* fplog, t_forcerec* fr);
72 /*! \brief Set the number of charge groups and atoms.
74 * The force calculation needs information on which atoms it
76 * \param[inout] fr The forcerec
77 * \param[in] natoms_force Number of atoms to compute force on
78 * \param[in] natoms_force_constr Number of atoms involved in constraints
79 * \param[in] natoms_f_novirsum Number of atoms for which
80 * force is to be compute but no virial
82 void forcerec_set_ranges(t_forcerec* fr, int natoms_force, int natoms_force_constr, int natoms_f_novirsum);
84 /*! \brief Initiate table constants
86 * Initializes the tables in the interaction constant data structure.
87 * \param[in] fp File for debugging output
88 * \param[in] ic Structure holding the table constant
90 void init_interaction_const_tables(FILE* fp, interaction_const_t* ic);
92 /*! \brief Initialize forcerec structure.
94 * \param[in] fplog File for printing
95 * \param[in] mdlog File for printing
96 * \param[out] fr The forcerec
97 * \param[in] fcd Force constant data
98 * \param[in] ir Inputrec structure
99 * \param[in] mtop Molecular topology
100 * \param[in] cr Communication structures
101 * \param[in] box Simulation box
102 * \param[in] tabfn Table potential file for non-bonded interactions
103 * \param[in] tabpfn Table potential file for pair interactions
104 * \param[in] tabbfnm Table potential files for bonded interactions
105 * \param[in] hardwareInfo Information about hardware
106 * \param[in] deviceInfo Info about GPU device to use for short-ranged work
107 * \param[in] useGpuForBonded Whether bonded interactions will run on a GPU
108 * \param[in] pmeOnlyRankUsesGpu Whether there is a PME task on a GPU on a PME-only rank
109 * \param[in] print_force Print forces for atoms with force >= print_force
110 * \param[out] wcycle Pointer to cycle counter object
112 void init_forcerec(FILE* fplog,
113 const gmx::MDLogger& mdlog,
116 const t_inputrec* ir,
117 const gmx_mtop_t* mtop,
122 gmx::ArrayRef<const std::string> tabbfnm,
123 const gmx_hw_info_t& hardwareInfo,
124 const gmx_device_info_t* deviceInfo,
125 bool useGpuForBonded,
126 bool pmeOnlyRankUsesGpu,
128 gmx_wallcycle* wcycle);
130 /*! \brief Check whether molecules are ever distributed over PBC boundaries
132 * Note: This covers only the non-DD case. For DD runs, domdec.h offers an
133 * equivalent dd_bonded_molpbc(...) function.
135 * \param[in] ir Inputrec structure
136 * \param[in] mtop Molecular topology
137 * \param[in] mdlog File for printing
139 bool areMoleculesDistributedOverPbc(const t_inputrec& ir, const gmx_mtop_t& mtop, const gmx::MDLogger& mdlog);
141 /*! \brief Divide exclusions over threads
143 * Set the exclusion load for the local exclusions and possibly threads
144 * \param[out] fr The force record
145 * \param[in] top The topology
147 void forcerec_set_excl_load(t_forcerec* fr, const gmx_localtop_t* top);
149 void free_gpu_resources(t_forcerec* fr,
150 const gmx::PhysicalNodeCommunicator& physicalNodeCommunicator,
151 const gmx_gpu_info_t& gpu_info);