Chombo + EB + MF
3.2
|
Grid metrics for a level. More...
#include <LevelGridMetrics.H>
Public Types | |
enum | AgeType { AgeOld = 0, AgeNew = 1, AgeNum = 2 } |
Age of metric terms during a regrid. More... | |
enum | TransverseNOpType { TransverseNOpNone, TransverseNOpAnalytic, TransverseNOpAverage } |
Type of operation for computing transverse terms in N. More... | |
Public Member Functions | |
LevelGridMetrics (const int a_nComp, const int a_spaceOrder) | |
Constructor. More... | |
virtual | ~LevelGridMetrics () |
Destructor. More... | |
void | clear () |
Free memory. More... | |
bool | hasFiner () const |
Does a finer level exist? More... | |
bool | hasCoarser () const |
Does a coarser level exist? More... | |
void | define (AMRLevel *const a_AMRLevel, MultiBlockCoordSysFactory *const a_coordSysFact, LevelGridMetrics *const a_coarserLevelGridMetrics, const RealVect &a_dxVect, const IntVect &a_ghostVect, const TransverseNOpType a_transverseNOpType=TransverseNOpNone, const bool a_haveMultiBlockVectorData=true, const int a_numBlocks=1) |
Define the class. No metrics terms are yet available. More... | |
void | define (AMRLevel *const a_AMRLevel, MultiBlockCoordSys *const a_coordSys, LevelGridMetrics *const a_coarserLevelGridMetrics, const RealVect &a_dxVect, const IntVect &a_ghostVect, const TransverseNOpType a_transverseNOpType=TransverseNOpNone, const bool a_haveMultiBlockVectorData=true, const int a_numBlocks=1) |
Define the class. No metrics terms are yet available. More... | |
bool | metricsDefined () const |
Are the metrics defined on this level? More... | |
bool | didFinerChange () const |
Did the metrics change on the finer mesh? More... | |
const MultiBlockCoordSys & | getCoordSys () const |
Retrieve the multi-block coordinate system. More... | |
const NewCoordSys * | getCoordSys2 (const Box &box) const |
Get the coordinate system. More... | |
const NewFourthOrderCoordSys * | getCoordSys (const Box &box) const |
int | getBlock (const Box &a_box) const |
Get the block index. More... | |
const ProblemDomain & | blockDomain (const Box &a_box, const int a_numGhost=0) |
Get a problem domain representing a block. More... | |
const RealVect & | dxVect () const |
Get the computational mesh spacing. More... | |
void | postTimeStep () |
After a time step, average down ![]() ![]() | |
virtual void | initialGrid (const DisjointBoxLayout *const a_newGrid) |
Set up initial grid. More... | |
void | postInitialGrid (const DisjointBoxLayout *const a_newGrid) |
Set up the initial metric terms. More... | |
void | preRegrid (const int a_baseLevel, const DisjointBoxLayout &a_newGrid, const LevelData< FArrayBox > *const a_coarseUOldPtr, LevelData< FArrayBox > &a_UOld, LevelData< FArrayBox > &a_JUOld) |
Compute new metrics and correct the solution on the coarser meshes. More... | |
virtual void | regrid (LevelData< FArrayBox > &a_JU, const LevelData< FArrayBox > &a_CrU, const LevelData< FArrayBox > &a_CrJU, const Interval &a_vectorIntv) |
Regrid operations – performs a coarse to fine interpolation. More... | |
virtual void | fillFineGhostCells (LevelData< FArrayBox > &a_U, LevelData< FArrayBox > &a_JU, Real a_time=-1) |
Fill invalid fine ghost cells (with preset CrFnU) More... | |
void | computeValidU (LevelData< FArrayBox > &a_U, const LevelData< FArrayBox > &a_JU) |
Computes <U> in valid cells. More... | |
void | multiblockExchangeU (LevelData< FArrayBox > &a_U, const Interval &a_vectorIntv) const |
Exchange <U> across multiblock boundaries. More... | |
void | timeIntermediate (const TimeInterpolatorRK4 &a_timeInterpolator, const Real &a_timeInterpCoeff, const int &a_stage, const Interval &a_vectorIntv) |
Supports a call to TimeInterpolatorRK4::intermediate for multi-block grids. More... | |
LevelData< FArrayBox > & | presetCr2ThisInterpolatorCrFnLevU () |
Set the coarsened-fine <U> used by the interpolator (CrFn access) More... | |
LevelData< FArrayBox > & | presetCr2ThisInterpolatorCrFnLevJU () |
Set the coarsened-fine <JU> used by the interpolator (CrFn access) More... | |
void | presetThis2FnInterpolatorCrFnLevU (const LevelData< FArrayBox > &a_CrLevU, const Interval &a_vectorIntv) |
Set the coarsened-fine <U> used by the interpolator. More... | |
void | invalidateCr2ThisInterpolatorCrFnLevData () |
Invalidate the CrFn data, both <U> and <JU>\, used by the interpolator. More... | |
void | invalidateThis2FnInterpolatorCrFnLevData () |
Invalidate the CrFn data, both <U> and <JU>\, used by the interpolator. More... | |
const IntVect & | interpolatorCrFnNumGhost (const bool a_force=false) const |
Number of ghosts used to build the coarsened-fine data in the interpolator. More... | |
bool | isMultiblock () const |
Is this a multiblock grid. More... | |
Consistent access to structural boxes | |
There are several places to get the boxes and interators from but all should be the same. These functions provide consistent access with sizes relevant to the metrics. | |
const DisjointBoxLayout & | getBoxes () const |
Get the boxes. More... | |
DataIterator | getDataIterator () const |
Get a level iterator. More... | |
Box | resizeWithGhosts (const Box &box) const |
Resize a box to include the ghost cells. More... | |
virtual IntVect | getJReqGhostVect () const |
Determine the ghost vector required for ![]() | |
virtual IntVect | getNReqGhostVect () const |
Determine the ghost vector required for ![]() | |
Box | resizeWithJReqGhosts (const Box &box) const |
Resize a box to the size required for ![]() | |
Box | resizeWithNReqGhosts (const Box &box) const |
Resize a box to the size required for ![]() | |
Static Public Member Functions | |
static int | bufferSize4thO (const std::vector< int > &a_refRatio, const int a_maxLevel, const int a_numGhost) |
Compute the minimum grid buffer size for a fourth-order interpolation. More... | |
Public Attributes | |
LevelData< FluxBox > | m_N |
![]() | |
LevelData< FArrayBox > | m_J |
Protected Member Functions | |
void | defineMetrics () |
Completely define the metrics for this level. More... | |
void | undefineMetrics () |
Label this and all finer levels as having undefined metrics. More... | |
void | faceNormalN (LevelData< FluxBox > &a_N, const LevelData< CodimBox< FArrayBox > > &a_scrN) |
Compute ![]() ![]() | |
void | getN (LevelData< FluxBox > &a_N) |
Compute ![]() ![]() | |
void | faceTransverseN (LevelData< FluxBox > &a_N) |
Add transverse components to ![]() | |
void | getScriptN (LevelData< CodimBox< FArrayBox > > &a_scrN) |
Integrate ![]() | |
void | averageScriptN (const bool a_isBase, LevelData< CodimBox< FArrayBox > > &a_scrN) |
Average ![]() | |
void | averageN (const bool a_isBase, LevelData< FluxBox > &a_N) |
Average ![]() ![]() | |
void | getVolFlux (LevelData< FluxBox > &a_NtX, const LevelData< FluxBox > &a_N) |
Compute the volume flux. More... | |
virtual void | setAvgJfromNtX (LevelData< FluxBox > &a_NtX) |
Take divergence of ![]() | |
void | averageVolFlux (const bool a_isBase, LevelData< FluxBox > &a_NtX, const AgeType a_age) |
Average the volume flux ![]() | |
void | volFluxCascade () |
Compute ![]() | |
void | averageSnapbackSolFlux (const bool a_isBase, LevelData< FluxBox > &a_NtFDiff) |
Average the snapback solution flux, ![]() | |
virtual void | defineGrids (const DisjointBoxLayout &a_grids) |
Store the DisjointBoxLayout and define multiblock structures. More... | |
void | defineGridsNP (const DisjointBoxLayout &a_grids) |
Create a non-periodic DisjointBoxLayout. More... | |
Static Protected Member Functions | |
static int | verbosity () |
Static Protected Attributes | |
static int | s_verbosity |
Private Member Functions | |
LevelGridMetrics (const LevelGridMetrics &) | |
LevelGridMetrics & | operator= (const LevelGridMetrics &) |
Easier access to AMRLevel data | |
const ProblemDomain & | problemDomain () const |
int | level () const |
int | refRatio () const |
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:
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:
Setup for the class is as follows:
During a run, be sure to:
For a regrid do the following:
LevelGridMetrics::LevelGridMetrics | ( | const int | a_nComp, |
const int | a_spaceOrder | ||
) |
Constructor.
|
virtual |
Destructor.
|
private |
|
private |
void LevelGridMetrics::clear | ( | ) |
Free memory.
bool LevelGridMetrics::hasFiner | ( | ) | const |
Does a finer level exist?
bool LevelGridMetrics::hasCoarser | ( | ) | const |
Does a coarser level exist?
void LevelGridMetrics::define | ( | AMRLevel *const | a_AMRLevel, |
MultiBlockCoordSysFactory *const | a_coordSysFact, | ||
LevelGridMetrics *const | a_coarserLevelGridMetrics, | ||
const RealVect & | a_dxVect, | ||
const IntVect & | a_ghostVect, | ||
const TransverseNOpType | a_transverseNOpType = TransverseNOpNone , |
||
const bool | a_haveMultiBlockVectorData = true , |
||
const int | a_numBlocks = 1 |
||
) |
Define the class. No metrics terms are yet available.
void LevelGridMetrics::define | ( | AMRLevel *const | a_AMRLevel, |
MultiBlockCoordSys *const | a_coordSys, | ||
LevelGridMetrics *const | a_coarserLevelGridMetrics, | ||
const RealVect & | a_dxVect, | ||
const IntVect & | a_ghostVect, | ||
const TransverseNOpType | a_transverseNOpType = TransverseNOpNone , |
||
const bool | a_haveMultiBlockVectorData = true , |
||
const int | a_numBlocks = 1 |
||
) |
Define the class. No metrics terms are yet available.
|
inline |
Are the metrics defined on this level?
After preRegrid, this also indicates if a level is used.
|
inline |
Did the metrics change on the finer mesh?
|
inline |
|
inline |
|
inline |
[in] | box | Assigned to this box |
References getCoordSys().
|
inline |
Get the block index.
[in] | a_box | Assigned to this interior box |
|
inline |
Get a problem domain representing a block.
[in] | a_box | Assigned to this interior box |
[in] | a_numGhost | The number of ghosts that the box representing the block should be grown by before cropping. Cropping only occurs at boundaries defined by the physical domain |
References CH_assert, Box::define(), and grow().
|
inline |
Get the computational mesh spacing.
void LevelGridMetrics::postTimeStep | ( | ) |
After a time step, average down and
.
|
virtual |
Set up initial grid.
void LevelGridMetrics::postInitialGrid | ( | const DisjointBoxLayout *const | a_newGrid | ) |
Set up the initial metric terms.
void LevelGridMetrics::preRegrid | ( | const int | a_baseLevel, |
const DisjointBoxLayout & | a_newGrid, | ||
const LevelData< FArrayBox > *const | a_coarseUOldPtr, | ||
LevelData< FArrayBox > & | a_UOld, | ||
LevelData< FArrayBox > & | a_JUOld | ||
) |
Compute new metrics and correct the solution on the coarser meshes.
|
virtual |
Regrid operations – performs a coarse to fine interpolation.
|
virtual |
Fill invalid fine ghost cells (with preset CrFnU)
void LevelGridMetrics::computeValidU | ( | LevelData< FArrayBox > & | a_U, |
const LevelData< FArrayBox > & | a_JU | ||
) |
Computes <U> in valid cells.
|
static |
Compute the minimum grid buffer size for a fourth-order interpolation.
void LevelGridMetrics::multiblockExchangeU | ( | LevelData< FArrayBox > & | a_U, |
const Interval & | a_vectorIntv | ||
) | const |
Exchange <U> across multiblock boundaries.
void LevelGridMetrics::timeIntermediate | ( | const TimeInterpolatorRK4 & | a_timeInterpolator, |
const Real & | a_timeInterpCoeff, | ||
const int & | a_stage, | ||
const Interval & | a_vectorIntv | ||
) |
Supports a call to TimeInterpolatorRK4::intermediate for multi-block grids.
|
inline |
Get the boxes.
|
inline |
Get a level iterator.
References getBoxes().
Resize a box to include the ghost cells.
References grow().
|
inlinevirtual |
Determine the ghost vector required for .
This is +1 over the ghost box to allow for derivatives needed to manipulate products
References IntVect::Unit.
|
inlinevirtual |
Determine the ghost vector required for .
This is +2 over the ghost box to allow for tangential derivatives needed to compute the volume flux
References IntVect::Unit.
Resize a box to the size required for .
References grow().
Resize a box to the size required for .
References grow().
Set the coarsened-fine <U> used by the interpolator (CrFn access)
Grids must have been defined for the interpolator. Returns a coarsening of 'this' level to be filled externally using a copyTo. 'this' is the fine level. I.e., 'this' is the fine level.
References CH_assert.
Set the coarsened-fine <JU> used by the interpolator (CrFn access)
Grids must have been defined for the interpolator. Returns a coarsening of 'this' level to be filled externally using a copyTo. 'this' is the fine level. I.e., 'this' is the fine level.
References CH_assert.
|
inline |
Set the coarsened-fine <U> used by the interpolator.
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.
[in] | a_CrU | <U> on the coarse level |
[in] | a_vectorIntv | An interval in components of U consisting of vector data |
References CH_assert.
|
inline |
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
References CH_assert.
|
inline |
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.
|
inline |
Number of ghosts used to build the coarsened-fine data in the interpolator.
[in] | a_force | T - avoid assertion checking. F - (default) |
References CH_assert.
|
inline |
Is this a multiblock grid.
|
inline |
|
inlineprotected |
|
inlineprotected |
|
staticprotected |
|
protected |
Completely define the metrics for this level.
|
protected |
Label this and all finer levels as having undefined metrics.
|
protected |
Compute on the hyperfaces from
.
Compute on the hyperfaces from
.
Add transverse components to .
Integrate on each hyperedge.
|
protected |
Average .
Average directly if
doesn't exist.
|
protected |
Compute the volume flux.
Take divergence of to set m_J.
|
protected |
Average the volume flux .
|
protected |
Compute on all finer levels and average down.
|
protected |
Average the snapback solution flux, .
|
protectedvirtual |
Store the DisjointBoxLayout and define multiblock structures.
|
protected |
Create a non-periodic DisjointBoxLayout.
Physical cell volume divided by computational cell volume
|
protected |
Averager for . Only used if m_useScriptN == true
|
protected |
Averager for Only used if m_useScriptN == false
|
protected |
This averages the volume flux from a finer level. Averagers exist for old "AgeOld" and new "AgeNew" meshes during a regrid
|
protected |
Averager for the snapback solution flux. This averager only operates on the intersections of three layouts.
|
protected |
The multi-block coordinate system.
|
protected |
Grid metrics on the next finer level.
|
protected |
Grid metrics on the next coarser level
|
protected |
Ghost cell vector.
|
protected |
Grid layout.
|
protected |
Non-periodic grid layout. This is a shallow copy of m_grids, with a non- periodic problem domain and a new neighbor iterator if problemDomain() is periodic.
|
protected |
Mesh spacing in each direction.
|
protected |
Spatial-order of accuracy - must be 4.
|
protected |
Constrained least-squares interpolator for interpolating <JU> from coarse to fine meshes. 'This' mesh is the coarse mesh.
|
protected |
Representing only the block (it is assumed periodic boundaries are not used for multiblock)
|
protected |
Index of the cached block.
|
protected |
Number of ghosts that the cached block was grown by.
|
protected |
Topology of the multiblock layout.
|
protected |
To exchange information across multiblock boundaries
|
protected |
Flux-like register for resolving on faces at coarse- fine interfaces that overlap multiblock boundaries
|
protected |
Flux-like register for resolving on faces at coarse-fine interfaces that overlap multiblock boundaries
|
protected |
Type of operatation for computing transverse terms in N
|
protected |
T - The metrics on this level have changed
|
protected |
T - The metrics have been defined for this level
|
protected |
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
|
protected |
T - A multiblock coordinates system.
|
protected |
T - Space vector data will be exchanged across multiblock boundaries
|
staticprotected |