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

Implementation of FieldSolver which uses multigrid. More...

#include <CD_FieldSolverMultigrid.H>

Inheritance diagram for FieldSolverMultigrid:
Inheritance graph
[legend]
Collaboration diagram for FieldSolverMultigrid:
Collaboration graph
[legend]

Public Member Functions

 FieldSolverMultigrid ()
 Weak constructor. More...
 
 FieldSolverMultigrid (const FieldSolverMultigrid &a_other)=delete
 Disallowed copy constructor. More...
 
 FieldSolverMultigrid (const FieldSolverMultigrid &&a_other)=delete
 Disallowed move constructor. More...
 
FieldSolverMultigridoperator= (const FieldSolverMultigrid &a_other)=delete
 Disallowed copy assignment operator. More...
 
FieldSolverMultigridoperator= (const FieldSolverMultigrid &&a_other)=delete
 Disallowed move assignment operator. More...
 
virtual ~FieldSolverMultigrid ()
 Constructor (does nothing)
 
virtual bool solve (MFAMRCellData &a_potential, const MFAMRCellData &a_rho, const EBAMRIVData &a_sigma, const bool a_zeroPhi=false) override
 Solves Poisson equation onto a_phi using a_rho and a_sigma as right-hand sides. More...
 
virtual void parseOptions () override
 Parse all class options from command-line or input script.
 
virtual void parseRuntimeOptions () override
 Parse runtime options from command line or input script.
 
virtual void computeElectricField (MFAMRCellData &a_E, const MFAMRCellData &a_potential) const override
 Compute the cell-centered electric field. More...
 
virtual void computeElectricField (MFAMRFluxData &a_E, const MFAMRCellData &a_potential) const override
 Compute the face-centered electric field. More...
 
virtual void computeElectricField (EBAMRCellData &a_E, const phase::which_phase a_phase, const MFAMRCellData &a_potential) const override
 Compute the cell-centered electric field on a specific phase. More...
 
virtual void computeElectricField (EBAMRFluxData &a_E, const phase::which_phase a_phase, const MFAMRCellData &a_potential) const override
 Compute the face-centered electric field on a specific phase. More...
 
virtual void preRegrid (const int a_lbase, const int a_oldFinestLevel) override
 Cache state before regridding. More...
 
virtual void regrid (const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
 Regrid method. More...
 
virtual void registerOperators () override
 Registers required operators for AMR for this class.
 
virtual void setupSolver () override
 Set up multigrid solver.
 
virtual void setSolverPermittivities (const MFAMRCellData &a_permittivityCell, const MFAMRFluxData &a_permittivityFace, const MFAMRIVData &a_permittivityEB) override
 Set new permittivities for the multigrid solver. More...
 
virtual Vector< long long > computeLoads (const DisjointBoxLayout &a_dbl, const int a_level) override
 Compute grid loads. More...
 
- Public Member Functions inherited from FieldSolver
 FieldSolver ()
 Constructor.
 
 FieldSolver (const FieldSolver &a_other)=delete
 Disallowed copy constructor. More...
 
 FieldSolver (const FieldSolver &&a_other)=delete
 Disallowed move constructor. More...
 
FieldSolveroperator= (const FieldSolver &a_other)=delete
 Disallowed copy assignment operator. More...
 
FieldSolveroperator= (const FieldSolver &&a_other)=delete
 Disallowed move assignment operator. More...
 
virtual ~FieldSolver ()
 Constructor.
 
virtual bool solve (const bool a_zeroPhi=false)
 Solve Poisson equation using m_potential, m_rho, and m_sigma. More...
 
virtual bool solve (MFAMRCellData &a_potential, const bool a_zerophi=false)
 Solve Poisson equation onto a_phi using m_rho, and m_sigma as right-hand sides. More...
 
virtual void computeElectricField ()
 Compute the cell-centered electric field. More...
 
virtual void allocate ()
 Allocates internal storage for FieldSolver. Derived classes may want to overwrite.
 
virtual void computeDisplacementField (MFAMRCellData &a_displacementField, const MFAMRCellData &a_electricField)
 Compute displacement field from the electric field. More...
 
virtual void deallocate ()
 Deallocate internal storage.
 
void setRho (const Real a_rho)
 Set space charge to constant value everywhere. More...
 
void setRho (const std::function< Real(const RealVect)> &a_rho)
 Set space charge to spatially dependent function. More...
 
void setSigma (const Real a_sigma)
 Set surface charge to specified value.
 
void setSigma (const std::function< Real(const RealVect)> &a_sigma)
 Set surface charge density to spatially dependent function. More...
 
void setComputationalGeometry (const RefCountedPtr< ComputationalGeometry > &a_computationalGeometry)
 Set the computational geometry. More...
 
void setAmr (const RefCountedPtr< AmrMesh > &a_amr)
 Set the amr object. More...
 
virtual void writePlotFile ()
 Write plot file. More...
 
virtual void postCheckpoint ()
 Write checkpoint data for a level @paramo[out] a_handle HDF5 handle. More...
 
virtual void writePlotData (LevelData< EBCellFAB > &a_output, int &a_comp, const std::string a_outputRealm, const int a_level, const bool a_forceNoInterp=false) const noexcept
 Write output data to a_output. More...
 
virtual void writeMultifluidData (LevelData< EBCellFAB > &a_output, int &a_comp, const MFAMRCellData &a_data, const phase::which_phase a_phase, const std::string a_outputRealm, const int a_level, const bool a_interp) const noexcept
 Write multifluid data to single-fluid data holders. More...
 
virtual void writeSurfaceData (LevelData< EBCellFAB > &a_output, int &a_comp, const LevelData< BaseIVFAB< Real >> &a_data, const std::string a_outputRealm, const int a_level) const noexcept
 Write surface data to volume data holder. More...
 
void setRealm (const std::string a_realm)
 Set Realm. More...
 
void setTime (const int a_timeStep, const Real a_time, const Real a_dt)
 Set time for this solver. More...
 
void setVerbosity (const int a_verbosity)
 Set verbosity. More...
 
virtual void setVoltage (std::function< Real(const Real a_time)> a_voltage)
 Set potential dependence in time. More...
 
virtual void setDomainSideBcFunction (const int a_dir, const Side::LoHiSide a_side, const ElectrostaticDomainBc::BcFunction &a_function)
 Boundary condition function on a domain side. More...
 
virtual void setElectrodeDirichletFunction (const int a_electrode, const ElectrostaticEbBc::BcFunction &a_function)
 Set embedded boundary Dirichlet function on a specific electrode. More...
 
virtual int getNumberOfPlotVariables () const
 Get number of output fields. More...
 
const std::function< Real(const Real a_time)> & getVoltage () const
 Get voltage function. More...
 
Real getCurrentVoltage () const
 Get current voltage. More...
 
Real getTime () const
 Get time. More...
 
Real computeCapacitance ()
 Compute the capacitance. More...
 
Real computeEnergy (const MFAMRCellData &a_electricField)
 Compute energy density U = 0.5*int(E.dot.D dV) More...
 
virtual Vector< std::string > getPlotVariableNames () const
 Get output plot names. More...
 
void setDataLocation (const Location::Cell a_dataLocation)
 Set the data location for the solver. More...
 
std::string getRealm () const
 Get the Realm where this solver is registered. More...
 
MFAMRCellDatagetPotential ()
 Get potential on both phases.
 
MFAMRCellDatagetElectricField ()
 Get electric field on both phases.
 
MFAMRCellDatagetRho ()
 Get storage for the space charge density. More...
 
MFAMRCellDatagetResidue ()
 Get the residue.
 
MFAMRCellDatagetPermittivityCell ()
 Get cell-centered permittivity.
 
MFAMRFluxDatagetPermittivityFace ()
 Get face-centered permittivity.
 
MFAMRIVDatagetPermittivityEB ()
 Get irregular b coefficient.
 
EBAMRIVDatagetSigma ()
 Get m_sigma.
 
Location::Cell getDataLocation () const
 Get data location.
 

Protected Types

enum class  BottomSolverType { Simple , BiCGStab , GMRES }
 Enum class for supported bottom solvers in multigrid.
 
enum class  MultigridType { VCycle , WCycle }
 Enum for multigrid cycle types.
 
enum class  JumpBCType { Natural , SaturationCharge }
 Jump BC type.
 

Protected Member Functions

virtual void parseMultigridSettings ()
 Parse multigrid settings.
 
virtual void parseKappaSource ()
 Parse m_kappaSource.
 
virtual void parseJumpBC ()
 Parse JumpBC type.
 
virtual void setPermittivities () override
 Set the permittivities. More...
 
virtual void setupHelmholtzFactory ()
 Set up the multigrid operator factory.
 
virtual void setupMultigrid ()
 Set up AMRMultiGrid.
 
- Protected Member Functions inherited from FieldSolver
virtual void parseVerbosity ()
 Parse solver class verbosity.
 
virtual void parsePlotVariables ()
 Function which parses which plot variables to write to plot files.
 
virtual void parseDomainBc ()
 Parse domain boundary conditions.
 
virtual void parseRegridSlopes ()
 Parse slope regrid.
 
virtual void setDefaultDomainBcFunctions ()
 Set default BC functions. This sets all the m_domainBcFunction objects to s_defaultDomainBcFunction, which return 1 everywhere.
 
virtual void setDefaultEbBcFunctions ()
 Set default Dirichlet boundary conditions on the embedded boundaries. More...
 
Real getDielectricPermittivity (const RealVect &a_pos) const
 Get relative permittivity at some point in space. More...
 
virtual void setCellPermittivities (EBCellFAB &a_perm, const Box &a_cellBox, const EBISBox &a_ebisbox, const RealVect &a_probLo, const Real &a_dx)
 Set cell-centered permittivities. More...
 
virtual void setFacePermittivities (EBFluxFAB &a_perm, const Box &a_cellBox, const EBISBox &a_ebisbox, const RealVect &a_probLo, const Real &a_dx)
 Set face-centered permittivities. More...
 
virtual void setEbPermittivities (BaseIVFAB< Real > &a_perm, const Box &a_cellBox, const EBISBox &a_ebisbox, const RealVect &a_origin, const Real &a_dx)
 Set EB-centered permittivities. More...
 
virtual ElectrostaticDomainBc::BcType parseBcString (const std::string a_str) const
 Returns BC type based on string. More...
 
virtual std::string makeBcString (const int a_dir, const Side::LoHiSide a_side) const
 Shortcut for making a boundary condition string. More...
 

Protected Attributes

MFHelmholtzOp::Smoother m_multigridRelaxMethod
 Relaxation type for gmg.
 
MultigridType m_multigridType
 GMG multigrid type.
 
BottomSolverType m_bottomSolverType
 Bottom solver type.
 
JumpBCType m_jumpBcType
 JumpBC type.
 
bool m_kappaSource
 Scale by kappa or not.
 
bool m_isSolverSetup
 Needs setup.
 
int m_multigridVerbosity
 Verbosity for geometric multigrid.
 
int m_multigridSmooth
 Number of smoothing for multigrid.
 
int m_multigridPreSmooth
 Number of smoothings before averaging.
 
int m_multigridPostSmooth
 Number of smoothings before averaging.
 
int m_multigridBottomSmooth
 Number of smoothing before bottom solver.
 
int m_multigridMaxIterations
 Maximum number of iterations.
 
int m_multigridMinIterations
 Minimum number of iterations.
 
int m_numSmoothingsForSimpleSolver
 Number of smoothing for bottom solver.
 
int m_minCellsBottom
 Set bottom drop depth.
 
int m_domainDropOrder
 Domain drop order.
 
int m_multigridBcOrder
 Set bc order.
 
int m_multigridBcWeight
 Set bc weight (used for weighted least squares)
 
int m_multigridJumpOrder
 Set bc jump order.
 
int m_multigridJumpWeight
 Set bc jump weight (used for weighted least squares)
 
Real m_multigridExitTolerance
 Exit tolerance for multigrid. More...
 
Real m_multigridExitHang
 Exit hang for multigrid. More...
 
RefCountedPtr< MFHelmholtzOpFactorym_helmholtzOpFactory
 Multigrid operator factory.
 
RefCountedPtr< AMRMultiGrid< LevelData< MFCellFAB > > > m_multigridSolver
 Geometric multigrid solver.
 
BiCGStabSolver< LevelData< MFCellFAB > > m_bicgstab
 Conjugate gradient solver bottom MG level.
 
GMRESSolver< LevelData< MFCellFAB > > m_gmres
 GMRES solver.
 
MFSimpleSolver m_mfsolver
 multi-fluid simple solver
 
- Protected Attributes inherited from FieldSolver
Location::Cell m_dataLocation
 Flag which specifies that data location.
 
Location::Face m_faceLocation
 Flag which specifies where the permittivities are stored.
 
std::string m_realm
 Realm where this solver is registered.
 
std::string m_className
 Class name (i.e., "FieldSolver" for the base class)
 
RefCountedPtr< MultiFluidIndexSpacem_multifluidIndexSpace
 Multifluid index space.
 
RefCountedPtr< ComputationalGeometrym_computationalGeometry
 Computational geometry.
 
RefCountedPtr< AmrMeshm_amr
 AMR - needed for pretty much everything.
 
MFAMRCellData m_cache
 Cached state used for regridding.
 
MFAMRCellData m_potential
 State data, i.e. the potential. The centering of this is the same as m_dataLocation.
 
MFAMRCellData m_electricField
 Electric field. The centering of this is the same as m_dataLocation.
 
MFAMRCellData m_rho
 Storage for space charge density.
 
EBAMRIVData m_sigma
 Storage for surface charge density.
 
MFAMRCellData m_residue
 Residue, e.g. used after solving Poisson equation.
 
MFAMRCellData m_permittivityCell
 Cell permittivity.
 
MFAMRFluxData m_permittivityFace
 Face permittivity.
 
MFAMRIVData m_permittivityEB
 EB permittivity.
 
bool m_isVoltageSet
 Flag for checking if voltage has been set.
 
bool m_plotPotential
 If true, potential will be added to plot files.
 
bool m_plotRho
 If true, space charge will be added to plot files.
 
bool m_plotElectricField
 If true, the electric field will be added to plot files.
 
bool m_plotElectricFieldSolid
 If true, the electric field on the inside of dielectrics will be added to plot files.
 
bool m_plotResidue
 If true, the residue will be added to plot files.
 
bool m_plotPermittivity
 If true, the permittivity will be added to plot files.
 
bool m_plotSigma
 If true, m_sigma will be added to plot files.
 
bool m_regridSlopes
 Use slopes when regridding or ont.
 
int m_verbosity
 Verbosity for this calss.
 
int m_timeStep
 Current time step.
 
Real m_dt
 Last time step increment.
 
Real m_time
 Current time.
 
ElectrostaticDomainBc m_domainBc
 Domain boundary conditions for FieldSolver.
 
ElectrostaticEbBc m_ebBc
 Dirichlet boundary conditions on electrodes.
 
std::map< ElectrostaticDomainBc::DomainSide, ElectrostaticDomainBc::BcFunctionm_domainBcFunctions
 Domain BC functions. This is used to map space/time to a voltage/field at the domain faces.
 
std::vector< std::pair< Electrode, ElectrostaticEbBc::BcFunction > > m_electrodeBcFunctions
 BC functions (Dirichlet) on the electrodes. Used to map space/time to a voltage on the electrodes.
 
std::function< Real(const Real a_time)> m_voltage
 Voltage function.
 

Static Protected Attributes

static constexpr Real m_alpha = 0.0
 alpha-coefficient (for Helmholtz operator)
 
static constexpr Real m_beta = -1.0
 Beta-coefficient (for Helmholtz operator)
 
- Static Protected Attributes inherited from FieldSolver
constexpr static int m_comp = 0
 Component number where data is stored.
 
constexpr static int m_nComp = 1
 Number of components in data holders.
 

Detailed Description

Implementation of FieldSolver which uses multigrid.

This class uses MFHelmholtzOp for discretizing the Poisson equation to second order. Although MFHelmholtzOp solves the Helmholtz equation alpha*a(x)*phi(x) + beta*div[b(x)*grad(phi)] = rho, we just set alpha to zero and eat the performance penalty. This class runs with electrostatic domain and EB boundary conditions that fit in the EBHelmholtzOp/MFHelmholtzOp constructs.

Constructor & Destructor Documentation

◆ FieldSolverMultigrid() [1/3]

FieldSolverMultigrid::FieldSolverMultigrid ( )

Weak constructor.

This sets default options.

◆ FieldSolverMultigrid() [2/3]

FieldSolverMultigrid::FieldSolverMultigrid ( const FieldSolverMultigrid a_other)
delete

Disallowed copy constructor.

Parameters
[in]a_otherOther solver

◆ FieldSolverMultigrid() [3/3]

FieldSolverMultigrid::FieldSolverMultigrid ( const FieldSolverMultigrid &&  a_other)
delete

Disallowed move constructor.

Parameters
[in]a_otherOther solver

Member Function Documentation

◆ computeElectricField() [1/4]

void FieldSolverMultigrid::computeElectricField ( EBAMRCellData a_E,
const phase::which_phase  a_phase,
const MFAMRCellData a_potential 
) const
overridevirtual

Compute the cell-centered electric field on a specific phase.

Parameters
[out]a_electricFieldCell-centered electric field
[in]a_phasePhase
[in]a_potentialCell-centered potential

Implements FieldSolver.

◆ computeElectricField() [2/4]

void FieldSolverMultigrid::computeElectricField ( EBAMRFluxData a_E,
const phase::which_phase  a_phase,
const MFAMRCellData a_potential 
) const
overridevirtual

Compute the face-centered electric field on a specific phase.

Parameters
[out]a_electricFieldFace-centered electric field
[in]a_phasePhase
[in]a_potentialCell-centered potential

Implements FieldSolver.

◆ computeElectricField() [3/4]

void FieldSolverMultigrid::computeElectricField ( MFAMRCellData a_E,
const MFAMRCellData a_potential 
) const
overridevirtual

Compute the cell-centered electric field.

Parameters
[out]a_electricFieldCell-centered electric field
[in]a_potentialCell-centered potential

Implements FieldSolver.

◆ computeElectricField() [4/4]

void FieldSolverMultigrid::computeElectricField ( MFAMRFluxData a_E,
const MFAMRCellData a_potential 
) const
overridevirtual

Compute the face-centered electric field.

Parameters
[out]a_electricFieldFace-centered electric field
[in]a_potentialCell-centered potential

Implements FieldSolver.

◆ computeLoads()

Vector< long long > FieldSolverMultigrid::computeLoads ( const DisjointBoxLayout &  a_dbl,
const int  a_level 
)
overridevirtual

Compute grid loads.

Parameters
[in]a_dblGrids on input level
[in]a_levelGrid level
Returns
Returns a vector of estimated loads. The indices in the vector correspond to the indices in DisjointBoxLayout::boxArray()

Reimplemented from FieldSolver.

◆ operator=() [1/2]

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

Disallowed move assignment operator.

Parameters
[in]a_otherOther solver

◆ operator=() [2/2]

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

Disallowed copy assignment operator.

Parameters
[in]a_otherOther solver

◆ preRegrid()

void FieldSolverMultigrid::preRegrid ( const int  a_lbase,
const int  a_oldFinestLevel 
)
overridevirtual

Cache state before regridding.

Parameters
[in]a_lbaseCoarsest level which changes during regrid.
[in]a_oldFinestLevelFinest AMR level before regrid.

Reimplemented from FieldSolver.

◆ regrid()

void FieldSolverMultigrid::regrid ( const int  a_lmin,
const int  a_oldFinestLevel,
const int  a_newFinestLevel 
)
overridevirtual

Regrid method.

This calls the parent regrid function first. We only need the overwrite because we have to signal that multigrid must be set up again.

Parameters
[in]a_lminCoarsest level allowed to change.
[in]a_oldFinestLevelFinest AMR level before the regrid.
[in]a_newFinestLevelFinest AMR level before the regrid.

This linearly interpolates (with limiters) m_potential to the new grids and recomputes the electric field (from the interpolated potential).

Reimplemented from FieldSolver.

◆ setPermittivities()

void FieldSolverMultigrid::setPermittivities ( )
overrideprotectedvirtual

Set the permittivities.

This sets m_permittivityCell, m_permittivityFace, and m_permittivityEB and fills necessary ghost faces/cells.

Reimplemented from FieldSolver.

◆ setSolverPermittivities()

void FieldSolverMultigrid::setSolverPermittivities ( const MFAMRCellData a_permittivityCell,
const MFAMRFluxData a_permittivityFace,
const MFAMRIVData a_permittivityEB 
)
overridevirtual

Set new permittivities for the multigrid solver.

Parameters
[in]a_permittivityCellPermittivity on cell center
[in]a_permittivityFacePermittivity on faces
[in]a_permittivityEBPermittivity on EB

Reimplemented from FieldSolver.

◆ solve()

bool FieldSolverMultigrid::solve ( MFAMRCellData a_potential,
const MFAMRCellData a_rho,
const EBAMRIVData a_sigma,
const bool  a_zeroPhi = false 
)
overridevirtual

Solves Poisson equation onto a_phi using a_rho and a_sigma as right-hand sides.

Parameters
[in,out]a_potentialPotential
[in]a_rhoSpace charge density
[in]a_sigmaSurface charge density.
[in]a_zeroPhiSet a_potential to zero first.
Returns
True if we found a solution and false otherwise.
Note
a_sigma must be defined on the gas phase.

Implements FieldSolver.

Member Data Documentation

◆ m_multigridExitHang

Real FieldSolverMultigrid::m_multigridExitHang
protected

Exit hang for multigrid.

Multigrid exits if residue is not reduce by at least this factor.

◆ m_multigridExitTolerance

Real FieldSolverMultigrid::m_multigridExitTolerance
protected

Exit tolerance for multigrid.

Multigrid exits if L(phi) < tolerance*L(phi=0)


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