Clean up index handing in make_bondeds_zone
[alexxy/gromacs.git] / src / gromacs / domdec / partition.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2018,2019,2020,2021, 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.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35 /*! \libinternal \file
36  *
37  * \brief This file declares functions for mdrun to call to make a new
38  * domain decomposition, and check it.
39  *
40  * \author Berk Hess <hess@kth.se>
41  * \inlibraryapi
42  * \ingroup module_domdec
43  */
44
45 #ifndef GMX_DOMDEC_PARTITION_H
46 #define GMX_DOMDEC_PARTITION_H
47
48 #include <cstdio>
49
50 #include "gromacs/math/vectypes.h"
51 #include "gromacs/utility/real.h"
52
53 struct gmx_ddbox_t;
54 struct gmx_domdec_t;
55 struct gmx_localtop_t;
56 struct gmx_mtop_t;
57 struct gmx_wallcycle;
58 struct pull_t;
59 struct t_commrec;
60 struct t_forcerec;
61 struct t_inputrec;
62 struct t_nrnb;
63 class t_state;
64
65 namespace gmx
66 {
67 template<typename>
68 class ArrayRef;
69 class Constraints;
70 class ForceBuffers;
71 class ImdSession;
72 class MDAtoms;
73 class MDLogger;
74 class VirtualSitesHandler;
75
76 //! Check whether the DD grid has moved too far for correctness.
77 bool check_grid_jump(int64_t step, const gmx_domdec_t* dd, real cutoff, const gmx_ddbox_t* ddbox, bool bFatal);
78
79 /*! \brief Print statistics for domain decomposition communication */
80 void print_dd_statistics(const t_commrec* cr, const t_inputrec& inputrec, FILE* fplog);
81
82 /*! \brief Partition the system over the nodes.
83  *
84  * step is only used for printing error messages.
85  * If bMasterState==TRUE then state_global from the master node is used,
86  * else state_local is redistributed between the nodes.
87  * When f!=NULL, *f will be reallocated to the size of state_local.
88  *
89  * \param[in] fplog         Pointer to the log file
90  * \param[in] mdlog         MD file logger
91  * \param[in] step          Current step
92  * \param[in] cr            Communication record
93  * \param[in] bMasterState  Is it a master state
94  * \param[in] nstglobalcomm Will globals be computed on this step
95  * \param[in] state_global  Global state
96  * \param[in] top_global    Global topology
97  * \param[in] inputrec      Input record
98  * \param[in] imdSession    IMD handle
99  * \param[in] pull_work     Pulling data
100  * \param[in] state_local   Local state
101  * \param[in] f             Force buffer
102  * \param[in] mdAtoms       MD atoms
103  * \param[in] top_local     Local topology
104  * \param[in] fr            Force record
105  * \param[in] vsite         Virtual sites handler
106  * \param[in] constr        Constraints
107  * \param[in] nrnb          Cycle counters
108  * \param[in] wcycle        Timers
109  * \param[in] bVerbose      Be verbose
110  */
111 void dd_partition_system(FILE*                     fplog,
112                          const gmx::MDLogger&      mdlog,
113                          int64_t                   step,
114                          const t_commrec*          cr,
115                          bool                      bMasterState,
116                          int                       nstglobalcomm,
117                          t_state*                  state_global,
118                          const gmx_mtop_t&         top_global,
119                          const t_inputrec&         inputrec,
120                          gmx::ImdSession*          imdSession,
121                          pull_t*                   pull_work,
122                          t_state*                  state_local,
123                          gmx::ForceBuffers*        f,
124                          gmx::MDAtoms*             mdAtoms,
125                          gmx_localtop_t*           top_local,
126                          t_forcerec*               fr,
127                          gmx::VirtualSitesHandler* vsite,
128                          gmx::Constraints*         constr,
129                          t_nrnb*                   nrnb,
130                          gmx_wallcycle*            wcycle,
131                          bool                      bVerbose);
132
133 } // namespace gmx
134 #endif