aboutsummaryrefslogtreecommitdiff
path: root/Carpet/doc/domain-decomposition.tex
blob: 2ce6758b3c5113b5fb4f8d647edf40ed608410c9 (plain)
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
\documentclass[oneside]{amsart}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{color}
\usepackage{graphicx}
\usepackage[latin9]{inputenc}
% \usepackage{mathpazo}
\usepackage[hyphens]{url}

% Put this package last
\usepackage[bookmarks, bookmarksopen, bookmarksnumbered]{hyperref}
% Put this package after hyperref
\usepackage[all]{hypcap}
% Don't use tt font for urls
\urlstyle{rm}



% Make a comment stand out visually
\newcommand{\todo}[1]{{\color{blue}$\blacksquare$~\textsf{[TODO: #1]}}}

% Name of a code
\newcommand{\code}[1]{\texttt{#1}}



\hyphenation{Cac-tus-Ein-stein Schwarz-schild South-amp-ton}

\sloppypar



\begin{document}

\title[Domain Decomposition in Carpet]{Domain Decomposition in
  Carpet:\\Regridding and Determination of the Communication Schedule}

\author{Erik Schnetter$^{(1,2)}$}

% \email
\thanks{\emph{Email}:~\url{mailto:schnetter@cct.lsu.edu}}

% \urladdr
\thanks{\emph{Web}:~\url{http://www.cct.lsu.edu/}}

% \address
\thanks{{}$^{(1)}$ Center for Computation \& Technology,
  Louisiana State University, Baton Rouge, LA, USA}

\thanks{{}$^{(2)}$ Department of Physics and Astronomy,
  Louisiana State University, Baton Rouge LA, USA}



\date{March 9, 2008}



\begin{abstract}
  This text describes the algorithms that Carpet
  \cite{Schnetter-etal-03b, carpetweb} uses for regridding, domain
  decomposition, and setting up the communication schedule.  It is
  intended for readers interested in more details than a casual user
  would need.  This text explains the concepts that Carpet uses
  internally to describe the grid hierarchy and to ensure its
  consistency.
\end{abstract}

\maketitle



\section{Introduction}

Setting up a grid hierarchy (``regridding'') is in Carpet handled by
three different entities: \emph{Carpet} itself decides the extent of
the domain, the type of outer boundary conditions, and distributes the
domain onto processors; a \emph{regridding thorn} is responsible for
deciding the shape of the grid hierarchy, and \emph{CarpetLib} handles
the details and actually manages the data.  (Technically speaking, it
is the regridding thorn which has to do the domain decomposition;
however, it can simply call a convenient helper routine in Carpet for
this task.)

This separation leaves the decision on the shape of the grid hiearchy
to a thorn which can be replaced or augmented as necessary.  All
handling of data happens in CarpetLib, which is thus the only entity
which needs to be optimised for speed.  Finally, Carpet retains the
overview of the regridding process.

In the following we assume that there is a single patch (block) which
contains a mesh refinement hierarchy.  If there are multiple patches,
then each patch is conceptually handled independently.  Certain
conditions may have to be satisfied if a refined mesh touches an
inter-patch boundary, but these are not discussed here.

We assume that the domain has $D$ spatial dimensions, usually $D=3$.



\section{Domain description}

We assume that boundary location and boundary discretisation are set
up via \emph{CoordBase}.  This is necessary since other methods do not
allow specifying sufficient details to handle e.g.\ refined regions
intersecting mesh refinement boundaries.  Below we give an overview
of the information that needs to be specified to describe a
boundary.  See the CoordBase thorn guide for details.

The extent of the overall simulation domain is described in terms of
real-valued coordinates.  The domain is cuboidal, i.e., it can be
described in terms of two vectors $x^i_\mathrm{min}$ and
$x^i_\mathrm{max}$.

The type of boundary conditions for each of the $2D$ faces is
described by three quantities:
\begin{itemize}
\item the total number of boundary points,
\item how many of these points are outside of the domain boundary,
\item whether the boundary is staggered with respect to the domain
  boundary, or whether one of the boundary points is located on the
  domain boundary.
\end{itemize}
\todo{Show the relevant figures from the CoordBase thorn guide.}

The extent of the domain $L^i := x^i_\mathrm{max} - x^i_\mathrm{min}$
must be commensurate with the coarse grid spacing $h^i$.  This means
that $L^i$ must be a multiple of $h^i$, modulo the fact that the
boundary may be staggered.

An \emph{outer boundary condition} can either be a \emph{physical}
boundary condition, such as e.g.\ a Dirichlet condition, or a
\emph{symmetry} boundary condition, such as e.g.\ a reflection
symmetry.  This distinction is irrelevant for Carpet.  Both kinds of
outer boundary conditions are applied by thorns which are scheduled in
the appropriate way.

The main distinction between an \emph{outer boundary point} and an
\emph{interior point} from Carpet's point of view is that an outer
boundary point is not evolved in time.  Instead, the value of boundary
points must be completely determined by the value of interior points.
(This is clearly the case for Dirichlet or symmetry boundary
conditions.)  The reason for this distinction is that Carpet cannot
fill outer boundary points on refined grids via interpolation, because
this requires off-centred interpolation stencils which are not
implemented at the moment.  Therefore, Carpet does not fill any outer
boundary points through interpolation.

\todo{We should introduce mesh refinement and parallelisation before
  this paragraph.}
%
If the refined region abuts the outer boundary, then outer boundary
points can also be refinement boundary points.  Carpet does not fill
these outer boundary points through synchronisation (prolongation)
either.  This requires that the outer boundary condition is applied
after every synchronisation.  This is usally automatically the case
when using the Cactus boundary condition selection mechanism, i.e.,
when the group \texttt{ApplyBCs} is scheduled.  Synchronising outer
boundary points would be possible, but this is not done so that
refinement boundaries and inter-processor boundaries are treated in
the same way.



\section{Regridding}

A regridding thorn, such as e.g.\ \texttt{CarpetRegrid} or
\texttt{CarpetRegrid2}, sets up the \emph{grid hierarchy}.  The grid
hierarchy consists of several \emph{refinement levels}, and each
refinement level consists of several \emph{refined regions}.  A
refined region is a cuboid set of grid points which is assigned to a
particular processor.  (The ``refined regions'' which are specified
e.g.\ in a parameter file are broken up during domain is decomposition
into a set of regions, so that each region is assigned to exactly one
processor.)  There can be zero or multiple regions per processor, and
different processors may own different numbers of regions.  Each face
of a region is either an outer or an internal boundary.  Refined
regions are described by the data structure \code{region\_t}, which is
declared in \code{CarpetLib/src/region.hh}.

The refined regions on one level may not overlap.  (If they do not
touch each other or the outer boundary, then they usually even have to
keep a certain minimum distance, as described below.)

The ``semantics'' (the result obtained in a simulation) of a grid
hierarchy is independent of the number of refined regions, or of the
processors which are assigned to them.  The only relevant quantity is
the set of refined grid points, i.e., the conjunction of all refined
regions.  When running on more processors, the regions will be split
up so that there are more and smaller regions.

The assignment of regions to processors is handled during regridding
because it affects performance.  When there are only few processors
available, then it may be more efficient to use fewer regions.
Combining regions may require some fill-in.  \todo{Show figure.}  No
current regridding thorn in Carpet offers this at the moment;
currently, the set of refined points is independent of the number of
processors.

Each face of a refined region is either an interior or an outer
boundary face.  Carpet adds no ghost or buffer zones to outer boundary
faces, and marks this face as outer boundary when calling thorns.  An
outer boundary face must extend up to the outermost outer boundary
point, since otherwise thorns will apply the outer boundary conditions
incorrectly.  The regridding thorn has to ensure this property.  Faces
which are not outer boundary faces must be sufficiently far away from
outer boundaries, so that any ghost or buffer zones which are added to
that face do not intersect the outer boundary.  \todo{Show figure.}
The regridding thorn also has to ensure this property.

Each face which is not an outer boundary face is either an
inter-processor or a refinement boundary face.  Inter-processor faces
have no buffer zones, and the ghost zones can be filled in completely
from other refined regions on the same level.  Refinement boundary
faces do have buffer zones, and at least some of the ghost zones must
be filled via prolongation from the next coarser grid.  It is possible
to have faces which are partly an inter-processor boundary and partly
a refinement boundary.  These are counted as and handled as refinement
boundaries, although some of the ghost zones may still be filled via
synchronisation.  (Any grid points which can be filled via
synchronisation are always also filled via synchronisation.)  This is
explained in more detail below.

As described below, ghost zones are added at the outside of regions by
Carpet.  Buffer zones need to be taken into account by the regridding
thorn, most likely by extending the refined regions appropriately.
(In terms of previous terminology: buffer zones are always ``inner''
buffer zones; ``outer'' buffer zones do not exist any more.  However,
if they are added by the regridding thorn, they do not need to be
taken into account when specifying the refinement hierarchy in a
parameter file -- this depends on the regridding thorn.
\todo{CarpetRegrid2 does this, CarpetRegrid does this not.})  Carpet
assumes buffer zones at all faces which are marked as refinement
boundaries.

It is the responsibility of the regridding thorn to mark outer
boundaries and refinement boundaries appropriately.  If the outer
boundary mark is chosen wrongly, then the simulation is inconsistent,
since the outer boundary condition may be applied at a the wrong
location, or the outer boundary may be filled by interpolation which
is less accurate.  Depending on the number of boundary points and
stencil sizes, this may or may not be detected later by
self-consistency checks.



\section{Zoning}

This section defines the algorithm which Carpet uses to define which
grid points are defined by what action.  This algorithm is codified in
\code{dh.cc}.  Since the code in \code{dh.cc} is tested, it should be
assumed to be correct where it differs with this description.  This
algorithm is applied to every refinement level.

\emph{Grid arrays} are handled in the same way as grid functions,
except that there are no refined regions.  This may seem like overkill
at first, but in fact it greatly simplifies the implementation since
grid arrays have (almost) only a subset of the capabilities of grid
functions.

\subsection{Domain}

Let $dom$ be the simulation domain.  Let $domact$ be the set of grid
points which are evolved in time, and which is required to be cuboidal
and not empty.\footnote{While grid functions cannot be empty, $domact$
  for grid arrays can be empty.}  (An empty region is also counted as
cuboidal.)

Each face has a layer of outer boundary points.  Let $domob$ be the
set of these layers.  We require that all values in $domob$ can be
calculated from the values in $domact$.  Let $domext := domact \cup
domob$.  It follows that $domext$ is cuboidal and not
empty.

\todo{Show figure.}

The following properties hold for $dom$:
\begin{itemize}
\item $domact$ is cuboidal and not empty
\item $domob$ is a possibly empty layer around $domact$
\item $domob$ has a width of \code{nboundaryzones} as obtained from
  \code{GetBoundarySpecification}
\item $domact \cap domob = \emptyset$
\item $domext = domact \cup domob$ is cuboidal and not empty
\item $domext$ has the size \code{cctk\_gsh}
\end{itemize}
For completeness, one can define $dombnd = dombuf = \emptyset$, and
$domint = domown = domact$.  Then the same relations hold for $dom$ as
for $reg$ below.

\subsection{Refined regions}

Let $reg$ be a refined region.  Let $regint$ be its interior, which is
required to be cuboidal and not empty.  $regint$ includes buffer zones
and outer boundary points.  We require that $regint \subseteq domext$.

There may be other refined regions $reg'$ on the same level.  We
require that $\forall_{reg' \ne reg}: regint \cap regint' =
\emptyset$.

Each face of $regint$ which is not an outer boundary face has a layer
of \code{cctk\_nghostzones} ghost zones added to it.  (These are what
Cactus calls ``ghost zones'', but note that not all ghost zones are
filled via synchronisation.)  Let $regghost$ be the set of these
layers.  We require that $regghost \subseteq domact$.  Let $regext :=
regint \cup regghost$ be the interior with the ghost zones added.  It
follows that $regext$ is cuboidal and not empty.  We require that
$regext \subseteq domext$.

\todo{Show figure.}

On each face of $regext$, the outermost layer of \code{nboundaryzones}
points are not communicated.  Let $regcomm$ be the set of communicated
points.  The $regcomm \subseteq regext$, we require it to be not
empty, and we require that $recomm \subseteq domact$.

Let $regob := regext - regcomm$ be the set of outer boundary points.
It follows that $regob \subseteq domob$.

The owned region $regown$ is the interior region, extended up to the
boundary, i.e., $regint$ with a layer of \code{nboundaryzones} points
added to it at all outer boundary faces.  Thus $regown$ is cuboidal,
and we require it to be not empty.  It is also $regown \subseteq
domact$, and $regown \subseteq regext$.  It is also $\forall_{reg' \ne
  reg}: regown \cap regown = \emptyset$.

Let $regbnd := regcomm - regown$.  Then $regbnd \subseteq domact$.
\todo{Does this follow, or is this a requirement?}  These points are
filled via synchronisation \todo{Is this so?  Is this always via
  inter-processor communiocation, or also via prolongation?}, and they
cannot be too close to the outer boundary.

Let $regbuf$ be the set of grid points which have a distance less than
\code{buffer\_width} from the boundary of the conjunction of all
active grid points.  Then $regbuf \subseteq regown$.  Let $regact :=
regown - regbuf$.  Then also $regact \subseteq regown$.  In general,
$regact$ is not cuboidal.  $regact$ can be empty.  \todo{This may be
  controversial.}

\todo{Show figure.}

Let $regsync := regbnd \cap allown$ be the boundary points which can
be filled via synchronisation.  Note that $regbnd \cap regown =
\emptyset$ by construction, which means that a region cannot
synchronise from itself.  Note that outer boundary points are
synchronised for backward compatibility.

Let $regref := (regbnd - regsync) \cup regbuf$ be the set of all
points which need to be filled via prolongation.  Note that $regref
\cap regsync = \emptyset$, which means that no point is both
synchronised and prolongated.  Note also that $regref \cap regob =
\emptyset$, which means that no outer boundary point is prolongated.

\todo{Show figure.}

The following properties hold for $reg$:
\begin{itemize}
\item $regint \subseteq domext$ is cuboidal and not empty
\item $regghost$ is a layer on the outside of $regint$ on those faces
  which are not marked ``outer boundary''
\item $regext = regint \cup regghost \subseteq domext$ is cuboidal and
  not empty
\item $recgomm \subseteq domact$
\item $regob \subseteq domob$
\item $regown \subseteq domact$ is cuboidal and not empty
\item $\forall_{reg' \ne reg}: regown \cup regown' = \emptyset$
\item $regbnd$ is a layer around $regown$ on those faces which are not
  marked ``outer boundary''
\item $regbuf$ is a layer around $regact$ on those faces which are
  marked ``refinement boundary''
\item $regsync$ are those boundary points which can be filled via
  synchronisation
\item $regref$ are those boundary or buffer points which are filled
  via prolongation
\end{itemize}
$regint$ is not important for Carpet's working, but only for Cactus.
Since Cactus has no notion of outer boundaries, we introduce $regint$,
which corresponds to $regown$, but includes outer boundary points.



\section{Algorithmic details}

It is straightforward to extend or shrink a cuboidal region $C$ by a
layer of grid points with a given width.  It is also straightforward
to extend an arbitrary region $R$, which is internally represented as
a set of non-overlapping cuboidal regions ${C^i}$.  One sets
$\mathrm{ext}[R] := \bigcup \mathrm{ext}[C^i]$.  The individual
extended cuboidal regions $\mathrm{ext}[C^i]$ will overlap in general,
but this overlap is handled correctly by the operator $\bigcup$.
However, there is no straightforward way to shrink an arbitrary region
$R$.  One possibility is to extend the complement of $R$ instead.

The layer of buffer zones $allbuf$ can be calculated in the following
way.  Let $allown := \bigcup regown$ as above be the set of all
refined grid points.  Then $domact - allown$ is the set of all
not-refined grid points in the domain.  In order to handle the outer
boundary of the domain correctly, we define $domlarge$ to be $domact$,
sufficiently enlarged in each direction, i.e., enlarged at least by
the number of buffer zones.  Let $notown := domlarge - allown$ be the
complement of $allown$.  Let $notact$ be $notown$, enlarged by the
number of buffer zones.  Then $allbuf := allown - notact$.



\appendix
\section{Terminology}

\todo{To be filled in}
\begin{description}
\item[Block:] See map.
\item[Buffer zone:] ???
\item[Component:] ???
\item[Ghost zone:] ???
\item[Grid hierarchy:] ???
\item[Inter-processor boundary:] ???
\item[Map:] ???
\item[Outer boundary:] ???
\item[Patch:] See map.
\item[Physical boundary:] ???
\item[Refinement boundary:] ???
\item[Refinement level:] ???
\item[Region:] ???
\item[Regridding:] ???
\item[Symmetry boundary:] ???
\end{description}



% With titles and urls
\bibliographystyle{bibtex/amsplain-url}
\bibliography{bibtex/references}

\end{document}