| Author(s): | Gabrielle Allen |
| Gerd Lanfermann |
| Joan Masso |
| Jonathan Thornburg |
| Date: | Date |
CartGrid3D allows you to set up coordinates on a 3D Cartesian grid in a flexible manner. You can choose different grid domains (eg octant) to allow you to exploit any symmetry in your problem. CartGrid3D also provides routines for registering symmetries of grid functions and applying symmetry conditions across the coordinate axes.
You specify the grid symmetry (or lack thereof) with the grid::domain parameter:
In each case except grid::domain = "full", symmetry zones are introduced just on the “other side” of each symmetry grid boundary. Each symmetry zone has a width (perpendicular to the boundary) of driver::ghost_size extra grid points. For centered 2nd order finite differencing, a width of driver::ghost_size = 1 should be sufficient, but for (centered) 4th order finite differencing, or for upwinded 2nd order, a width of driver::ghost_size = 2 is needed. Making driver::ghost_size too large is fairly harmless (it just slightly reduces performance), but making it too small will almost certainly result in horribly wrong finite differencing near the symmetry boundaries, and may also result in core dumps from out-of-range array accessing.
Note that the symmetry zones must be explicitly included in driver::global_nx, driver::global_ny, and driver::global_nz, but should not be included in any of the grid::type = "byrange" parameters grid::xmin, grid::xmax, grid::ymin, grid::ymax, grid::zmin, grid::zmax, grid::xyzmin, and/or grid::xyzmax described in the next section.
Note also that driver::global_nx, driver::global_ny, and driver::global_nz do not include any ghost zones introduced for multiprocessor synchronization. (For more information on ghost zones, see the section “Ghost Size” in the “Cactus Variables” chapter of the Cactus Users’ Guide.)
CartGrid3D provides several different methods for setting up the integer grid size (eg 128), floating-point grid spacing (eg 0.1), and floating-point grid range (eg 12.8).1 You specify which method to use, with the grid::type parameter:
There are also a number of optional parameters which can be used to specify whether or not it’s ok to have a grid point with an x, y, and/or z coordinate exactly equal to 0:
Δx, x = -
Δx, x = +
Δx, x = +
Δx, …, but not at x = 0.
Here is an example of setting up a grid using the PUGH unigrid driver. The relevant parts of the parameter file are as follows:
The resulting Cactus output (describing the grid) is as follows:
Since there’s no symmetry in the x and y directions, the grid is set up just as specified, with floating-point coordinates running from -3.0 to 3.0 inclusive, and 61 grid points with integer grid indices [0,60] (C) or [1,61] (Fortran).
However, in the z direction there’s a reflection symmetry across the z = 0 plane, so the specified range of the grid, z ∈ [0.0,3.0], is automagically widened to include the symmetry zone of driver::ghost_size = 2 grid points. The grid thus actually includes the range of floating-point coordinates z ∈ [-0.2,3.0]. The original specification of 33 grid points is left alone, however, so the grid points have integer array indices [0,32] (C) or [1,33] (Fortran). The “physical” (ie non-symmetry-zone) part of the grid is precisely the originally-specified range, z ∈ [0.0,3.0], and has the integer array indices [2,32] (C) or [3,33] (Fortran).
CartGrid3D defines (registers) four coordinate systems: cart3d, cart2d, cart1d, and spher3d.
The Cartesian coordinates supplied by this thorn are grid functions with the standard names x, y, and z. To use these coordinates you need to inherit from grid, ie you need to have an
line in your interface.ccl file. In addition a grid function r is provided, containing the radial coordinate from the origin where

CartGrid3D registers the lower and upper range of each coordinate with the flesh.
If your problem and initial data allow it, CartGrid3D allows you to enforce even or odd parity for any grid function at (across) each coordinate axis. For a function ϕ(x,y,z), even parity symmetry on the x-axis means


Note that the symmetries will only be enforced if a symmetry domain is chosen (that is, if grid::domain is set to something other than grid::domain = "full".
Each grid function can register how it behaves under a coordinate change using function calls in CartGrid3D. These symmetry properties can then be used by other thorns, for example CactusBase/Boundary uses them to enforce symmetry boundary conditions across coordinate axes. Symmetries should obviously be registered before they are used, but since they can be different for different grids, they must be registered after the CCTK_STARTUP timebin. The usual place to register symmetries is in the CCTK_BASEGRID timebin.
For example, to register the symmetries of the xy component of the metric tensor from C, you first need to get access to the include file by putting the line
in your interface.ccl file. Then in your thorn you can write (C)
CartGrid3D provides the following two routines to apply symmetry boundary conditions to a variable group:
and for a specific variable it provides:
A group or variable can be specified by its index value or name (use the ’I’ or ’N’ version respectively). The Fortran versions of these functions take an additional first argument, which is an integer which will hold the return value.
avoid_origin | Scope: private | BOOLEAN |
Description: Don’t place grid points on the coordinate origin/axes
| ||
| Range | Default: yes | |
: | ||
avoid_originx | Scope: private | BOOLEAN |
Description: Don’t place grid points on the x-coordinate origin/axes
| ||
| Range | Default: yes | |
: | ||
avoid_originy | Scope: private | BOOLEAN |
Description: Don’t place grid points on the y-coordinate origin/axes
| ||
| Range | Default: yes | |
: | ||
avoid_originz | Scope: private | BOOLEAN |
Description: Don’t place grid points on the z-coordinate origin/axes
| ||
| Range | Default: yes | |
: | ||
no_origin | Scope: private | BOOLEAN |
Description: DEPRECATED: Don’t place grid points on the coordinate origin/axes
| ||
| Range | Default: yes | |
: | ||
no_originx | Scope: private | BOOLEAN |
Description: DEPRECATED: Don’t place grid points on the x-coordinate origin/axes
| ||
| Range | Default: yes | |
: | ||
no_originy | Scope: private | BOOLEAN |
Description: DEPRECATED: Don’t place grid points on the y-coordinate origin/axes
| ||
| Range | Default: yes | |
: | ||
no_originz | Scope: private | BOOLEAN |
Description: DEPRECATED: Don’t place grid points on the z-coordinate origin/axes
| ||
| Range | Default: yes | |
: | ||
register_default_coordinate_systems | Scope: private | BOOLEAN |
Description: register cartnd as the default coordinate systems
| ||
| Default: yes | ||
set_coordinate_ranges_on | Scope: private | KEYWORD |
Description: On which grids to set the coordinate ranges
| ||
| Range | Default: all grids | |
all grids | set ranges in local mode, on the coarsest level
| |
all maps | set ranges in singlemap mode, on the coarsest level
| |
first level | set ranges in level mode, on the first level
| |
bitant_plane | Scope: restricted | KEYWORD |
Description: Plane defining bitant domain
| ||
| Range | Default: xy | |
xy | xy-plane
| |
xz | xz-plane
| |
yz | yz-plane
| |
domain | Scope: restricted | KEYWORD |
Description: Domain type
| ||
| Range | Default: full | |
octant | Use an octant about the origin
| |
quadrant | Use a quadrant in x-y plane
| |
see [1] below | Use a quadrant with rotation symmetry about an axis
| |
bitant | Use a bitant about the x-y plane
| |
bitant_rotate | Use a bitant with rotation symmetry about an axis
| |
full | Use the full domain
| |
[1]
dx | Scope: restricted | REAL |
Description: Coarse grid spacing in x-direction
| ||
| Range | Default: 0.3 | |
0:* | Positive
| |
dxyz | Scope: restricted | REAL |
Description: Coarse grid spacing in x,y,z-directions
| ||
| Range | Default: 0.0 | |
0:* | Positive
| |
dy | Scope: restricted | REAL |
Description: Coarse grid spacing in y-direction
| ||
| Range | Default: 0.3 | |
0:* | Positive
| |
dz | Scope: restricted | REAL |
Description: Coarse grid spacing in z-direction
| ||
| Range | Default: 0.3 | |
0:* | Positive
| |
quadrant_direction | Scope: restricted | KEYWORD |
Description: Direction defining quadrant domain
| ||
| Range | Default: z | |
x | x-direction
| |
y | y-direction
| |
z | z-direction
| |
rotation_axis | Scope: restricted | KEYWORD |
Description: Axis about which the rotation symmetry is to be applied
| ||
| Range | Default: z | |
x | x-axis
| |
y | y-axis
| |
z | z-axis
| |
symmetry_xmax | Scope: restricted | BOOLEAN |
Description: Symmetry boundary condition on upper x boundary
| ||
| Range | Default: no | |
: | Logical
| |
symmetry_xmin | Scope: restricted | BOOLEAN |
Description: Symmetry boundary condition on lower x boundary
| ||
| Range | Default: no | |
: | Logical
| |
symmetry_ymax | Scope: restricted | BOOLEAN |
Description: Symmetry boundary condition on upper y boundary
| ||
| Range | Default: no | |
: | Logical
| |
symmetry_ymin | Scope: restricted | BOOLEAN |
Description: Symmetry boundary condition on lower y boundary
| ||
| Range | Default: no | |
: | Logical
| |
symmetry_zmax | Scope: restricted | BOOLEAN |
Description: Symmetry boundary condition on upper z boundary
| ||
| Range | Default: no | |
: | Logical
| |
symmetry_zmin | Scope: restricted | BOOLEAN |
Description: Symmetry boundary condition on lower z boundary
| ||
| Range | Default: no | |
: | Logical
| |
type | Scope: restricted | KEYWORD |
Description: Grid type
| ||
| Range | Default: box | |
box | Box grid from -0.5 to 0.5
| |
byrange | Specify min and max values
| |
byspacing | Specify grid spacings
| |
coordbase | Get specification from CoordBase
| |
multipatch | Get specification from MultiPatch
| |
xmax | Scope: restricted | REAL |
Description: Coordinate maximum in x-direction
| ||
| Range | Default: 1.0 | |
: | Anything
| |
xmin | Scope: restricted | REAL |
Description: Coordinate minimum in x-direction
| ||
| Range | Default: -1.0 | |
: | Anything
| |
xyzmax | Scope: restricted | REAL |
Description: Coordinate maximum in xyz-directions
| ||
| Range | Default: -424242 | |
: | Anything
| |
xyzmin | Scope: restricted | REAL |
Description: Coordinate minimum in x,y,z-directions
| ||
| Range | Default: -424242 | |
: | Anything
| |
ymax | Scope: restricted | REAL |
Description: Coordinate maximum in y-direction
| ||
| Range | Default: 1.0 | |
: | Anything
| |
ymin | Scope: restricted | REAL |
Description: Coordinate minimum in y-direction
| ||
| Range | Default: -1.0 | |
: | Anything
| |
zmax | Scope: restricted | REAL |
Description: Coordinate maximum in z-direction
| ||
| Range | Default: 1.0 | |
: | Anything
| |
zmin | Scope: restricted | REAL |
Description: Coordinate minimum in z-direction
| ||
| Range | Default: -1.0 | |
: | Anything
| |
periodic | Scope: shared from DRIVER | BOOLEAN |
periodic_x | Scope: shared from DRIVER | BOOLEAN |
periodic_y | Scope: shared from DRIVER | BOOLEAN |
periodic_z | Scope: shared from DRIVER | BOOLEAN |
Implements:
grid
Inherits:
coordbase
| Group Names | Variable Names | Details | |
| gridspacings | compact | 0 | |
| coarse_dx | description | 3D Cartesian grid spacings | |
| coarse_dy | dimensions | 0 | |
| coarse_dz | distribution | CONSTANT | |
| group type | SCALAR | ||
| stagger type | NONE | ||
| tags | Checkpoint=”no” | ||
| timelevels | 1 | ||
| variable type | REAL | ||
| coordinates | compact | 0 | |
| x | description | 3D Cartesian grid coordinates | |
| y | dimensions | 3 | |
| z | distribution | DEFAULT | |
| r | group type | GF | |
| stagger type | NONE | ||
| tags | Prolongation=”None” Checkpoint=”no” | ||
| timelevels | 1 | ||
| variable type | REAL | ||
Adds header:
Symmetry.h
Uses header:
CoordBase.h
This section lists all the variables which are assigned storage by thorn CactusBase/CartGrid3D. Storage can either last for the duration of the run (Always means that if this thorn is activated storage will be assigned, Conditional means that if this thorn is activated storage will be assigned for the duration of the run if some condition is met), or can be turned on for the duration of a schedule function.
| Always: | |
| coordinates gridspacings | |
CCTK_STARTUP
symmetrystartup
register gh extension for gridsymmetry
| Language: | c | |
| Type: | function | |
CCTK_WRAGH
registercartgrid3dcoords
register coordinates for the cartesian grid
| Language: | c | |
| Options: | meta | |
| Type: | function | |
BoundaryConditions
cartgrid3d_applybc
apply symmetry boundary conditions
| Language: | c | |
| Type: | function | |
SymmetryRegister
registersymmetryboundaries
register symmetry boundaries
| Language: | c | |
| Options: | meta | |
| Type: | function | |
CCTK_PARAMCHECK
paramcheck_cartgrid3d
check coordinates for cartgrid3d
| Language: | c | |
| Type: | function | |
CCTK_BASEGRID (conditional)
cartgrid3d_setranges
set up ranges for spatial 3d cartesian coordinates (on all grids)
| Before: | spatialcoordinates | |
| Language: | c | |
| Type: | function | |
CCTK_BASEGRID (conditional)
cartgrid3d_setranges
set up ranges for spatial 3d cartesian coordinates (on all maps)
| Before: | spatialcoordinates | |
| Language: | c | |
| Options: | singlemap | |
| Type: | function | |
CCTK_BASEGRID (conditional)
cartgrid3d_setranges
set up ranges for spatial 3d cartesian coordinates (on first level)
| Before: | spatialcoordinates | |
| Language: | c | |
| Options: | level | |
| Type: | function | |
CCTK_BASEGRID
cartgrid3d_setcoordinates
set up spatial 3d cartesian coordinates on the gh
| Language: | c | |
| Type: | function | |
CCTK_POSTREGRIDINITIAL
cartgrid3d_setcoordinates
set coordinates after regridding
| Language: | c | |
| Type: | function | |
CCTK_POSTREGRID
cartgrid3d_setcoordinates
set coordinates after regridding
| Language: | c | |
| Type: | function | |
| Alias Name: | Function Name: |
| CartGrid3D_SetCoordinates | SpatialCoordinates |
1If you’re AMR-ing, this all refers to the coarsest or base grid.