chombo-discharge
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Physics::Electrostatics::FieldStepper< T > Class Template Reference

TimeStepper for solving the electrostatic Poisson equation, optionally with surface charge. More...

#include <CD_FieldStepper.H>

Inheritance diagram for Physics::Electrostatics::FieldStepper< T >:
Inheritance graph
[legend]
Collaboration diagram for Physics::Electrostatics::FieldStepper< T >:
Collaboration graph
[legend]

Public Member Functions

 FieldStepper ()
 Constructor – parses some input options.
 
virtual ~FieldStepper ()
 Destructor (does nothing)
 
void setupSolvers () override
 Solver setup routine. This instantiates the FieldSolver and parses input options.
 
void initialData () override
 Set initial data – this sets the space and surface charges.
 
void postInitialize () override
 Post-initialization routine. This solves the Poisson equation.
 
void allocate () override
 Allocation method – allocates memory and internal data for solvers.
 
MFAMRCellDatagetPotential ()
 Get the electrostatic potential.
 
void postCheckpointSetup () override
 Post-initialize operations to be performed – does nothing.
 
int getNumberOfPlotVariables () const override
 Get number of plot variables contributed by this TimeStepper.
 
Vector< std::stringgetPlotVariableNames () const override
 Get plot variable names.
 
void writePlotData (LevelData< EBCellFAB > &a_output, int &a_icomp, const std::string &a_outputRealm, const int a_level) const override
 Write plot data to output holder.
 
Real computeDt () override
 Compute time step.
 
Real advance (const Real a_dt) override
 Perform a single time step with step a_dt.
 
void synchronizeSolverTimes (const int a_step, const Real a_time, const Real a_dt) override
 Synchronize solver times and time steps.
 
void printStepReport () override
 Print step report – this does nothing.
 
void registerRealms () override
 Register simulation realms to be used for this simulation module.
 
void registerOperators () override
 Register operators for this simulation module.
 
void preRegrid (const int a_lbase, const int a_finestLevel) override
 Perform pre-regrid operations.
 
bool loadBalanceThisRealm (const std::string &a_realm) const override
 Load balancing query for a specified realm. If this returns true for a_realm, load balancing routines will be called during regrids.
 
void loadBalanceBoxes (Vector< Vector< int > > &a_procs, Vector< Vector< Box > > &a_boxes, const std::string &a_realm, const Vector< DisjointBoxLayout > &a_grids, const int a_lmin, const int a_finestLevel) override
 Load balance grid boxes for a specified realm.
 
void regrid (const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
 Regrid method – regrids the potential distribution in FieldSolver (but does not solve the Poisson equation, that is done in postRegrid()).
 
void postRegrid () override
 Perform post-regrid operations – this will resolve the Poisson equation.
 
void setRho (const std::function< Real(const RealVect &a_pos)> &a_rho, const phase::which_phase a_phase) noexcept
 Set the space charge distribution.
 
void setSigma (const std::function< Real(const RealVect &a_pos)> &a_sigma) noexcept
 Set the surface charge distribution.
 
- Public Member Functions inherited from TimeStepper
 TimeStepper ()
 Default constructor (does nothing)
 
virtual ~TimeStepper ()
 Default destructor (does nothing)
 
 TimeStepper (const TimeStepper &)=delete
 Disallow copy construction.
 
TimeStepperoperator= (const TimeStepper &)=delete
 Disallow copy assignment.
 
 TimeStepper (TimeStepper &&)=default
 Allow move construction.
 
TimeStepperoperator= (TimeStepper &&)=default
 Allow move assignment.
 
void setAmr (const RefCountedPtr< AmrMesh > &a_amr)
 Set AmrMesh.
 
void setComputationalGeometry (const RefCountedPtr< ComputationalGeometry > &a_computationalGeometry)
 Set the computational geometry.
 
virtual void parseRuntimeOptions ()
 Parse runtime options.
 
virtual void prePlot ()
 An option for calling special functions prior to plotting data. Called by Driver in the IMMEDIATELY before writing the plot file.
 
virtual void postPlot ()
 An option for calling special functions prior to plotting data. Called by Driver in the IMMEDIATELY after writing the plot file.
 
virtual Vector< long intgetCheckpointLoads (const std::string &a_realm, int a_level) const
 Get computational loads to be checkpointed.
 
virtual bool needToRegrid ()
 Function which can have Driver do regrids at arbitrary points in the simulation.
 
bool keepGoing () const
 Query whether the time stepper wants to continue stepping.
 

Protected Member Functions

void solvePoisson ()
 Solve the Poisson equation and compute the electric field.
 

Protected Attributes

bool m_loadBalance
 If true, the simulation will be introspectively load balanced.
 
BoxSorting m_boxSort
 If using load balancing, this specifies how boxes will be sorted (in space) before load balancing.
 
RefCountedPtr< FieldSolverm_fieldSolver
 Reference to the FieldSolver.
 
RefCountedPtr< SurfaceODESolver< 1 > > m_sigma
 Reference to the surface charge solver.
 
std::string m_realm
 Realm where the solver lives.
 
std::function< Real(const RealVect &a_pos)> m_rhoGas
 Space charge inside gas phase.
 
std::function< Real(const RealVect &a_pos)> m_rhoDielectric
 Space charge inside dielectric.
 
std::function< Real(const RealVect &a_pos)> m_surfaceChargeDensity
 Surface charge distribution.
 
- Protected Attributes inherited from TimeStepper
int m_verbosity
 Class verbosity.
 
int m_timeStep
 Time step.
 
Real m_time
 TIme.
 
Real m_dt
 Previous time step size.
 
bool m_keepGoing
 If false, Driver will stop the time loop after the current step.
 
RefCountedPtr< AmrMeshm_amr
 AmrMesh.
 
RefCountedPtr< ComputationalGeometrym_computationalGeometry
 Computational geometry.
 

Detailed Description

template<class T>
class Physics::Electrostatics::FieldStepper< T >

TimeStepper for solving the electrostatic Poisson equation, optionally with surface charge.

This module solves the electrostatic problem on a static or adaptively refined AMR hierarchy. The template parameter T is the concrete FieldSolver type (e.g. FieldSolverGMG).

The solver decomposes the potential into contributions from the applied voltage and from space/surface charges. On live electrodes the voltage defaults to 1 V; use setRho() and setSigma() before calling postInitialize() to override the default zero charges.

Adaptive mesh refinement is supported when a CellTagger is attached via Driver — the stepper re-solves the Poisson equation after every regrid in postRegrid().

Member Function Documentation

◆ advance()

template<class T >
Real Physics::Electrostatics::FieldStepper< T >::advance ( const Real  a_dt)
overridevirtual

Perform a single time step with step a_dt.

Parameters
[in]a_dtTime step
Returns
a_dt

Implements TimeStepper.

◆ allocate()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::allocate ( )
overridevirtual

Allocation method – allocates memory and internal data for solvers.

Implements TimeStepper.

◆ computeDt()

template<class T >
Real Physics::Electrostatics::FieldStepper< T >::computeDt ( )
inlineoverridevirtual

Compute time step.

This is a static solver so it returns 0.0

Returns
Computed dt

Implements TimeStepper.

◆ getNumberOfPlotVariables()

template<class T >
int Physics::Electrostatics::FieldStepper< T >::getNumberOfPlotVariables ( ) const
overridevirtual

Get number of plot variables contributed by this TimeStepper.

Returns
Number of plot variables written by writePlotData().

Implements TimeStepper.

◆ getPlotVariableNames()

template<class T >
Vector< std::string > Physics::Electrostatics::FieldStepper< T >::getPlotVariableNames ( ) const
overridevirtual

Get plot variable names.

Returns
Vector of plot variable name strings.

Implements TimeStepper.

◆ getPotential()

template<class T >
MFAMRCellData & Physics::Electrostatics::FieldStepper< T >::getPotential ( )

Get the electrostatic potential.

Returns
Reference to the multifluid AMR cell data holding the potential.

◆ initialData()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::initialData ( )
overridevirtual

Set initial data – this sets the space and surface charges.

Implements TimeStepper.

◆ loadBalanceBoxes()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::loadBalanceBoxes ( Vector< Vector< int > > &  a_procs,
Vector< Vector< Box > > &  a_boxes,
const std::string a_realm,
const Vector< DisjointBoxLayout > &  a_grids,
const int  a_lmin,
const int  a_finestLevel 
)
overridevirtual

Load balance grid boxes for a specified realm.

Parameters
[out]a_procsMPI ranks owning the various grid boxes.
[out]a_boxesGrid boxes on every level (obtain them with a_grids[lvl].boxArray())
[in]a_realmRealm identifier
[in]a_gridsOriginal grids
[in]a_lminCoarsest grid level that changed
[in]a_finestLevelNew finest grid level

This is only called by Driver if TimeStepper::loadBalanceThisRealm(a_realm) returned true. The default implementation uses volume-based loads for the grid patches. If the user wants to load balance boxes on a realm, this routine must be overwritten and he should compute loads for the various patches in a_grids and call LoadBalancing::makeBalance on each level. It is up to the user/programmer to decide if load balancing should be done independently on each level, or if loads per MPI rank are accumulated across levels.

Reimplemented from TimeStepper.

◆ loadBalanceThisRealm()

template<class T >
bool Physics::Electrostatics::FieldStepper< T >::loadBalanceThisRealm ( const std::string a_realm) const
overridevirtual

Load balancing query for a specified realm. If this returns true for a_realm, load balancing routines will be called during regrids.

Parameters
[in]a_realmRealm name
Returns
Return value

Reimplemented from TimeStepper.

◆ postCheckpointSetup()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::postCheckpointSetup ( )
inlineoverridevirtual

Post-initialize operations to be performed – does nothing.

Implements TimeStepper.

◆ postInitialize()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::postInitialize ( )
overridevirtual

Post-initialization routine. This solves the Poisson equation.

Implements TimeStepper.

◆ postRegrid()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::postRegrid ( )
overridevirtual

Perform post-regrid operations – this will resolve the Poisson equation.

This includes all operations to be done AFTER interpolating data to new grids.

Implements TimeStepper.

◆ preRegrid()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::preRegrid ( const int  a_lbase,
const int  a_finestLevel 
)
overridevirtual

Perform pre-regrid operations.

Parameters
[in]a_lbaseThe coarsest level that changes.
[in]a_finestLevelThe finest level before the regrid.

Implements TimeStepper.

◆ printStepReport()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::printStepReport ( )
inlineoverridevirtual

Print step report – this does nothing.

Implements TimeStepper.

◆ registerOperators()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::registerOperators ( )
overridevirtual

Register operators for this simulation module.

Implements TimeStepper.

◆ registerRealms()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::registerRealms ( )
overridevirtual

Register simulation realms to be used for this simulation module.

Implements TimeStepper.

◆ regrid()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::regrid ( const int  a_lmin,
const int  a_oldFinestLevel,
const int  a_newFinestLevel 
)
overridevirtual

Regrid method – regrids the potential distribution in FieldSolver (but does not solve the Poisson equation, that is done in postRegrid()).

Parameters
[in]a_lminThe coarsest level that changed.
[in]a_oldFinestLevelThe finest level before the regrid.
[in]a_newFinestLevelThe finest level after the regrid.

Implements TimeStepper.

◆ setRho()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::setRho ( const std::function< Real(const RealVect &a_pos)> &  a_rho,
const phase::which_phase  a_phase 
)
noexcept

Set the space charge distribution.

Parameters
[in]a_rhoCallable returning the charge density (C/m^3) at a given position.
[in]a_phasePhase (gas or solid) in which to apply the space charge.

◆ setSigma()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::setSigma ( const std::function< Real(const RealVect &a_pos)> &  a_sigma)
noexcept

Set the surface charge distribution.

Parameters
[in]a_sigmaCallable returning the surface charge density (C/m^2) at a given position.

◆ setupSolvers()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::setupSolvers ( )
overridevirtual

Solver setup routine. This instantiates the FieldSolver and parses input options.

Implements TimeStepper.

◆ solvePoisson()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::solvePoisson ( )
protected

Solve the Poisson equation and compute the electric field.

Called from postInitialize() and postRegrid().

◆ synchronizeSolverTimes()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::synchronizeSolverTimes ( const int  a_step,
const Real  a_time,
const Real  a_dt 
)
overridevirtual

Synchronize solver times and time steps.

Parameters
[in]a_stepCurrent time step number.
[in]a_timeCurrent simulation time in seconds.
[in]a_dtTime step that was used.

Implements TimeStepper.

◆ writePlotData()

template<class T >
void Physics::Electrostatics::FieldStepper< T >::writePlotData ( LevelData< EBCellFAB > &  a_output,
int a_icomp,
const std::string a_outputRealm,
const int  a_level 
) const
overridevirtual

Write plot data to output holder.

Parameters
[in,out]a_outputOutput data holder.
[in,out]a_icompStarting component in a_output; incremented by the number of components written.
[in]a_outputRealmRealm where a_output lives.
[in]a_levelGrid level.

Implements TimeStepper.


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