CarpetXRegrid

Steven R. Brandt <sbrandt@cct.lsu.edu>
Roland Haas <rhaas@illinois.edu>

July 30 2024

Abstract

Provide a grid function, regrid_error, to the CarpetX driver. This grid function is used by CarpetX and AMReX to determine where to refine the grid.

1 Introduction

AMReX [1] and thus CarpetX implement Berger-Oliger [2] type structured mesh refinement. Grid cells are tagged for refinement in CarpetX using the overloaded virtual function AmrCore::ErrorEst.

This thorn, in combination with CarpetX, provides a covenient way for Cactus thorns to label cells needed refinement via a cell centered grid function regrid_error whose value controls if a cell is marked for refinement or not.

A cell is marked for refinement if the value found in regrid_error exceeds the threshold in parameter CarpetX::regrid_error_threshold and marked as not requiring refinement otherwise.

A client thorn wishing to control refinement should schedule a function in schedule bins POSTINITIAL and POSTSTEP. See thorn ErrorEstimator for an example.

2 Numerical Implementation

This thorn only provides access to the tagging grid function regrid_error and initializes it to zero at the beginning of the simulation.

3 Using This Thorn

To use this thorn, make sure to inherit from CarpetXRegrid to gain access to the public grid function regrid_error. A client thorn wishing to control refinement should then schedule a function in schedule bins POSTINITIAL and POSTSTEP which should loop over the interior of cell centered grid function regrid_error marking each cell for refinement or no refinement as needed. See thorn ErrorEstimator for an example.

In the future, to allow multiple independent regridding criteria to contribute to mesh refinement, grid function regrid_error may be interpreted as a boolean flag with true / false indicated by values of \(1.0\) and \(0.0\) (and all other values considered invalid). In the future this will require that a thorn should never reset non-zero value back to zero.

3.1 Obtaining This Thorn

This thorn is included in the CarpetX arrangement which is part of the Einstein Toolkit.

3.2 Special Behaviour

This thorn will initialize the error estimator grid function regrid_error to zero at the beginning of a simulation but does not change or use its values otherwise.

In the future it may reset the error estimator grid function before client thorns mark cells for refinement.

3.3 Interaction With Other Thorns

This thorn only provides access to regrid_error, while the actual regrid happens inside of CarpetX and AMReX.

3.4 Examples

Please consult thorn ErrorEstimator for an example on how to use this thorn.

extern "C" void MyRegrid_EstError(CCTK_ARGUMENTS) {
  DECLARE_CCTK_ARGUMENTSX_MyRegrid_EstError;
  DECLARE_CCTK_PARAMETERS;

  grid.loop_all_device<1, 1, 1>(
      grid.nghostzones,
      [=] CCTK_DEVICE(const Loop::PointDesc &p)
          CCTK_ATTRIBUTE_ALWAYS_INLINE {
              regrid_error(p.I) = fabs(p.x) < 42. ? 1.0 : 0.0;
      }
  );
}

3.5 Support and Feedback

For questions and bug reports please use the Einstein Toolkit users mailing list users@einsteintoolkit.org and bug tracker https://trac.einsteintoolkit.org.

References

[1]   Zhang, W., Almgren, A., Beckner, V., Bell, J., Blaschke, J., Chan, C., Day, M., Friesen, B., Gott, K., Graves, D., Katz, M., Myers, A., Nguyen, T., Nonaka, A., Rosso, M., Williams, S. & Zingale, M. AMReX: a framework for block-structured adaptive mesh refinement. Journal Of Open Source Software. 4, 1370 (2019,5), https://doi.org/10.21105/joss.01370

[2]   M. J. Berger and J. Oliger, “Adaptive Mesh Refinement for Hyperbolic Partial Differential Equations,” J. Comput. Phys. 53 (1984), 484 doi:10.1016/0021-9991(84)90073-1

4 Parameters

5 Interfaces

General

Implements:

carpetxregrid

Grid Variables

5.0.1 PUBLIC GROUPS





  Group Names     Variable Names   Details    




regrid_error centering centering={1 1 1}
regrid_error compact 0
description Regridding condition
dimensions 3
distribution DEFAULT
group type GF
tags checkpoint=”no”
timelevels 1
variable type REAL




6 Schedule

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

Storage

NONE

Scheduled Functions

CCTK_BASEGRID

  carpetxregrid_initerror

  initialize regridding error to zero

 

  Language: c
  Type: function
  Writes: carpetxregrid::regrid_error(everywhere)