LevelGridMetrics Class Reference

Detailed Description

Grid metrics for a level.

This class adds infrastructure for mapped grids to the fourth-order Cartesian AMRLevel class. The interface closely follows that of AMRLevel. Typically this class is a member of the user's derived AMRLevel and the member functions of LevelGridData should be called from member functions of the derived AMRLevel that have the same name.

This class provides m_N, the metric terms on each face, and m_J, the determinant (physical cell volume divided by computational cell volume). These quantities are appropriately maintained during all aspects of an AMR solution.

GHOSTS --- The determinants, (J), are defined on all ghost cells at the domain interior and 1 layer of ghost cells outside a non-periodic domain. Hence, gradients of J are available everywhere an application may store data. To achieve this, it is assumed that the metrics can be evaluated everywhere in . HOWEVER, metrics that are consistent between levels are only maintained in the valid region of the finer level. A valid cell on a coarse level will have metrics computed separately from any overlapping ghost cells from a finer level (i.e., the volumes of the fine ghost cells may not sum to the volume of the valid coarse cell). Consistency between levels everywhere could be achieved by treating all ghost cells as part of the valid region --- this would simply (probably simply) require some modifications to the "averagers". However we do not do this because:

it breaks a consistent definition of valid/invalid

there is no requirement for conservation in ghost cells since they are only used for gradient reconstruction, limiting, etc.

Any ghost cell that is covered by a valid cell on that level is consistent with the metrics from any finer level by means of the copiers (used in the averagers) copying to both the invalid and valid regions of a destination.

Transverse terms in N are determined only on the faces of grow(N.box(), -1) if obtained by averaging, i.e., on one less layer than where the normal components are known. If obtained by analytic methods, they are available everywhere.

Normally, N is calculated using script N to ensure freestream preservation. But in some cases, e.g., a 2-D solution on the surface of a sphere, there is no definition of script N. In those cases, m_useScriptN should be set to false and N will be calculated and averaged directly. The averaging ensures conservation but freestream-preservation is sacrificed. The value of m_useScriptN is obtained from the MultiBlockCoordSys and should be set to 'false' in the constructor of coordinate systems derived from class MultiBlockCoordSys. Otherwise, by default, it is set to true.

The following routines should be called from the corresponding routines with the same name derived AMRLevel:

initialGrid

postInitialGrid

postTimeStep

preRegrid

regrid

Setup for the class is as follows:

Call define to setup the class members -- metrics are still undefined.

Optionally call initialGrid to set the new box layout on a level. This can be deferred until postInitialGrid if desired.

Call postInitialGrid to set the new box layout (if not done in previous step) and define the metrics.

During a run, be sure to:

Call postTimeStep to average down the metric terms from finer levels. This only has an effect if they changed on the finer level

For a regrid do the following:

Call preRegrid to compute the new metrics and correct the solution on the old mesh to the metrics of the new mesh (snapback).

Optionally call regrid to interpolate from the coarse mesh to the new fine mesh. This can be done is user code but must use FourthOrderMappedFineInterp to ensure a conservative and free-stream preserving interpolation on the mapped grid.

Note:

To facilitate products that involve gradients, the metrics (N) are determined on the faces of boxes with size ghostBox+2. This is labeled an 'NReqGhostBox' herein. At domain boundaries, the boxes for 'N' extend by 2 cells outside the physical domain and it is assumed that the mappings exist there. The determinants (J) are determined on the cells of boxes with size ghostBox+1. This is labeled a 'JReqGhostBox' herein. At domain boundaries, the boxes for 'J' extends by 1 cell outside the physical domain

Averages of fluxes. Most of the fluxes, <F>\ are stored as average quantities to be applied to a face and do not include area information. I.e., the actual flux across a 2-D face is Hence when correcting from fine to coarse, you want to average the fine <F> and then muliply by the area of the coarse face (although in most equations, the area cancels out with another term). However, the , which are a type of flux, are stored differently in that they have already been multiplied by the length term (equivalent to in the example above). Hence, these fluxes needed to be summed when correcting from coarse to fine.

WARNING! If transverse components of <N> are computed analytically, they are only averaged down when finer levels have changed before entering a postTimeStep (along with normal components). Consequently, it is currently difficult to know if they have been computed or averaged from a finer level at any given point. But note that if transverse components of <N> are computed by averaging from normal components, then they should always be consistent. **FIXME -- probably the best fix is to only average the normal components if transverse are computed analytically.

Grids must have been defined for the interpolator. Returns a coarsening of 'this' level. I.e., 'this' is the fine level. Grids must have been defined for the interpolator. Returns a coarsening of 'this' level. I.e., 'this' is the fine level. Grids must have been defined for the interpolator. Copies the coarse data from 'this' level to the coarsened-fine representation in the interpolator. 'this' is the coarse level.

Invalidate the CrFn data, both <U> and <JU>\, used by the interpolator.

Grids must have been defined for the interpolator. Copies the coarse data from 'this' level to the coarsened-fine representation in the interpolator. 'this' is the coarse level. 'this' is the fine level. If data goes out-of-date on the coarser level, then the interpolator, for interpolating to 'this' level, has out-of-date coarsened-fine data. There must be a coarser level

Invalidate the CrFn data, both <U> and <JU>\, used by the interpolator.

'this' is the coarse level. If data goes out-of-date on 'this' level, then the interpolator, for interpolating to the next finer level, has out-of-date coarsened-fine data. You can invalidate even if there is no finer level.

Number of ghosts used to build the coarsened-fine data in the interpolator.

Parameters:

[in]

a_force

T - avoid assertion checking. F - (default)

Note:

The caller should ensure that a finer level exists if the assertion is disabled. Commonly, the return value is required inbetween initialGrid() and postInitialGrid() where the metrics have not yet been defined (so the assertion would fail) but the grid has been defined (so this value is known).

For some mappings, it is not possible to define scriptN. In those cases, N is calculated and averaged directly. The solution is conservative but freestream- preservation is lost across coarse- fine interfaces. T - Script N is used (default). F - Script N is not used. N is calculated directly and freestream preservation is lost