chombo-discharge
Loading...
Searching...
No Matches
PetscHelmholtzEBStencils Class Reference

Shared one-sided EB face stencils for the EB and jump boundary conditions of PetscHelmholtzOp. More...

#include <CD_PetscHelmholtzEBStencils.H>

Inheritance diagram for PetscHelmholtzEBStencils:

Public Member Functions

 PetscHelmholtzEBStencils () noexcept
 Default constructor. Must subsequently set the order and the weight, and call define.
virtual ~PetscHelmholtzEBStencils () noexcept
 Destructor.
 PetscHelmholtzEBStencils (const PetscHelmholtzEBStencils &a_other)=delete
 Disallowed copy constructor.
 PetscHelmholtzEBStencils (const PetscHelmholtzEBStencils &&a_other)=delete
 Disallowed move constructor.
PetscHelmholtzEBStencils & operator= (const PetscHelmholtzEBStencils &a_other)=delete
 Disallowed copy assignment operator.
PetscHelmholtzEBStencils & operator= (const PetscHelmholtzEBStencils &&a_other)=delete
 Disallowed move assignment operator.
virtual long long getNumCellsWithoutStencil () const noexcept
 Get the number of cut cells, summed over phases, levels and ranks, that have an EB face but no stencil.
virtual void setOrder (const int a_order) noexcept
 Set the order of the stencils.
virtual void setWeight (const int a_weight) noexcept
 Set the least-squares weighting.
virtual void clear () noexcept
 Release the stored stencils, the grids and the interpolators, so that the object can be defined again, e.g. after a regrid.
virtual void define (const RefCountedPtr< PetscGrid > &a_petscGrid, const Vector< MFMultigridInterpolator > &a_interpolators, const RealVect &a_probLo, const Vector< Real > &a_dx) noexcept
 Define over the AMR hierarchy, and compute the one-sided normal derivative stencils of every cut cell.

Protected Member Functions

virtual void getNormalDerivativeStencil (Real &a_boundaryWeight, PetscStencil &a_stencil, const int a_phase, const int a_level, const DataIndex &a_din, const VolIndex &a_vof) const noexcept
 Get the stored one-sided normal derivative at the EB face of a cut cell.
virtual void computeNormalDerivativeStencil (Real &a_boundaryWeight, PetscStencil &a_stencil, const int a_phase, const int a_level, const DataIndex &a_din, const VolIndex &a_vof) const noexcept
 Compute the one-sided normal derivative at the EB face of a cut cell.
virtual bool getLeastSquaresStencil (Real &a_boundaryWeight, PetscStencil &a_stencil, const int a_phase, const int a_level, const DataIndex &a_din, const VolIndex &a_vof, const VofUtils::Neighborhood a_neighborhood, const int a_order) const noexcept
 Try to compute the one-sided normal derivative at the EB face of a cut cell, for one neighbourhood and one order.
virtual RealVect getBoundaryPosition (const int a_phase, const int a_level, const DataIndex &a_din, const VolIndex &a_vof) const noexcept
 Get the physical position of the centroid of the EB face of a cut cell.

Protected Attributes

bool m_isDefined
 Is defined or not.
long long m_numCellsWithoutStencil
 Number of cut cells, summed over phases, levels and ranks, that have an EB face but no stencil.
bool m_verbose
 Verbose output or not.
int m_order
 Highest order of the stencils, or -1 if not set.
int m_weight
 Least-squares weighting, or -1 if not set.
RefCountedPtr< PetscGrid > m_petscGrid
 PETSc grid.
Vector< MFMultigridInterpolator > m_interpolators
 Coarse-fine ghost cell interpolators of both phases, on each level.
RealVect m_probLo
 Lower-left corner of the computational domain.
Vector< Real > m_dx
 Grid resolution on each level.
Vector< RefCountedPtr< LayoutData< BaseIVFAB< PetscStencil > > > > m_derivStencils [2]
 The stencils of the one-sided normal derivatives, over PETSc rows.
Vector< RefCountedPtr< LayoutData< BaseIVFAB< Real > > > > m_derivWeights [2]
 The weights w_B of the boundary value in the one-sided normal derivatives.

Detailed Description

Shared one-sided EB face stencils for the EB and jump boundary conditions of PetscHelmholtzOp.

For each cut cell of each phase, this class holds the one-sided normal derivative of phi at the EB face,

dphi/dn = w_B * phi_B + sum_i w_i * phi_i,

where phi_B is the value on the EB face, n points out of the cell (into the boundary, i.e. minus the EB normal), and the stencil is over PETSc rows of the cell's phase. phi is cell-centered.

The stencil is a weighted least-squares fit at the EB face centroid, with phi_B known, over the cells in a neighbourhood of the cut cell on its own level, within a radius equal to the order:

  • Cells that are PETSc rows are used as they are.
  • Coarse-fine ghost cells are used as well, and are replaced by their interpolation stencils from the EBMultigridInterpolator (PetscGrid::getPetscStencilWithGhostCells), which are over rows on this level and the next coarser one. The interpolator fills the ghost cells within its radius of a cut cell, so the order must not exceed that radius.
  • Cells covered by the next finer level are replaced by the finer cells under them that are PETSc rows.

Every cell of the neighbourhood enters the fit, as in FieldSolverGMG. The search tries the half-circle, quadrant and radius neighbourhoods, each from the order down to 1. A fit is accepted only if w_B > 0, i.e. if the normal derivative increases with the boundary value, as in FieldSolverGMG. If no fit is accepted, or if a cut cell has no EB normal, the cell has no flux through its EB face: its stencil is empty with w_B = 0. The stencils are computed once, in define, and contain neither the b-coefficient nor the face area.

PetscHelmholtzEBBC (electrode faces) and PetscHelmholtzJumpBC (interface faces) derive from this class and build their fluxes from these stencils.

Constructor & Destructor Documentation

◆ PetscHelmholtzEBStencils() [1/2]

PetscHelmholtzEBStencils::PetscHelmholtzEBStencils ( const PetscHelmholtzEBStencils & a_other)
delete

Disallowed copy constructor.

Parameters
[in]a_otherOther object

◆ PetscHelmholtzEBStencils() [2/2]

PetscHelmholtzEBStencils::PetscHelmholtzEBStencils ( const PetscHelmholtzEBStencils && a_other)
delete

Disallowed move constructor.

Parameters
[in]a_otherOther object

Member Function Documentation

◆ clear()

void PetscHelmholtzEBStencils::clear ( )
virtualnoexcept

Release the stored stencils, the grids and the interpolators, so that the object can be defined again, e.g. after a regrid.

The order and the weight are settings, and are kept.

Reimplemented in PetscHelmholtzSaturationChargeJumpBC.

◆ computeNormalDerivativeStencil()

void PetscHelmholtzEBStencils::computeNormalDerivativeStencil ( Real & a_boundaryWeight,
PetscStencil & a_stencil,
const int a_phase,
const int a_level,
const DataIndex & a_din,
const VolIndex & a_vof ) const
protectedvirtualnoexcept

Compute the one-sided normal derivative at the EB face of a cut cell.

Runs the neighbourhood and order search described for the class. If no stencil is found, w_B = 0 and the stencil is empty.

Parameters
[out]a_boundaryWeightWeight w_B of the boundary value phi_B
[out]a_stencilStencil over PETSc rows of the cell's phase
[in]a_phasePhase
[in]a_levelGrid level
[in]a_dinGrid index on the level
[in]a_vofCut cell

◆ define()

void PetscHelmholtzEBStencils::define ( const RefCountedPtr< PetscGrid > & a_petscGrid,
const Vector< MFMultigridInterpolator > & a_interpolators,
const RealVect & a_probLo,
const Vector< Real > & a_dx )
virtualnoexcept

Define over the AMR hierarchy, and compute the one-sided normal derivative stencils of every cut cell.

The order and the weight must be set first. Clears any previous definition first. Aborts if the order exceeds the radius within which the interpolators fill the ghost cells.

Parameters
[in]a_petscGridPETSc grid. Holds the grids on every level, their coarsenings and refinements, and the per-cell AMR information.
[in]a_interpolatorsCoarse-fine ghost cell interpolators of both phases, on each level. Entry 0 is not used.
[in]a_probLoLower-left corner of the computational domain
[in]a_dxGrid resolution on each level

Reimplemented in PetscHelmholtzNeumannEBBC.

◆ getBoundaryPosition()

RealVect PetscHelmholtzEBStencils::getBoundaryPosition ( const int a_phase,
const int a_level,
const DataIndex & a_din,
const VolIndex & a_vof ) const
protectedvirtualnoexcept

Get the physical position of the centroid of the EB face of a cut cell.

Parameters
[in]a_phasePhase
[in]a_levelGrid level
[in]a_dinGrid index on the level
[in]a_vofCut cell
Returns
Position of the EB face centroid.

◆ getLeastSquaresStencil()

bool PetscHelmholtzEBStencils::getLeastSquaresStencil ( Real & a_boundaryWeight,
PetscStencil & a_stencil,
const int a_phase,
const int a_level,
const DataIndex & a_din,
const VolIndex & a_vof,
const VofUtils::Neighborhood a_neighborhood,
const int a_order ) const
protectedvirtualnoexcept

Try to compute the one-sided normal derivative at the EB face of a cut cell, for one neighbourhood and one order.

Gathers the cells of the neighbourhood as described for the class, and fits them by least squares.

Parameters
[out]a_boundaryWeightWeight w_B of the boundary value phi_B
[out]a_stencilStencil over PETSc rows of the cell's phase
[in]a_phasePhase
[in]a_levelGrid level
[in]a_dinGrid index on the level
[in]a_vofCut cell
[in]a_neighborhoodNeighbourhood of the cut cell to take cells from
[in]a_orderOrder of the fit. Also the radius of the neighbourhood.
Returns
True if there were enough cells for the fit, it succeeded and w_B > 0, in which case a_boundaryWeight and a_stencil are set.

◆ getNormalDerivativeStencil()

void PetscHelmholtzEBStencils::getNormalDerivativeStencil ( Real & a_boundaryWeight,
PetscStencil & a_stencil,
const int a_phase,
const int a_level,
const DataIndex & a_din,
const VolIndex & a_vof ) const
protectedvirtualnoexcept

Get the stored one-sided normal derivative at the EB face of a cut cell.

Parameters
[out]a_boundaryWeightWeight w_B of the boundary value phi_B
[out]a_stencilStencil over PETSc rows of the cell's phase
[in]a_phasePhase
[in]a_levelGrid level
[in]a_dinGrid index on the level
[in]a_vofCut cell

◆ getNumCellsWithoutStencil()

long long PetscHelmholtzEBStencils::getNumCellsWithoutStencil ( ) const
virtualnoexcept

Get the number of cut cells, summed over phases, levels and ranks, that have an EB face but no stencil.

These cells have no flux through their EB face. Set by define.

Returns
The number of cut cells without a stencil.

◆ operator=() [1/2]

PetscHelmholtzEBStencils & PetscHelmholtzEBStencils::operator= ( const PetscHelmholtzEBStencils && a_other)
delete

Disallowed move assignment operator.

Parameters
[in]a_otherOther object
Returns
This object.

◆ operator=() [2/2]

PetscHelmholtzEBStencils & PetscHelmholtzEBStencils::operator= ( const PetscHelmholtzEBStencils & a_other)
delete

Disallowed copy assignment operator.

Parameters
[in]a_otherOther object
Returns
This object.

◆ setOrder()

void PetscHelmholtzEBStencils::setOrder ( const int a_order)
virtualnoexcept

Set the order of the stencils.

Parameters
[in]a_orderHighest order of the stencils. The search falls back to lower orders, down to 1.

◆ setWeight()

void PetscHelmholtzEBStencils::setWeight ( const int a_weight)
virtualnoexcept

Set the least-squares weighting.

Parameters
[in]a_weightExponent of the inverse-distance weighting in the least-squares fit.

Member Data Documentation

◆ m_derivStencils

Vector<RefCountedPtr<LayoutData<BaseIVFAB<PetscStencil> > > > PetscHelmholtzEBStencils::m_derivStencils[2]
protected

The stencils of the one-sided normal derivatives, over PETSc rows.

Indexed as [phase][level], with one stencil per cut cell of the phase.

◆ m_derivWeights

Vector<RefCountedPtr<LayoutData<BaseIVFAB<Real> > > > PetscHelmholtzEBStencils::m_derivWeights[2]
protected

The weights w_B of the boundary value in the one-sided normal derivatives.

Indexed as [phase][level], with one weight per cut cell of the phase.


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