Chombo + EB + MF
3.2
|
Interpolate from coarse cells to valid fine cells on mapped grids. More...
#include <FourthOrderMappedFineInterp.H>
Public Member Functions | |
FourthOrderMappedFineInterp (const int a_degree, const int a_nComp) | |
Non-defining construction. More... | |
FourthOrderMappedFineInterp (const int a_degree, const int a_nComp, const IntVect &a_refRatio, const RealVect &a_h) | |
Constructor that initializes the stencils. More... | |
~FourthOrderMappedFineInterp () | |
Destructor. More... | |
virtual void | defineStencils (const IntVect &a_refRatio, const RealVect &a_h) |
Define that initializes the stencils. More... | |
virtual void | defineGrids (const DisjointBoxLayout &a_FnGrid, const DisjointBoxLayout &a_CrGrid, const ProblemDomain &a_CrProblemDomain, const IntVect &a_FnInterpRadVec=IntVect::Zero, const bool a_willFillGhostsWithCrFnJU=true, const MultiBlockLevelGeom *const a_mbgeoPtr=0) |
Define that allocates data for coarse representations of the fine grid. More... | |
virtual void | defineCrFnJ (const LevelData< FArrayBox > &a_CrJ) |
Define that saves the coarse <J> on the coarsened-fine layout. More... | |
virtual void | defineCFInterface (LevelGridMetrics *const a_CrMetricsPtr) |
Define that initializes the coarse-fine interface for filling ghosts. More... | |
virtual void | interpToFine (LevelData< FArrayBox > &a_FnLevJU, const LevelData< FArrayBox > &a_FnLevJ, const LevelData< FArrayBox > &a_CrLevU, const LevelData< FArrayBox > &a_CrLevJU, LevelGridMetrics *const a_CrMetricsPtr, const Interval &a_vectorIntv) |
Interpolate from a coarse to fine level on a mapped grid. More... | |
void | fillGhosts (LevelData< FArrayBox > &a_FnLevU, LevelData< FArrayBox > &a_FnLevJU, const LevelData< FArrayBox > &a_FnLevJ, const LevelData< FArrayBox > &a_CrLevData, const char *const a_CrDataType, const ProblemDomain &a_CrProblemDomain) |
Fill the invalid ghost cells on a mapped grid. More... | |
virtual void | fillGhosts (LevelData< FArrayBox > &a_FnLevU, LevelData< FArrayBox > &a_FnLevJU, const LevelData< FArrayBox > &a_FnLevJ, LevelGridMetrics *const a_CrMetricsPtr) |
Fill invalid ghost cells from preset coarsened-fine data on a mapped grid. More... | |
virtual void | interpCrFnToFine (LevelData< FArrayBox > &a_FnLevJU, const LevelData< FArrayBox > &a_FnLevJ, const DisjointBoxLayout &a_CrFnGrid, const LevelData< FArrayBox > &a_CrFnLevU, const LevelData< FArrayBox > &a_CrFnLevJU, LevelGridMetrics *const a_CrMetricsPtr) const |
Interpolate from a coarsened-fine to fine level on a mapped grid. More... | |
int | interpToFine (FArrayBox &a_FnFabJU, const FArrayBox &a_FnFabJ, const Box &a_CrBox, const FArrayBox &a_CrFabU, const FArrayBox &a_CrFabJU, const ProblemDomain &a_CrProblemDomain) const |
Interpolate from a coarse to fine box on a mapped grid. More... | |
void | fillGhosts (FArrayBox &a_FnFabU, FArrayBox &a_FnFabJU, const FArrayBox &a_FnFabJ, const IntVectSet &a_CrCells, const BaseFab< int > &a_CrCellsArIdx, const FArrayBox &a_CrFabU, const ProblemDomain &a_CrProblemDomain) const |
Fill any ghost cells on a finer mesh. More... | |
bool | isStencilDefined () const |
True if stencil defined. More... | |
bool | isGridDefined () const |
True if coarsend-fine grid data defined. More... | |
bool | isCFInterfaceDefined () const |
True if coarse-fine interface defined. More... | |
bool | isCrFnJDefined () const |
True if coarse-fine <J> defined. More... | |
bool | properNesting (const DisjointBoxLayout &a_CrBoxes, const DisjointBoxLayout &a_CrFnBoxes, LevelGridMetrics *const a_CrMetricsPtr) const |
Check for proper nesting of the fine level in the coarse level. More... | |
virtual LevelData< FArrayBox > & | presetCrFnLevU () |
Preset the coarsened-fine <U> externally. More... | |
virtual LevelData< FArrayBox > & | presetCrFnLevJU () |
Preset the coarsened-fine <JU> externally. More... | |
virtual void | presetCrFnLevU (const LevelData< FArrayBox > &a_CrLevU, const Interval &a_vectorIntv) |
Preset the coarsened-fine <U> from coarse level data. More... | |
virtual void | invalidateCrFnLevData () |
Invalidate the CrFn data, both <U> and <JU> More... | |
const IntVect & | CrFnNumGhost () const |
Get the number of ghosts used to build the coarsened-fine data. More... | |
int | nComp () const |
Return the number of components. More... | |
Protected Types | |
enum | CrFnStatus { CrFnStatusInvalid = 0, CrFnStatusHaveJU = 1, CrFnStatusHaveU = 2 } |
Status of internal coarsened-fine data. More... | |
Protected Member Functions | |
bool | isMultiblock () const |
Is this a multiblock grid. More... | |
Private Member Functions | |
FourthOrderMappedFineInterp (const FourthOrderMappedFineInterp &) | |
FourthOrderMappedFineInterp & | operator= (const FourthOrderMappedFineInterp &) |
void | selectStencil (const IntVect a_center, const ProblemDomain &a_CrProblemDomain, int &a_iStencil, CoordTransform &a_ctStoP, CoordTransform &a_ctPtoS, IntVect &a_offset, IntVect &a_fineSmlEnd) const |
void | sortEachSetDx (int *const a_a, int *const a_b) const |
Sort sets of dimensions with the same mesh spacing. More... | |
int | offset2Key (const int *const a_offsets) const |
Get the stencil key from a list of offsets. More... | |
void | loadAvgXipA (Real *a_A, const RealVect &a_dxi, const RealVect a_h) const |
Load for all p. More... | |
void | loadAvgXiKpA (Real *a_A, const RealVect &a_dxi, const RealVect a_h) const |
Load for all p, evaluated with K. More... | |
void | loadAvgGradXip (Real *a_gradXip, const RealVect &a_dxi, const RealVect a_h) const |
Load gradients of for all p. More... | |
Interpolate from coarse cells to valid fine cells on mapped grids.
This class is used to interpolate the solution from coarse cells to valid fine cells on mapped grids using a constrained least-squares procedure. We solve a least-squares system for the coefficients of a polynomial interpolant
subject to the constraint
Given this interpolant, we can construct on the control volumes at level .
The details of the method are described in the Chombo document titled "Fourth-order conservation law example"
Implementation
To compute the coefficients, we solve the system
where is the lenM x lenN coefficient matrix of . lenM is the number of equations (number of cells in the stencil, the maximum value is for the interior stencil where and lenN is the number of powers of a displacement given by 0 = binomial(degree + SpaceDim, SpaceDim) where degree is the order of interpolation (i.e., 3 for a cubic polynomial and fourth-order interpolation). We solve for coeffients where is the constraint equation shown above. You will see this notation in the code, e.g, A, LSx, LSBu, LSbl, etc. Implementation is broken down into two parts. During construction, data is initialized that is valid for any boxes with the same mesh spacing and refinement ratios. Specifically, this is A and the displacements in the fine cells. Then, the member function, 'interpolate', will then interpolate everywhere on a coarse box.
The solution can be achieved using the LAPACK [S|D]GGLSE routine or an internal method which solves the linear system using a Cholesky factoriza- tion. Define statements in the Fortran routine 'maplsinterp' are used to select the method. The internal method is faster by a factor of about 4 for 2 components in the solution and should be even faster for more components. If both are used, the results are compared to some tolerance.
Stencil
The standard interior stencil has an inner box with size 3 and outer cells added in each dimension. See the Chombo doc mentioned above for more details and boundary stencils. The maximum stencil extent is shown below when cell 'i' is adjacent to the boundary. The encroachment of the wall in this example is by two cells relative to cell 'i' in the interior stencil. We label this as a "stencil offset from interior" of 2 in this direction, (2, 0). In this fashion, we can mark all the possible stencils.
* +---+ +---+\\ * | | | |\\ * +===========+ +===========+\\ * H | | H H | | H\\ * +---H---+---+---H---+ +---H---+---+---H\\ * | H | i | H | | H | | i H\\ * +---H---+---+---H---+ +---H---+---+---H\\ * H | | H H | | H\\ * +===========+ +===========+\\ * | | | |\\ * +---+ +---+\\ * <---2--> stencil extent <-----3----> max stencil extent *
The stencils along with the coefficient matrices are stored during construction. To minimize the required memory, symmetric stencils are only stored once and coordinate transformations are used during actual interpolation. In the above example, a wall on the left would produce an identical but reflected stencil. If dx = dy, then walls on the top and bottom would also form the same stencil with some rotational similarity. Without any symmetry, the number of required stencils is given by . By exploiting symmetry in a given direction (quadrant), the number of stencils is . By exploiting symmetry between directions with the same mesh spacing, the number of stencils is binomial(SpaceDim + 2, 2). This has a dramatic effect at higher dimensions. At 6 dimensions, the memory required for 64 bit storage of matrix A are 7.246 GiB, 346 MiB, and 13 MiB, respectively. For 3 dimensions, this is 644 KiB, 139 KiB, and 52 KiB, respectively. All possible symmetries are exploited herein, both within a direction and between directions with the same mesh spacing.
|
protected |
FourthOrderMappedFineInterp::FourthOrderMappedFineInterp | ( | const int | a_degree, |
const int | a_nComp | ||
) |
Non-defining construction.
FourthOrderMappedFineInterp::FourthOrderMappedFineInterp | ( | const int | a_degree, |
const int | a_nComp, | ||
const IntVect & | a_refRatio, | ||
const RealVect & | a_h | ||
) |
Constructor that initializes the stencils.
FourthOrderMappedFineInterp::~FourthOrderMappedFineInterp | ( | ) |
Destructor.
|
private |
|
private |
|
virtual |
Define that initializes the stencils.
|
virtual |
Define that allocates data for coarse representations of the fine grid.
|
virtual |
Define that saves the coarse <J> on the coarsened-fine layout.
|
virtual |
Define that initializes the coarse-fine interface for filling ghosts.
|
virtual |
Interpolate from a coarse to fine level on a mapped grid.
void FourthOrderMappedFineInterp::fillGhosts | ( | LevelData< FArrayBox > & | a_FnLevU, |
LevelData< FArrayBox > & | a_FnLevJU, | ||
const LevelData< FArrayBox > & | a_FnLevJ, | ||
const LevelData< FArrayBox > & | a_CrLevData, | ||
const char *const | a_CrDataType, | ||
const ProblemDomain & | a_CrProblemDomain | ||
) |
Fill the invalid ghost cells on a mapped grid.
|
virtual |
Fill invalid ghost cells from preset coarsened-fine data on a mapped grid.
|
virtual |
Interpolate from a coarsened-fine to fine level on a mapped grid.
int FourthOrderMappedFineInterp::interpToFine | ( | FArrayBox & | a_FnFabJU, |
const FArrayBox & | a_FnFabJ, | ||
const Box & | a_CrBox, | ||
const FArrayBox & | a_CrFabU, | ||
const FArrayBox & | a_CrFabJU, | ||
const ProblemDomain & | a_CrProblemDomain | ||
) | const |
Interpolate from a coarse to fine box on a mapped grid.
void FourthOrderMappedFineInterp::fillGhosts | ( | FArrayBox & | a_FnFabU, |
FArrayBox & | a_FnFabJU, | ||
const FArrayBox & | a_FnFabJ, | ||
const IntVectSet & | a_CrCells, | ||
const BaseFab< int > & | a_CrCellsArIdx, | ||
const FArrayBox & | a_CrFabU, | ||
const ProblemDomain & | a_CrProblemDomain | ||
) | const |
Fill any ghost cells on a finer mesh.
|
inline |
|
inline |
True if coarsend-fine grid data defined.
References m_defined.
Referenced by CrFnNumGhost(), presetCrFnLevJU(), and presetCrFnLevU().
|
inline |
True if coarse-fine interface defined.
References m_defined.
|
inline |
True if coarse-fine <J> defined.
Must be defined to fill ghosts using 'fillGhostsFromCrJU'
References m_defined.
bool FourthOrderMappedFineInterp::properNesting | ( | const DisjointBoxLayout & | a_CrBoxes, |
const DisjointBoxLayout & | a_CrFnBoxes, | ||
LevelGridMetrics *const | a_CrMetricsPtr | ||
) | const |
Check for proper nesting of the fine level in the coarse level.
Preset the coarsened-fine <U> externally.
This returns the coarsened-fine representation and you have to do the copyTo externally
References CH_assert, CrFnStatusHaveU, isGridDefined(), m_CrFnLevU, and m_CrFnStatus.
Preset the coarsened-fine <JU> externally.
This returns the coarsened-fine representation and you have to do the copyTo externally
References CH_assert, CrFnStatusHaveJU, isGridDefined(), m_CrFnLevJU, and m_CrFnStatus.
|
virtual |
Preset the coarsened-fine <U> from coarse level data.
|
inlinevirtual |
Invalidate the CrFn data, both <U> and <JU>
References CrFnStatusInvalid, and m_CrFnStatus.
|
inline |
Get the number of ghosts used to build the coarsened-fine data.
References CH_assert, isGridDefined(), and m_CrFnNumGhost.
|
inline |
Return the number of components.
References m_nComp.
|
private |
|
private |
Sort sets of dimensions with the same mesh spacing.
|
private |
Get the stencil key from a list of offsets.
|
private |
Load for all p.
|
private |
Load for all p, evaluated with K.
|
private |
Load gradients of for all p.
|
inlineprotected |
const int FourthOrderMappedFineInterp::m_degree |
Degree of interpolating polynomial.
const int FourthOrderMappedFineInterp::m_stencilExtent |
Maximum extent of interior stencil. Hard coded as 2.
const int FourthOrderMappedFineInterp::m_nComp |
Number of components for <U> and <JU>
Referenced by nComp().
IntVect FourthOrderMappedFineInterp::m_refRatio |
Refinement ratios between the levels.
int FourthOrderMappedFineInterp::m_numStencil |
Number of possible stencils.
int FourthOrderMappedFineInterp::m_numUniqueDx |
Number of different mesh spacing over all dimensions
int FourthOrderMappedFineInterp::m_uniqueDx[SpaceDim] |
Marks sets of dimensions with the same mesh spacing
bool FourthOrderMappedFineInterp::m_defined[4] |
0 - stencil, 1 - grids, 2 - CF interface, 3 - coarsened-fine<J>
Referenced by isCFInterfaceDefined(), isCrFnJDefined(), isGridDefined(), and isStencilDefined().
bool FourthOrderMappedFineInterp::m_willFillGhostsWithCrFnJU |
T - expecting to fill ghosts from from a coarsened-fine <JU> as specified in defineGrids().
std::map<int, int> FourthOrderMappedFineInterp::m_mapStencilIndex |
Maps a key based on the stencil offset to a sequential index for a stencil
CHArray<IntVectSet, 1> FourthOrderMappedFineInterp::m_ivsStencilMask |
Masks for the various stencils.
CHArray<CHMatrix, 1, ArZeroCol, ArSp::ArrayOfMatrixAlloc> FourthOrderMappedFineInterp::m_At |
The transpose of matrix A for solving . I.e., the powers of the displacements to the neighbour cells. The 'm_At' for all stencils are stored in a continguous chunk of memory by the ArrayOfMatrixAlloc allocator
CHArray<Real, SpaceDim+1, ArRangeCol>* FourthOrderMappedFineInterp::m_fnXiLSx |
Fine displacements already multiplied by the solution to the constrained least-squares problem (LSx). Multiply by LSbl to get <U> in a fine cell.
CHArray<Real, SpaceDim+1, ArRangeCol>* FourthOrderMappedFineInterp::m_fnGradXiLSx |
Gradients of fine displacements already multiplied by the solution to the constrained least-squares problem (LSx). Multiply by LSbl to get the gradient of <U> in a fine cell.
CHArray<Real, SpaceDim+1, ArRangeCol> FourthOrderMappedFineInterp::m_avgXipFine |
Powers of displacements for fine cells
CHArray<Real, SpaceDim+1, ArRangeCol> FourthOrderMappedFineInterp::m_avgXiKpFine |
Powers of displacements for fine cells with constant added to impose constraint when filling ghosts
CHArray<Real, SpaceDim+1, ArRangeCol> FourthOrderMappedFineInterp::m_avgGradXipFine |
Gradients of 'm_avgXipFine'. This is stored linearly in each cell as (SpaceDim, p) with 'p' contiguous since fortran only supports rank 7 arrays (at least until F2008 becomes commonplace).
DisjointBoxLayout FourthOrderMappedFineInterp::m_CrFnGrid |
The coarsened-fine boxes.
<U> on a coarse representation of the fine mesh
Referenced by presetCrFnLevU().
<JU> on a coarse representation of the fine mesh
Referenced by presetCrFnLevJU().
<J> on a coarse representation of the fine mesh
Copier FourthOrderMappedFineInterp::m_copier |
Friendly neighbourhood copier for copying from Cr to CrFn
MultiBlockLevelCopierAverage FourthOrderMappedFineInterp::m_mbcp |
To copy information between diffferent layout across multiblock boundaries
IntVect FourthOrderMappedFineInterp::m_FnInterpRadVec |
Number of fine ghost cells that must be filled in each direction.
IntVect FourthOrderMappedFineInterp::m_CrInterpRadVec |
Number of coarse cells that underlie fine ghost cells in each direction
IntVect FourthOrderMappedFineInterp::m_CrFnNumGhost |
Number of layers of ghost cells required on the coarsened-fine mesh
Referenced by CrFnNumGhost().
LayoutData<IntVectSet> FourthOrderMappedFineInterp::m_CrFnFillInterp |
Coarse cells in which to interpolate to fill fine ghost cells
LayoutData<BaseFab<int> > FourthOrderMappedFineInterp::m_ArIdxFillInterp |
Box describing the fine cells that need to be filled in a coarse cell. Max size is n_{ref}^{l}
int FourthOrderMappedFineInterp::m_numCrFnFillGhost |
Total number of coarse cells used to fill fine ghost cells on this processor (this is actually a count of total cells, not layers like numGhost usually is)
int FourthOrderMappedFineInterp::m_CrFnStatus |
Status of coarsened-fine data. We may know JU, U, or nothing. This is kept consistent with what MappedLevelData knows about the coarser data
Referenced by invalidateCrFnLevData(), presetCrFnLevJU(), and presetCrFnLevU().
bool FourthOrderMappedFineInterp::m_isMultiblock |
T - A multiblock coordinates system.
Referenced by isMultiblock().