chombo-discharge
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
EBGradient Class Reference

Class for computing gradients in an EBAMR context. More...

#include <CD_EBGradient.H>

Public Types

using CellLocation = Location::Cell
 Specification of cell-center or cell-centroid type of interpolation.
 

Public Member Functions

 EBGradient ()=delete
 Disallowed constructor.
 
 EBGradient (const EBGradient &a_other)=delete
 Disallowed copy constructor.
 
 EBGradient (const EBLevelGrid &a_eblg, const EBLevelGrid &a_eblgFine, const EBLevelGrid &a_eblgFiCo, const bool a_hasFine, const Real a_dx, const int a_refRat, const int a_order, const int a_weighting, const IntVect a_ghostVector) noexcept
 Full constructor. Calsl the define function. More...
 
virtual ~EBGradient () noexcept
 Destructor (does nothing)
 
virtual void define (const EBLevelGrid &a_eblg, const EBLevelGrid &a_eblgFine, const EBLevelGrid &a_eblgFiCo, const bool a_hasFine, const Real a_dx, const int a_refRat, const int a_order, const int a_weighting, const IntVect a_ghostVector) noexcept
 Define function. More...
 
virtual void computeLevelGradient (LevelData< EBCellFAB > &a_gradient, const LevelData< EBCellFAB > &a_phi) const noexcept
 Compute gradient using data on the input level only. More...
 
virtual void computeNormalDerivative (LevelData< EBFluxFAB > &a_gradient, const LevelData< EBCellFAB > &a_phi) const noexcept
 Compute the gradient component which is normal to the face, using centered differencing. More...
 
virtual void computeAMRGradient (LevelData< EBCellFAB > &a_gradient, const LevelData< EBCellFAB > &a_phi, const LevelData< EBCellFAB > &a_phiFine) const noexcept
 Compute gradient using two-level stencils (matching at EBCF). More...
 

Protected Member Functions

virtual void defineLevelStencils () noexcept
 Define level stencils.
 
virtual void defineMasks (LevelData< FArrayBox > &a_coarMaskCF, LevelData< FArrayBox > &a_coarMaskInvalid) noexcept
 Make masks. More...
 
virtual void defineIteratorsEBCF (const LevelData< FArrayBox > &a_coarMaskCF, const LevelData< FArrayBox > &a_coarMaskInvalid) noexcept
 Define iterators and cells that need modified stencils. More...
 
virtual void defineStencilsEBCF (const LevelData< FArrayBox > &a_coarMaskInvalid) noexcept
 Define stencils for interpolation across the EBCF refinement boundary. More...
 
virtual void defineBuffers () noexcept
 Define buffer data.
 
virtual bool getFiniteDifferenceStencil (VoFStencil &a_stencil, const VolIndex &a_vof, const EBISBox &a_ebisBox, const DenseIntVectSet &a_invalidRegion, const Real a_dx) const noexcept
 Get a finite difference stencil, assuming that the data is cell-centered. More...
 
virtual bool getLeastSquaresStencil (VoFStencil &a_stencilCoar, VoFStencil &a_stencilFine, const VolIndex &a_vofCoar, const CellLocation &a_dataLocation, const EBISLayout &a_ebislCoar, const EBISLayout &a_ebislFine, const DataIndex &a_dit, const DenseIntVectSet &a_validCellsCoar, const DenseIntVectSet &a_validCellsFine, const Real &a_dxCoar, const Real &a_dxFine, const int &a_order, const int &a_weight) const noexcept
 Build a gradient stencil using least squares. More...
 
virtual bool isFiniteDifferenceStencilValid (const IntVect &a_ivCoar, const EBISBox &a_ebisBox, const FArrayBox &a_invalidRegion) const noexcept
 Check if a cell can produce valid finite difference stencils. More...
 
virtual void makeAggStencils () noexcept
 Turn raw stencils into optimized AggStencils.
 

Protected Attributes

CellLocation m_dataLocation
 How to interpret data locations.
 
EBLevelGrid m_eblg
 Grids.
 
EBLevelGrid m_eblgFine
 Fine grids.
 
EBLevelGrid m_eblgFiCo
 Refined coarse grids.
 
bool m_isDefined
 Is defined or not.
 
bool m_hasFine
 True if we have a finer level (m_eblgFine is defined)
 
bool m_hasEBCF
 True if we have EBCF crossings that require special stencils.
 
Real m_dx
 Resolution on this level.
 
Real m_dxFine
 Resolution on finer level.
 
int m_order
 Desired order for least squares stencils.
 
int m_weighting
 Weight (for least squares)
 
int m_refRat
 Refinement factor between fine and coarse level.
 
IntVect m_ghostVector
 Number of ghost cells in incoming data holders.
 
Copier m_copier
 Pre-built copier for making copying from m_eblg to m_eblgFiCo go faster.
 
LayoutData< BaseIVFAB< VoFStencil > > m_levelStencils
 Stencils for boundaries and cut-cells. More...
 
LayoutData< BaseIVFAB< VoFStencil > > m_ebcfStencilsCoar
 Part of EBCF gradient stencil which reaches into the coarse level.
 
LayoutData< BaseIVFAB< VoFStencil > > m_ebcfStencilsFine
 Part of EBCF gradient stencil which reaches into the coarse level.
 
LayoutData< RefCountedPtr< AggStencil< EBCellFAB, EBCellFAB > > > m_aggLevelStencils [SpaceDim]
 AggStencils for boundaries and cut-cells. Provides faster application of m_levelStencils. More...
 
LayoutData< VoFIterator > m_levelIterator
 Iterator for boundary cells (either domain or EB) More...
 
LayoutData< VoFIterator > m_ebcfIterator
 Iterator for EBCF cells. More...
 

Static Protected Attributes

static constexpr int m_comp = 0
 Scalar component to reach into.
 
static constexpr int m_nComp = 1
 Number of components that are supported.
 

Detailed Description

Class for computing gradients in an EBAMR context.

Although computing the gradient might seem like an easy thing to do, the presence of a coarse-fine boundary together with an EB complicates both the stencil availability and the consistent handling of the gradient on the coarse level. This class introduces a two-level view of such stencil computations. This class uses regular second order finite differencing in regular regions, including those covered by a finer level. Near the EB, however, the stencil might reach into cut-cells that are covered by the finer level. The invalid data might be filled with bogus data, or at the very best coarsened from the fine level. Since there is no consistent way of doing that coarsening (both conserative and averaging make sense), this class switches to a least squares based approach for such cases. In those particular corner cases we only reach into valid regions in the domain. Because of that, the directional derivatives in those cells are in the form

 d(phi)/dx = sum(vofCoar) w(vofCoar)*phi(vofCoar) + sum(vofFine)[w(vofFine)*phi(vofFine)]

i.e., the gradient is a two-level stencil.

Near the domain boundaries this routine switches to first order stencils.

Note
If there is no finer level, this class will compute regular second-order stencils away from the EB and switch to compact width-one stencils if there are not enough cells available near the EB.
This class requires at least one ghost cell.

Constructor & Destructor Documentation

◆ EBGradient()

EBGradient::EBGradient ( const EBLevelGrid &  a_eblg,
const EBLevelGrid &  a_eblgFine,
const EBLevelGrid &  a_eblgFiCo,
const bool  a_hasFine,
const Real  a_dx,
const int  a_refRat,
const int  a_order,
const int  a_weighting,
const IntVect  a_ghostVector 
)
noexcept

Full constructor. Calsl the define function.

Parameters
[in]a_eblgGrids
[in]a_eblgFineFine grids
[in]a_eblgFiCoRefinement of coarse grids
[in]a_hasFineHas fine level or not
[in]a_dxResolution
[in]a_refRatRefinement ratio
[in]a_orderInterpolation order for modified gradients.
[in]a_weightingWeighting factor least squares.
[in]a_ghostVectNumber of ghost cells in the input data

Member Function Documentation

◆ computeAMRGradient()

void EBGradient::computeAMRGradient ( LevelData< EBCellFAB > &  a_gradient,
const LevelData< EBCellFAB > &  a_phi,
const LevelData< EBCellFAB > &  a_phiFine 
) const
virtualnoexcept

Compute gradient using two-level stencils (matching at EBCF).

Parameters
[out]a_gradientGradient of input scalar
[in]a_phiInput scalar
[in]a_phiFineInput scalar on finer level.

◆ computeLevelGradient()

void EBGradient::computeLevelGradient ( LevelData< EBCellFAB > &  a_gradient,
const LevelData< EBCellFAB > &  a_phi 
) const
virtualnoexcept

Compute gradient using data on the input level only.

Parameters
[out]a_gradientGradient of input scalar
[in]a_phiInput scalar

◆ computeNormalDerivative()

void EBGradient::computeNormalDerivative ( LevelData< EBFluxFAB > &  a_gradient,
const LevelData< EBCellFAB > &  a_phi 
) const
virtualnoexcept

Compute the gradient component which is normal to the face, using centered differencing.

If the face is oriented along dir, this computes the dir-component of the gradient using centered differences on the face. This routine is useful after e.g. averaging a cell-centered gradient to faces (in order to shrink the stencil).

Parameters
[in,out]a_gradientGradient of input scalar
[in]a_phiInput scalar

◆ define()

void EBGradient::define ( const EBLevelGrid &  a_eblg,
const EBLevelGrid &  a_eblgFine,
const EBLevelGrid &  a_eblgFiCo,
const bool  a_hasFine,
const Real  a_dx,
const int  a_refRat,
const int  a_order,
const int  a_weighting,
const IntVect  a_ghostVector 
)
virtualnoexcept

Define function.

Parameters
[in]a_eblgGrids
[in]a_eblgFineFine grids
[in]a_eblgFiCoRefinement of coarse grids
[in]a_hasFineHas fine level or not
[in]a_dxResolution
[in]a_refRatRefinement ratio
[in]a_orderInterpolation order for modified gradients.
[in]a_weightingWeighting factor least squares.
[in]a_ghostVectNumber of ghost cells in the input data

◆ defineIteratorsEBCF()

void EBGradient::defineIteratorsEBCF ( const LevelData< FArrayBox > &  a_coarMaskCF,
const LevelData< FArrayBox > &  a_coarMaskInvalid 
)
protectedvirtualnoexcept

Define iterators and cells that need modified stencils.

Parameters
[in]a_coarMaskCFMask for CF region on the coarse layout.
[in]a_coarMaskInvalidMask for invalid regions on the coarse layout.

◆ defineMasks()

void EBGradient::defineMasks ( LevelData< FArrayBox > &  a_coarMaskCF,
LevelData< FArrayBox > &  a_coarMaskInvalid 
)
protectedvirtualnoexcept

Make masks.

Parameters
[out]a_coarMaskCFMask holding a value of 1 in coarse cells that live on the refinement boundary.
[out]a_coarMaskInvalidMask holding a value of 1 in coarse cells that are covered by a finer grid level.

◆ defineStencilsEBCF()

void EBGradient::defineStencilsEBCF ( const LevelData< FArrayBox > &  a_coarMaskInvalid)
protectedvirtualnoexcept

Define stencils for interpolation across the EBCF refinement boundary.

Parameters
[in]a_bufferCoarMaskInvalidMap of coarse cells that are covered by finer cells.

◆ getFiniteDifferenceStencil()

bool EBGradient::getFiniteDifferenceStencil ( VoFStencil &  a_stencil,
const VolIndex &  a_vof,
const EBISBox &  a_ebisBox,
const DenseIntVectSet &  a_invalidRegion,
const Real  a_dx 
) const
protectedvirtualnoexcept

Get a finite difference stencil, assuming that the data is cell-centered.

Parameters
[out]a_stencilFinite difference stencil.
[in]a_vofGrid cell
[in]a_ebisBoxEBISBox
[in]a_invalidRegionMap of cells that can/can't be used.
[in]a_dxGrid resolution

◆ getLeastSquaresStencil()

bool EBGradient::getLeastSquaresStencil ( VoFStencil &  a_stencilCoar,
VoFStencil &  a_stencilFine,
const VolIndex &  a_vofCoar,
const CellLocation a_dataLocation,
const EBISLayout &  a_ebislCoar,
const EBISLayout &  a_ebislFine,
const DataIndex &  a_dit,
const DenseIntVectSet &  a_validCellsCoar,
const DenseIntVectSet &  a_validCellsFine,
const Real &  a_dxCoar,
const Real &  a_dxFine,
const int &  a_order,
const int &  a_weight 
) const
protectedvirtualnoexcept

Build a gradient stencil using least squares.

Parameters
[out]a_stencilCoarCoarse-grid stencil
[out]a_stencilFineFine-grid stencil
[in]a_vofCoarVoF on the coarse level.
[in]a_dataLocationData location
[in]a_ebisBoxCoarCoarse grid EBISBox
[in]a_ebisBoxFineFine grid EBISBox
[in]a_validCellsCoarMap of cells that are valid on the coarse domain.
[in]a_validCellsFineMap of cells that are valid on the coarse domain.
[in]a_dxCoarGrid resolution on the coarse level
[in]a_dxFineGrid resolution on the fine level
[in]a_orderInterpolation order
[in]a_weightEquation weighting for least squares reconstruction.
Returns
Returns true if a stencil was found, in which case it is defined in a_stencilFine and a_stencilCoar.

◆ isFiniteDifferenceStencilValid()

bool EBGradient::isFiniteDifferenceStencilValid ( const IntVect &  a_ivCoar,
const EBISBox &  a_ebisBox,
const FArrayBox &  a_invalidRegion 
) const
protectedvirtualnoexcept

Check if a cell can produce valid finite difference stencils.

This will check for stencils for all vofs in a_ivCoar.

Parameters
[in]a_ivCoarCoarse grid cell.
[in]a_ebisBoxEBISBox
[in]a_invalidRegionMap of cells that are covered by a finer cell.

Member Data Documentation

◆ m_aggLevelStencils

LayoutData<RefCountedPtr<AggStencil<EBCellFAB, EBCellFAB> > > EBGradient::m_aggLevelStencils[SpaceDim]
protected

AggStencils for boundaries and cut-cells. Provides faster application of m_levelStencils.

Note
Lives on the coarse layout and only has one component.

◆ m_ebcfIterator

LayoutData<VoFIterator> EBGradient::m_ebcfIterator
mutableprotected

Iterator for EBCF cells.

Note
Lives on the coarse layout.

◆ m_levelIterator

LayoutData<VoFIterator> EBGradient::m_levelIterator
mutableprotected

Iterator for boundary cells (either domain or EB)

Note
Lives on the coarse layout.

◆ m_levelStencils

LayoutData<BaseIVFAB<VoFStencil> > EBGradient::m_levelStencils
protected

Stencils for boundaries and cut-cells.

Note
Lives on the coarse layout.

The documentation for this class was generated from the following files: