12 #ifndef CD_FieldSolver_H
13 #define CD_FieldSolver_H
24 #include <CD_NamespaceHeader.H>
95 solve(
const bool a_zeroPhi =
false);
150 const phase::which_phase a_phase,
161 const phase::which_phase a_phase,
189 preRegrid(
const int a_lbase,
const int a_oldFinestLevel);
213 regrid(
const int a_lmin,
const int a_oldFinestLevel,
const int a_newFinestLevel);
233 setRho(
const std::function<Real(
const RealVect)>& a_rho);
246 setSigma(
const std::function<Real(
const RealVect)>& a_sigma);
260 setAmr(
const RefCountedPtr<AmrMesh>& a_amr);
284 writeCheckpointLevel(HDF5Handle& a_handle,
const int a_level)
const;
295 readCheckpointLevel(HDF5Handle& a_handle,
const int a_level);
317 const std::string a_outputRealm,
319 const bool a_forceNoInterp =
false) const noexcept;
336 const
phase::which_phase a_phase,
337 const std::
string a_outputRealm,
339 const
bool a_interp) const noexcept;
353 const LevelData<BaseIVFAB<Real>>& a_data,
354 const std::
string a_outputRealm,
355 const
int a_level) const noexcept;
362 setRealm(const std::
string a_realm);
372 setTime(const
int a_timeStep, const Real a_time, const Real a_dt);
387 setVoltage(std::function<Real(const Real a_time)> a_voltage);
398 const Side::LoHiSide a_side,
420 const std::function<Real(const Real a_time)>&
457 virtual Vector<std::
string>
466 virtual Vector<
long long>
467 computeLoads(const DisjointBoxLayout& a_dbl, const
int a_level);
775 const Box& a_cellBox,
776 const EBISBox& a_ebisbox,
777 const RealVect& a_probLo,
790 const Box& a_cellBox,
791 const EBISBox& a_ebisbox,
792 const RealVect& a_probLo,
805 const Box& a_cellBox,
806 const EBISBox& a_ebisbox,
807 const RealVect& a_origin,
825 makeBcString(const
int a_dir, const Side::LoHiSide a_side) const;
828 #include <CD_NamespaceFooter.H>
Declaration of core class for handling AMR-related operations (with embedded boundaries)
Declaration of base class for defining geometries.
Declaration of a class for holding function-based boundary conditions on domain edges.
Data holder for holding the voltage at electrodes.
Implementation of CD_FieldSolver.H.
Declaration of cell positions.
Class for handling spatial operations.
Definition: CD_AmrMesh.H:44
Abstract base class for geometries.
Definition: CD_ComputationalGeometry.H:36
Electrode class for encapsulating the concept of an electrical conductor.
Definition: CD_Electrode.H:26
Class which maps boundary condition types to a side and direction.
Definition: CD_ElectrostaticDomainBc.H:33
Class which maps boundary condition types to a side and direction.
Definition: CD_ElectrostaticEbBc.H:33
Base class for electrostatic solvers.
Definition: CD_FieldSolver.H:32
virtual void registerOperators()=0
Register operators for AMR. Derived classes have to implement these.
MFAMRCellData & getElectricField()
Get electric field on both phases.
Definition: CD_FieldSolver.cpp:1645
void setSigma(const Real a_sigma)
Set surface charge to specified value.
Definition: CD_FieldSolver.cpp:454
const std::function< Real(const Real a_time)> & getVoltage() const
Get voltage function.
Definition: CD_FieldSolver.cpp:1601
virtual ElectrostaticDomainBc::BcType parseBcString(const std::string a_str) const
Returns BC type based on string.
Definition: CD_FieldSolver.cpp:679
FieldSolver(const FieldSolver &a_other)=delete
Disallowed copy constructor.
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.
Definition: CD_FieldSolver.cpp:996
bool m_plotSigma
If true, m_sigma will be added to plot files.
Definition: CD_FieldSolver.H:668
void setTime(const int a_timeStep, const Real a_time, const Real a_dt)
Set time for this solver.
Definition: CD_FieldSolver.cpp:543
RefCountedPtr< MultiFluidIndexSpace > m_multifluidIndexSpace
Multifluid index space.
Definition: CD_FieldSolver.H:573
void setAmr(const RefCountedPtr< AmrMesh > &a_amr)
Set the amr object.
Definition: CD_FieldSolver.cpp:496
Real getTime() const
Get time.
Definition: CD_FieldSolver.cpp:1623
std::string m_className
Class name (i.e., "FieldSolver" for the base class)
Definition: CD_FieldSolver.H:568
bool m_plotElectricFieldSolid
If true, the electric field on the inside of dielectrics will be added to plot files.
Definition: CD_FieldSolver.H:653
Location::Face m_faceLocation
Flag which specifies where the permittivities are stored.
Definition: CD_FieldSolver.H:558
void setRealm(const std::string a_realm)
Set Realm.
Definition: CD_FieldSolver.cpp:556
MFAMRCellData m_electricField
Electric field. The centering of this is the same as m_dataLocation.
Definition: CD_FieldSolver.H:598
MFAMRCellData m_potential
State data, i.e. the potential. The centering of this is the same as m_dataLocation.
Definition: CD_FieldSolver.H:593
virtual void parseRuntimeOptions()=0
Parse runtime options (for derived class)
constexpr static int m_comp
Component number where data is stored.
Definition: CD_FieldSolver.H:543
bool m_isVoltageSet
Flag for checking if voltage has been set.
Definition: CD_FieldSolver.H:633
Location::Cell m_dataLocation
Flag which specifies that data location.
Definition: CD_FieldSolver.H:553
std::string getRealm() const
Get the Realm where this solver is registered.
Definition: CD_FieldSolver.cpp:567
virtual void setDomainSideBcFunction(const int a_dir, const Side::LoHiSide a_side, const ElectrostaticDomainBc::BcFunction &a_function)
Boundary condition function on a domain side.
Definition: CD_FieldSolver.cpp:754
MFAMRCellData m_cache
Cached state used for regridding.
Definition: CD_FieldSolver.H:588
virtual bool solve(MFAMRCellData &a_phi, const MFAMRCellData &a_rho, const EBAMRIVData &a_sigma, const bool a_zerophi=false)=0
Solves Poisson equation onto a_phi using a_rho and a_sigma as right-hand sides.
FieldSolver(const FieldSolver &&a_other)=delete
Disallowed move constructor.
virtual void parseRegridSlopes()
Parse slope regrid.
Definition: CD_FieldSolver.cpp:633
virtual Vector< long long > computeLoads(const DisjointBoxLayout &a_dbl, const int a_level)
Get computational loads for a level.
Definition: CD_FieldSolver.cpp:1573
Location::Cell getDataLocation() const
Get data location.
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel)
Regrid method.
Definition: CD_FieldSolver.cpp:396
RefCountedPtr< ComputationalGeometry > m_computationalGeometry
Computational geometry.
Definition: CD_FieldSolver.H:578
MFAMRIVData m_permittivityEB
EB permittivity.
Definition: CD_FieldSolver.H:628
virtual void writePlotFile()
Write plot file.
Definition: CD_FieldSolver.cpp:1024
virtual void setDefaultEbBcFunctions()
Set default Dirichlet boundary conditions on the embedded boundaries.
Definition: CD_FieldSolver.cpp:723
virtual int getNumberOfPlotVariables() const
Get number of output fields.
Definition: CD_FieldSolver.cpp:1493
virtual void deallocate()
Deallocate internal storage.
Definition: CD_FieldSolver.cpp:378
FieldSolver()
Constructor.
Definition: CD_FieldSolver.cpp:33
MFAMRCellData & getPotential()
Get potential on both phases.
Definition: CD_FieldSolver.cpp:1634
Real getDielectricPermittivity(const RealVect &a_pos) const
Get relative permittivity at some point in space.
Definition: CD_FieldSolverImplem.H:20
MFAMRFluxData m_permittivityFace
Face permittivity.
Definition: CD_FieldSolver.H:623
EBAMRIVData & getSigma()
Get m_sigma.
Definition: CD_FieldSolver.cpp:1667
virtual void parsePlotVariables()
Function which parses which plot variables to write to plot files.
Definition: CD_FieldSolver.cpp:591
virtual void setSolverPermittivities(const MFAMRCellData &a_permittivityCell, const MFAMRFluxData &a_permittivityFace, const MFAMRIVData &a_permittivityEB)
A special routine for when solver permittivities need to change but solver does not.
Definition: CD_FieldSolver.cpp:117
virtual void computeElectricField(MFAMRCellData &a_E, const MFAMRCellData &a_potential) const =0
Compute the cell-centered electric field.
virtual void computeElectricField(MFAMRFluxData &a_E, const MFAMRCellData &a_potential) const =0
Compute the face-centered electric field.
void setVerbosity(const int a_verbosity)
Set verbosity.
Definition: CD_FieldSolver.cpp:532
Real computeCapacitance()
Compute the capacitance.
Definition: CD_FieldSolver.cpp:325
virtual void parseOptions()=0
Parse options (for derived class)
virtual void postCheckpoint()
Write checkpoint data for a level @paramo[out] a_handle HDF5 handle.
Definition: CD_FieldSolver.cpp:1154
MFAMRIVData & getPermittivityEB()
Get irregular b coefficient.
Definition: CD_FieldSolver.cpp:1711
virtual void computeDisplacementField(MFAMRCellData &a_displacementField, const MFAMRCellData &a_electricField)
Compute displacement field from the electric field.
Definition: CD_FieldSolver.cpp:184
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.
Definition: CD_FieldSolver.H:713
virtual void allocate()
Allocates internal storage for FieldSolver. Derived classes may want to overwrite.
Definition: CD_FieldSolver.cpp:139
virtual void computeElectricField(EBAMRCellData &a_E, const phase::which_phase a_phase, const MFAMRCellData &a_potential) const =0
Compute the cell-centered electric field on a specific phase.
void setDataLocation(const Location::Cell a_dataLocation)
Set the data location for the solver.
Definition: CD_FieldSolver.cpp:52
int m_timeStep
Current time step.
Definition: CD_FieldSolver.H:683
virtual Vector< std::string > getPlotVariableNames() const
Get output plot names.
Definition: CD_FieldSolver.cpp:1528
virtual bool solve(const bool a_zeroPhi=false)
Solve Poisson equation using m_potential, m_rho, and m_sigma.
Definition: CD_FieldSolver.cpp:87
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.
Definition: CD_FieldSolver.cpp:1205
std::string m_realm
Realm where this solver is registered.
Definition: CD_FieldSolver.H:563
MFAMRCellData & getRho()
Get storage for the space charge density.
Definition: CD_FieldSolver.cpp:1656
EBAMRIVData m_sigma
Storage for surface charge density.
Definition: CD_FieldSolver.H:608
MFAMRCellData m_residue
Residue, e.g. used after solving Poisson equation.
Definition: CD_FieldSolver.H:613
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.
Definition: CD_FieldSolver.cpp:952
constexpr static int m_nComp
Number of components in data holders.
Definition: CD_FieldSolver.H:548
Real getCurrentVoltage() const
Get current voltage.
Definition: CD_FieldSolver.cpp:1612
virtual void setVoltage(std::function< Real(const Real a_time)> a_voltage)
Set potential dependence in time.
Definition: CD_FieldSolver.cpp:509
virtual void setPermittivities()
Set the permittivities.
Definition: CD_FieldSolver.cpp:861
Real m_time
Current time.
Definition: CD_FieldSolver.H:693
virtual void parseVerbosity()
Parse solver class verbosity.
Definition: CD_FieldSolver.cpp:578
std::map< ElectrostaticDomainBc::DomainSide, ElectrostaticDomainBc::BcFunction > m_domainBcFunctions
Domain BC functions. This is used to map space/time to a voltage/field at the domain faces.
Definition: CD_FieldSolver.H:708
ElectrostaticEbBc m_ebBc
Dirichlet boundary conditions on electrodes.
Definition: CD_FieldSolver.H:703
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.
Definition: CD_FieldSolver.cpp:1453
virtual void computeElectricField()
Compute the cell-centered electric field.
Definition: CD_FieldSolver.cpp:128
void setComputationalGeometry(const RefCountedPtr< ComputationalGeometry > &a_computationalGeometry)
Set the computational geometry.
Definition: CD_FieldSolver.cpp:480
MFAMRCellData & getPermittivityCell()
Get cell-centered permittivity.
Definition: CD_FieldSolver.cpp:1689
RefCountedPtr< AmrMesh > m_amr
AMR - needed for pretty much everything.
Definition: CD_FieldSolver.H:583
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.
Definition: CD_FieldSolver.cpp:1163
MFAMRCellData & getResidue()
Get the residue.
Definition: CD_FieldSolver.cpp:1678
virtual ~FieldSolver()
Constructor.
Definition: CD_FieldSolver.cpp:48
bool m_plotPotential
If true, potential will be added to plot files.
Definition: CD_FieldSolver.H:638
virtual void computeElectricField(EBAMRFluxData &a_E, const phase::which_phase a_phase, const MFAMRCellData &a_potential) const =0
Compute the face-centered electric field on a specific phase.
bool m_plotPermittivity
If true, the permittivity will be added to plot files.
Definition: CD_FieldSolver.H:663
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.
Definition: CD_FieldSolver.cpp:911
virtual void parseDomainBc()
Parse domain boundary conditions.
Definition: CD_FieldSolver.cpp:769
virtual void setupSolver()=0
Set up solver routines.
Real computeEnergy(const MFAMRCellData &a_electricField)
Compute energy density U = 0.5*int(E.dot.D dV)
Definition: CD_FieldSolver.cpp:282
void setRho(const Real a_rho)
Set space charge to constant value everywhere.
Definition: CD_FieldSolver.cpp:426
bool m_plotRho
If true, space charge will be added to plot files.
Definition: CD_FieldSolver.H:643
bool m_regridSlopes
Use slopes when regridding or ont.
Definition: CD_FieldSolver.H:673
bool m_plotElectricField
If true, the electric field will be added to plot files.
Definition: CD_FieldSolver.H:648
int m_verbosity
Verbosity for this calss.
Definition: CD_FieldSolver.H:678
bool m_plotResidue
If true, the residue will be added to plot files.
Definition: CD_FieldSolver.H:658
virtual std::string makeBcString(const int a_dir, const Side::LoHiSide a_side) const
Shortcut for making a boundary condition string.
Definition: CD_FieldSolver.cpp:646
ElectrostaticDomainBc m_domainBc
Domain boundary conditions for FieldSolver.
Definition: CD_FieldSolver.H:698
std::function< Real(const Real a_time)> m_voltage
Voltage function.
Definition: CD_FieldSolver.H:718
MFAMRCellData m_permittivityCell
Cell permittivity.
Definition: CD_FieldSolver.H:618
virtual void setDefaultDomainBcFunctions()
Set default BC functions. This sets all the m_domainBcFunction objects to s_defaultDomainBcFunction,...
Definition: CD_FieldSolver.cpp:702
virtual void preRegrid(const int a_lbase, const int a_oldFinestLevel)
Cache state before regridding.
Definition: CD_FieldSolver.cpp:167
FieldSolver & operator=(const FieldSolver &a_other)=delete
Disallowed copy assignment operator.
virtual void setElectrodeDirichletFunction(const int a_electrode, const ElectrostaticEbBc::BcFunction &a_function)
Set embedded boundary Dirichlet function on a specific electrode.
Definition: CD_FieldSolver.cpp:521
MFAMRFluxData & getPermittivityFace()
Get face-centered permittivity.
Definition: CD_FieldSolver.cpp:1700
FieldSolver & operator=(const FieldSolver &&a_other)=delete
Disallowed move assignment operator.
Real m_dt
Last time step increment.
Definition: CD_FieldSolver.H:688
MFAMRCellData m_rho
Storage for space charge density.
Definition: CD_FieldSolver.H:603
Two-fluid index space.
Definition: CD_MultiFluidIndexSpace.H:42
Namespace for encapsulating various data centerings.
Definition: CD_Location.H:24
Cell
Enum for distinguishing between cell locations.
Definition: CD_Location.H:30
Face
Enum for distinguishing between face locations.
Definition: CD_Location.H:40
phase names
Definition: CD_MultiFluidIndexSpace.H:27