Erik Schnetter <>



When the computational domain has symmetries, then it is often very convenient to be able to interpolate at points that are not present on the actual computational grid, but can be mapped into the grid through the symmetries. Thorn SymBase provides a mechanism by which symmetry conditions can register routines that handle this mapping when a global interpolator is called.

1 Introduction

Thorn SymBase contains a registry for symmetry conditions and for symmetry faces. Other thorns that implement symmetry boundary conditions register themselves with SymBase and reserve certain faces of the grid, so that no other boundary condition is applied there. Thorns that implement physical boundary conditions should query SymBase about the set of faces that have symmetry boundary conditions and should not apply the physical boundary condition there.


Figure 1: Multiple SymBase symmetry transformations across different registered symmetry faces. A point x is transformed to point x by transformation A, and then to point x by transformation B. Data is only actually stored for point x.

The driver has to be aware that it calls thorn SymBase’s mapping routine before it actually interpolates. The whole mechanism is transparent for the user.

2 Registering Symmetry Conditions

Each thorn that implements a symmetry boundary condition should register itself with thorn SymBase. This has no consequences per se, but it reserves a symmetry handle for later reference. The API for registering and querying symmetry names and handles is

    SymmetryRegister (CCTK_STRING IN sym_name)  
    SymmetryHandleOfName (CCTK_STRING IN sym_name)  
    SymmetryNameOfHandle (CCTK_INT IN sym_handle)

The routine SymmetryRegister should be called in a routine that has been scheduled in the schedule group SymmetryRegister.

Note: We have the API in the specification, we have it in the interface file, in the source code, and in a header file, and I duplicated it into grdoc headers. I refuse to write and describe and cross-check the API a sixth time in latex. At some point, we have to start using tools for that. Please read the grdoc headers or the grdoc-produced HTML files for a detailed description.

3 Registering Symmetries for Faces

Thorn SymBase keeps two registries. The first, mentioned in the previous section, is the set of symmetry boundary conditions. The second, the symmetry table, prescribes to which faces of the grids which symmetry boundary condition is to be applied. Each entry of this table constitutes a mapping from grid faces to symmetry boundary conditions, described by arrays whose elements correspond to grid faces:

CCTK_INT symmetry_handle[]  
CCTK_INT symmetry_zone_width[]

The faces are numbered in the same way those of the cctk_bbox array. Each element of symmetry_handle is a symmetry handle as described in section 2. The symmetry zone is the same as a Cactus ghost zone, just in the context of a symmetry boundary, so the symmetry_zone_width will be typically be the same as the ghost zone width.

There is one such table for the grid hierarchy, which is valid for all grid functions. There is additionally one such table for each grid array group.

The API for registering symmetries for faces is

         (CCTK_POINTER IN cctkGH,  
          CCTK_INT IN sym_handle,  
          CCTK_INT IN ARRAY which_faces,  
          CCTK_INT IN ARRAY symmetry_zone_width)  
        (CCTK_POINTER IN cctkGH,  
         CCTK_INT IN sym_handle,  
         CCTK_INT IN ARRAY which_faces,  
         CCTK_INT IN ARRAY symmetry_zone_width,  
         CCTK_INT IN group_index)  
        (CCTK_POINTER IN cctkGH,  
         CCTK_INT IN sym_handle,  
         CCTK_INT IN ARRAY which_faces,  
         CCTK_INT IN ARRAY symmetry_zone_width,  
         CCTK_STRING IN group_name)

The first routine registers a symmetry condition for the grid hierarchy; the other two routines register for grid array groups (by index or name, respectively) sym_handle must be a symmetry handle obtained as described in the previous section. which_faces and symmetry_zone_width are arrays with one element per face, numbered in the same way as the cctk_bbox array. which_faces selects which faces to register, and symmetry_zone_width sets the number of symmetry zones for these faces.

These routines may be called at anytime after SymmetryRegister.

It is not possible to register multiple symmetry boundary conditions for the same face.

4 Querying Symmetries of Faces

Physical boundary conditions need to know to which faces they should apply the boundary condition. They need to query SymBase for the set of faces that have a symmetry boundary condition, and they must not apply their physical boundary condition there. The API is

    SymmetryTableHandleForGrid (CCTK_POINTER_TO_CONST IN cctkGH)  
         CCTK_INT IN group_index)  
         CCTK_STRING IN group_name)

The first of these functions returns the symmetry table handle for the grid hierarchy; the second and third return the that for the grid array group (by index or name, respectively).

The table entry with key symmetry_handle contains the symmetry handle for the symmetry boundary condition, or a negative number if the face has no symmetry boundary condition associated with it.

The code to find out which boundaries should have a physical boundary condition applied might look as follows:

#include "cctk.h"  
#include "util_Table.h"  
CCTK_INT symtable;  
CCTK_INT symbnd[6];  
int face;  
int ierr;  
symtable = SymmetryTableHandleForGrid (cctkGH);  
if (symtable<0)  
  CCTK_VWarn(0, __LINE__, __FILE__, "Thorn_Name", "symtable is out of bounds");  
ierr = Util_TableGetIntArray (symtable, 6, symbnd, "symmetry_handle");  
if (ierr!=6)  
  CCTK_VWarn(0, __LINE__, __FILE__, "Thorn_Name", "Util_TableGetIntArray returned error");  
for (face=0; face<6; ++face) {  
  if (cctk_bbox[face] && symbnd[face]<0) {  
    /* Apply physical boundary condition here */  


#include "util_Table.h"  
CCTK_INT symtable  
CCTK_INT symbnd(6)  
integer face  
integer ierr  
symtable = SymmetryTableHandleForGrid (cctkGH)  
if (symtable<0) call CCTK_WARN (0, "internal error")  
call Util_TableGetIntArray (ierr, int(symtable), 6, symbnd, "symmetry_handle")  
if (ierr/=6) call CCTK_WARN (0, "internal error")  
do face=1,6  
  if (cctk_bbox(face)/=0 .and. symbnd(face)<0) then  
    ! Apply physical boundary condition here  
  end if  
end do

5 Symmetry Interpolation

The mechanism by which the grid points are mapped into the domain works as follows:

  1. The user calls CCTK_InterpGridArrays with a list of coordinates.
  2. The Flesh forwards this call to the driver.
  3. The driver calls SymBase’s aliased function, SymmetryInterpolate, passing along all arguments.
  4. SymBase sets a flag for each face for which a symmetry condition has been registered, and then calls SymmetryInterpolateFaces, passing along all arguments. This is the beginning of a chain of recursive calls.
  5. SymmetryInterpolateFaces checks whether any faces are flagged.
  6. If no faces are flagged, SymBase calls the driver’s aliased function DriverInterpolate, which performs the actual interpolation. This ends the chain of recursive calls.
  7. If there are faces with symmetry conditions flagged, SymBase chooses one such face, and then calls the “symmetry interpolation” routine of the symmetry condition registered for this face, passing along all arguments.
  8. The “symmetry interpolation” routine maps the coordinates into the domain by applying the symmetry condition for this face. It then removes the flag for the corresponding face, and calls SymmetryInterpolateFaces, passing along the arguments with the changed interpolation locations.
  9. After the actual interpolation has happened in the driver, the recursive call will return. The “symmetry interpolation” routine then examines the tensor types of the interpolated quantities and un-maps the values back onto their original locations. That is, e.g., after a reflection on the lower x-boundary, x-components of vectors need their sign changed.
  10. The chain of recursive calls unravels until the call to CCTK_InterpGridArrays returns.


Figure 2: The recursive calls involved in symmetry interpolation. Values of grid functions a at global Cartesian coordinates x are calculated by nested calls to the symmetry interpolators, which first apply the symmetry transformation to the coordinates. When all the symmetries have been applied, the local interpolator is called, producing the interpolation of grid function values in the local basis. As the symmetry interpolators return, they apply the inverse basis transformation to the interpolated grid function values.

This mechanism has thus four players:

5.1 Interaction With Symmetry Conditions

The symmetry conditions have to register their “symmetry interpolation” routines by calling SymBase’s aliased function SymmetryRegisterGridInterpolator. The “symmetry interpolation” routine must use C linkage and must have the prototype

CCTK_INT symmetry_interpolate  
     CCTK_INT IN N_dims,  
     CCTK_INT IN local_interp_handle,  
     CCTK_INT IN param_table_handle,  
     CCTK_INT IN coord_system_handle,  
     CCTK_INT IN N_interp_points,  
     CCTK_INT IN interp_coords_type,  
     CCTK_POINTER_TO_CONST ARRAY IN interp_coords,  
     CCTK_INT IN N_input_arrays,  
     CCTK_INT ARRAY IN input_array_indices,  
     CCTK_INT IN N_output_arrays,  
     CCTK_INT ARRAY IN output_array_types,  
     CCTK_POINTER ARRAY IN output_arrays,  
     CCTK_INT IN faces)

These arguments are the same as those for CCTK_InterpGridArrays, except that here the bit field faces is used to flag those faces that remain to have their symmetry boundary condition applied to the interpolation points.

The aliased function SymmetryRegisterGridInterpolator has the prototype

CCTK_INT FUNCTION                                           \  
    SymmetryRegisterGridInterpolator                        \  
        (CCTK_POINTER IN cctkGH,                            \  
         CCTK_INT IN sym_handle,                            \  
         CCTK_INT CCTK_FPOINTER IN symmetry_interpolate     \  
             (CCTK_POINTER_TO_CONST IN cctkGH,              \  
              CCTK_INT IN N_dims,                           \  
              CCTK_INT IN local_interp_handle,              \  
              CCTK_INT IN param_table_handle,               \  
              CCTK_INT IN coord_system_handle,              \  
              CCTK_INT IN N_interp_points,                  \  
              CCTK_INT IN interp_coords_type,               \  
              CCTK_POINTER_TO_CONST ARRAY IN interp_coords, \  
              CCTK_INT IN N_input_arrays,                   \  
              CCTK_INT ARRAY IN input_array_indices,        \  
              CCTK_INT IN N_output_arrays,                  \  
              CCTK_INT ARRAY IN output_array_types,         \  
              CCTK_POINTER ARRAY IN output_arrays,          \  
              CCTK_INT IN faces))

which takes a function pointer to the aforementioned “symmetry interpolation” routine, while sym_handle specifies which symmetry condition this routine is for. This handle must have been obtained from SymmetryRegister.

The routine SymmetryRegisterGridInterpolator must be called after the symmetry faces have been selected by the call to SymmetryRegisterGrid.

For convenience, the macro CCTK_ALL_FACES is provided. It may be used to initialize the faces bit field in cases where the interpolation is to occur on all grid faces.

After it has removed from the faces variable the faces whose symmetry condition it has applied, the symmetry interpolator routine must call the SymBase function SymmetryInterpolateFaces, which has the prototype

CCTK_INT FUNCTION                                           \  
    SymmetryInterpolateFaces                                \  
        (CCTK_POINTER_TO_CONST IN cctkGH,                   \  
         CCTK_INT IN N_dims,                                \  
         CCTK_INT IN local_interp_handle,                   \  
         CCTK_INT IN param_table_handle,                    \  
         CCTK_INT IN coord_system_handle,                   \  
         CCTK_INT IN N_interp_points,                       \  
         CCTK_INT IN interp_coords_type,                    \  
         CCTK_POINTER_TO_CONST ARRAY IN interp_coords,      \  
         CCTK_INT IN N_input_arrays,                        \  
         CCTK_INT ARRAY IN input_array_indices,             \  
         CCTK_INT IN N_output_arrays,                       \  
         CCTK_INT ARRAY IN output_array_types,              \  
         CCTK_POINTER ARRAY IN output_arrays,               \  
         CCTK_INT IN faces)

5.2 Driver Interaction

The driver has to call SymBase’s aliased function SymmetryInterpolate, and has to provide an aliased function DriverInterpolate. Both functions have prototypes similar to CCTK_InterpGridArrays:

         CCTK_INT IN N_dims,  
         CCTK_INT IN local_interp_handle,  
         CCTK_INT IN param_table_handle,  
         CCTK_INT IN coord_system_handle,  
         CCTK_INT IN N_interp_points,  
         CCTK_INT IN interp_coords_type,  
         CCTK_POINTER_TO_CONST ARRAY IN interp_coords,  
         CCTK_INT IN N_input_arrays,  
         CCTK_INT ARRAY IN input_array_indices,  
         CCTK_INT IN N_output_arrays,  
         CCTK_INT ARRAY IN output_array_types,  
         CCTK_POINTER ARRAY IN output_arrays)

         CCTK_INT IN N_dims,  
         CCTK_INT IN local_interp_handle,  
         CCTK_INT IN param_table_handle,  
         CCTK_INT IN coord_system_handle,  
         CCTK_INT IN N_interp_points,  
         CCTK_INT IN interp_coords_type,  
         CCTK_POINTER_TO_CONST ARRAY IN interp_coords,  
         CCTK_INT IN N_input_arrays,  
         CCTK_INT ARRAY IN input_array_indices,  
         CCTK_INT IN N_output_arrays,  
         CCTK_INT ARRAY IN output_array_types,  
         CCTK_POINTER ARRAY IN output_arrays)

6 Tensor Types

Cactus supports declaring the tensor type of grid function groups. These tensor types define how the grid functions, which are supposed to be tensor components, transform under various transformations, such as reflections and rotations.

The tensor types are not declared directly; instead, a tensor type alias is declared. The following tensor type aliases are currently known and supported:

a scalar ρ
a vector βi
a covector si
a symmetric rank two tensor γij

(More tensor type aliases are likely to be defined in the future.)

In addition to the tensor type, one can also declare the tensor parity, tensor weight, and a tensor metric. The tensor parity (an integer) specifies the behaviour under reflections. Scalars and polar vectors have a parity + 1, pseudo scalars and axial vectors have a parity 1. The tensor weight (a real number) specifies the behaviour under transformations that change the volume element. The tensor metric (a string) specifies what metric has to be used to raise or lower indices for that quantity.

Last but not least, a tensor special can be defined for quantities that do not transform as tensor. The currently supported tensor specials are

for the transformation behaviour of the Γi variables of the BSSN formalism; it is Γi := γjkΓjki with Γjki := 1 2γil kγlj + jγlk lγjk
for the transformation behaviour of the variable ϕ of the BSSN formalism; it is ϕ := logψ with ψ12 := detγij.

By default, the basis with respect to which the tensor components are given is supposed to be the (local) coordinate system given by the grid, i.e., the coordinate directions are the “natural” directions of the grid. It is possible to specify a different basis by declaring a tensor basis, which is the name of a grid function group containing the coordinate system.

6.1 Example Tensor Type Declarations

From CactusWave/WaveToy:

CCTK_REAL scalarevolve TYPE=gf TAGS=’tensortypealias="scalar"’

From CactusEinstein/ADMBase:

CCTK_REAL metric TYPE=gf TAGS=’tensortypealias="dd_sym" tensormetric="ADMBase::metric"’  
CCTK_REAL curv TYPE=gf TAGS=’tensortypealias="dd_sym" tensormetric="ADMBase::metric"’  
CCTK_REAL lapse TYPE=gf TAGS=’tensortypealias="scalar" tensormetric="ADMBase::metric"’  
CCTK_REAL shift TYPE=gf TAGS=’tensortypealias="U" tensormetric="ADMBase::metric"’

From AEIThorns/BSSN_MoL:

    TAGS=’tensortypealias="u" tensormetric="ADMBase::metric"’  
CCTK_REAL ADM_BSSN_dtlapse TYPE=gf \  
    TAGS=’tensortypealias="scalar" tensormetric="ADMBase::metric"’  
    TAGS=’tensortypealias="scalar" tensormetric="BSSN_MoL::ADM_BSSN_metric" \  
          tensorweight=0.16666666666666667 tensorspecial="log"’  
    TAGS=’tensortypealias="dd_sym" tensormetric="BSSN_MoL::ADM_BSSN_metric" \  
    TAGS=’tensortypealias="scalar" tensormetric="BSSN_MoL::ADM_BSSN_metric"’  
    TAGS=’tensortypealias="dd_sym" tensormetric="BSSN_MoL::ADM_BSSN_metric" \  
    TAGS=’tensortypealias="u" tensormetric="BSSN_MoL::ADM_BSSN_metric" \  
          tensorweight=0.66666666666666667 tensorspecial="Gamma"’

7 Parameters

Scope: private  BOOLEAN

Description: Output symmetry boundary face descriptions after registration

  Default: yes

8 Interfaces





SymmetryRegister to

SymmetryHandleOfName to

SymmetryNameOfHandle to

SymmetryRegisterGrid to

SymmetryRegisterGI to

SymmetryRegisterGN to

SymmetryRegisterGridInterpolator to

SymmetryTableHandleForGrid to

SymmetryTableHandleForGI to

SymmetryTableHandleForGN to

GetSymmetryBoundaries to

SymmetryInterpolate to

SymmetryInterpolateFaces to

9 Schedule

This section lists all the variables which are assigned storage by thorn CactusBase/SymBase. 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.



Scheduled Functions



  register gh extension for symbase


 Type: function



  wrapper group for symbase





  register your symmetries here





  print symmetry boundary face descriptions


 After: symmetryregister
 Type: function



  check whether the driver set up the grid consistently


 Type: function