-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdomain_decomposition.h
215 lines (181 loc) · 8.09 KB
/
domain_decomposition.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*
Copyright (C) 2010 The ESPResSo project
Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010 Max-Planck-Institute for Polymer Research, Theory Group, PO Box 3148, 55021 Mainz, Germany
This file is part of ESPResSo.
ESPResSo is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ESPResSo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DOMAIN_DECOMP_H
#define DOMAIN_DECOMP_H
/** \file domain_decomposition.h
*
* This file contains everything related to the cell system: domain decomposition.
*
* The simulation box is split into spatial domains for each node
* according to a cartesian node grid (\ref node_grid).
*
* The domain of a node is split into a 3D cell grid with dimension
* \ref DomainDecomposition::cell_grid. Together with one ghost cell
* layer on each side the overall dimension of the ghost cell grid is
* \ref DomainDecomposition::ghost_cell_grid. The domain
* decomposition enables one the use of the linked cell algorithm
* which is in turn used for setting up the verlet list for the
* system. You can see a 2D graphical representation of the linked
* cell grid below.
*
* \image html linked_cells.gif "Linked cells structure"
* \image latex linked_cells.eps "Linked cells structure"
*
* 2D representation of a linked cell grid: cell_grid =
* {4,4}, ghost_cell_grid = {6,6}
*
* Each cell has 3^D neighbor cells (For cell 14 they are
* marked). Since we deal with pair forces, it is sufficient to
* calculate only half of the interactions (Newtons law: actio =
* reactio). We have chosen the upper half e.g. all neighbor cells with
* a higher linear index (For cell 14 they are marked in light
* blue). Caution: This implementation needs double sided ghost
* communication! For single sided ghost communication one would need
* some ghost-ghost cell interaction as well, which we do not need!
*
* For more information on cells,
* see \ref cells.h
*/
#include "utils.h"
#include "cells.h"
#include "integrate.h"
#include "communication.h"
#include "verlet.h"
#include "thermostat.h"
/** Structure containing information about non bonded interactions
with particles in a neighbor cell. */
typedef struct {
/** Just for transparency the index of the neighbor cell. */
int cell_ind;
/** Pointer to particle list of neighbor cell. */
ParticleList *pList;
/** Verlet list for non bonded interactions of a cell with a neighbor cell. */
PairList vList;
} IA_Neighbor;
typedef struct {
/** number of interacting neighbor cells .
A word about the interacting neighbor cells:
In a 3D lattice each cell has 27 neighbors (including
itself!). Since we deal with pair forces, it is sufficient to
calculate only half of the interactions (Newtons law: actio =
reactio). For each cell 13+1=14 neighbors. This has only to be
done for the inner cells.
Caution: This implementation needs double sided ghost
communication! For single sided ghost communication one would
need some ghost-ghost cell interaction as well, which we do not
need!
It follows: inner cells: n_neighbors = 14
ghost cells: n_neighbors = 0
*/
int n_neighbors;
/** Interacting neighbor cell list */
IA_Neighbor *nList;
} IA_Neighbor_List;
/** Structure containing the information about the cell grid used for domain decomposition. */
typedef struct {
/** flag for using Verlet List */
int use_vList;
/** linked cell grid in nodes spatial domain. */
int cell_grid[3];
/** linked cell grid with ghost frame. */
int ghost_cell_grid[3];
/** cell size.
Def: \verbatim cell_grid[i] = (int)(local_box_l[i]/max_range); \endverbatim */
double cell_size[3];
/** inverse cell size = \see DomainDecomposition::cell_size ^ -1. */
double inv_cell_size[3];
/** Array containing information about the interactions between the cells. */
IA_Neighbor_List *cell_inter;
} DomainDecomposition;
/************************************************************/
/** \name Exported Variables */
/************************************************************/
/*@{*/
/** Information about the domain decomposition. */
extern DomainDecomposition dd;
/** Maximal skin size. This is a global variable wwhich can be read
out by the user via \ref global::setmd in order to optimize the cell
grid */
extern double max_skin;
/** Maximal number of cells per node. In order to avoid memory
* problems due to the cell grid one has to specify the maximal
* number of \ref cells::cells . The corresponding callback function
* is \ref max_num_cells_callback. If the number of cells \ref
* n_cells, is larger than max_num_cells the cell grid is
* reduced. max_num_cells has to be larger than 27, e.g one inner
* cell. max_num_cells is initialized with the default value
* specified in \ref config.h: \ref CELLS_MAX_NUM_CELLS.
*/
extern int max_num_cells;
/** Minimal number of cells per node. This is mainly to avoid excessively large
numbers of particles per cell, which will result in really large Verlet
lists and eventually crash Espresso.
*/
extern int min_num_cells;
/*@}*/
/************************************************************/
/** \name Exported Functions */
/************************************************************/
/*@{*/
/** Re-derives the topology dimensions after the NpT-integrator
changed the box-length. Note that no changes occur to the
cell structure itself, use \ref dd_create_cell_grid for that.
@param scal1 isotropic scaling factor by which each \ref box_l[i] changed. */
void dd_NpT_update_cell_grid(double scal1);
/** Initialize the topology. The argument is a list of cell pointers,
containing particles that have to be sorted into new cells. The
particles might not belong to this node. This procedure is used
when particle data or cell structure has changed and the cell
structure has to be reinitialized. This also includes setting up
the cell_structure array.
@param cl List of cell pointers with particles to be stored in the
new cell system.
*/
void dd_topology_init(CellPList *cl);
/** Called when the current cell structure is invalidated because for
example the box length has changed. This procedure may NOT destroy
the old inner and ghost cells, but it should free all other
organizational data. Note that parameters like the box length or
the node_grid may already have changed. Therefore organizational
data has to be stored independently from variables that may be
changed from outside. */
void dd_topology_release();
/** Just resort the particles. Used during integration. The particles
are stored in the cell structure.
@param global_flag Use DD_GLOBAL_EXCHANGE for global exchange and
DD_NEIGHBOR_EXCHANGE for neighbor exchange (recommended for use within
Molecular dynamics, or any other integration scheme using only local
particle moves)
*/
void dd_exchange_and_sort_particles(int global_flag);
/** implements \ref CellStructure::position_to_cell. */
Cell *dd_position_to_cell(double pos[3]);
/** Callback for setmd max_num_cells (maxnumcells >= 27).
see also \ref max_num_cells */
int max_num_cells_callback(Tcl_Interp *interp, void *_data);
/** Callback for setmd min_num_cells.
see also \ref min_num_cells */
int min_num_cells_callback(Tcl_Interp *interp, void *_data);
/** calculate physical (processor) minimal number of cells */
int calc_processor_min_num_cells();
/** Calculate nonbonded and bonded forces with link-cell
method (without Verlet lists)
*/
void calc_link_cell();
/** Nonbonded and bonded energy calculation using link-cell method */
void calculate_link_cell_energies();
/*@}*/
#endif