Reduced includes of common headers in headers
[gromacs.git] / src / gromacs / domdec / domdec_specatomcomm.h
blob825fdc4f9cadc070d0891be516d7a40804964dec
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2005,2006,2007,2008,2009,2010,2012,2013,2014,2015,2017,2018, 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 /*! \internal \file
37 * \brief This file declares functions for domdec to use
38 * while managing communication of atoms required for special purposes
40 * \author Berk Hess <hess@kth.se>
41 * \ingroup module_domdec
44 #ifndef GMX_DOMDEC_DOMDEC_SPECATOMCOMM_H
45 #define GMX_DOMDEC_DOMDEC_SPECATOMCOMM_H
47 #include "gromacs/math/vectypes.h"
48 #include "gromacs/utility/basedefinitions.h"
50 struct gmx_domdec_t;
51 struct gmx_hash_t;
52 struct t_commrec;
54 typedef struct {
55 int nsend;
56 int *a;
57 int a_nalloc;
58 int nrecv;
59 } gmx_specatsend_t;
61 typedef struct {
62 int *ind;
63 int nalloc;
64 int n;
65 } ind_req_t;
67 /*! \internal \brief Struct with setup and buffers for special atom communication */
68 struct gmx_domdec_specat_comm_t {
69 /* The number of indices to receive during the setup */
70 int nreq[DIM][2][2]; /**< The nr. of atoms requested, per DIM, direction and direct/indirect */
71 /* The atoms to send */
72 gmx_specatsend_t spas[DIM][2]; /**< The communication setup per DIM, direction */
73 gmx_bool *bSendAtom; /**< Work buffer that tells if spec.atoms should be sent */
74 int bSendAtom_nalloc; /**< Allocation size of \p bSendAtom */
75 /* Send buffers */
76 int *ibuf; /**< Integer send buffer */
77 int ibuf_nalloc; /**< Allocation size of \p ibuf */
78 rvec *vbuf; /**< rvec send buffer */
79 int vbuf_nalloc; /**< Allocation size of \p vbuf */
80 rvec *vbuf2; /**< rvec send buffer */
81 int vbuf2_nalloc; /**< Allocation size of \p vbuf2 */
82 /* The range in the local buffer(s) for received atoms */
83 int at_start; /**< Start index of received atoms */
84 int at_end; /**< End index of received atoms */
86 /* The atom indices we need from the surrounding cells.
87 * We can gather the indices over nthread threads.
89 int nthread; /**< Number of threads used for spec.atom communication */
90 ind_req_t *ireq; /**< Index request buffer per thread, allocation size \p nthread */
93 /*! \brief Communicates the force for special atoms, the shift forces are reduced with \p fshift != NULL */
94 void dd_move_f_specat(gmx_domdec_t *dd, gmx_domdec_specat_comm_t *spac,
95 rvec *f, rvec *fshift);
97 /*! \brief Communicates the coordinates for special atoms
99 * \param[in] dd Domain decomposition struct
100 * \param[in] spac Special atom communication struct
101 * \param[in] box Box, used for pbc
102 * \param[in,out] x0 Vector to communicate
103 * \param[in,out] x1 Vector to communicate, when != NULL
104 * \param[in] bX1IsCoord Tells is \p x1 is a coordinate vector (needs pbc)
106 void dd_move_x_specat(gmx_domdec_t *dd, gmx_domdec_specat_comm_t *spac,
107 const matrix box,
108 rvec *x0,
109 rvec *x1, gmx_bool bX1IsCoord);
111 /*! \brief Sets up the communication for special atoms
113 * \param[in] dd Domain decomposition struct
114 * \param[in] ireq List of requested atom indices
115 * \param[in,out] spac Special atom communication struct
116 * \param[out] ga2la_specat Global to local special atom index
117 * \param[in] at_start Index in local state where to start storing communicated atoms
118 * \param[in] vbuf_fac Buffer factor, 1 or 2 for communicating 1 or 2 vectors
119 * \param[in] specat_type Name of the special atom, used for error message
120 * \param[in] add_err Text to add at the end of error message when atoms can't be found
122 int setup_specat_communication(gmx_domdec_t *dd,
123 ind_req_t *ireq,
124 gmx_domdec_specat_comm_t *spac,
125 gmx_hash_t *ga2la_specat,
126 int at_start,
127 int vbuf_fac,
128 const char *specat_type,
129 const char *add_err);
131 /*! \brief Initialize a special communication struct */
132 gmx_domdec_specat_comm_t *specat_comm_init(int nthread);
134 #endif