chombo-discharge
Loading...
Searching...
No Matches
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Physics::AdvectionDiffusion::AdvectionDiffusionStepper Class Reference

TimeStepper implementation for advancing a single advection-diffusion equation. More...

#include <CD_AdvectionDiffusionStepper.H>

Inheritance diagram for Physics::AdvectionDiffusion::AdvectionDiffusionStepper:
Inheritance graph
[legend]
Collaboration diagram for Physics::AdvectionDiffusion::AdvectionDiffusionStepper:
Collaboration graph
[legend]

Public Member Functions

 AdvectionDiffusionStepper ()
 Default constructor. Parses all options from ParmParse and sets default velocity, diffusion coefficient, and initial data functors.
 
 AdvectionDiffusionStepper (RefCountedPtr< CdrSolver > &a_solver)
 Full constructor. Delegates to the default constructor and then stores the provided solver.
 
virtual ~AdvectionDiffusionStepper ()
 Destructor.
 
void initialData () override
 Fill the solver with initial data and set velocity, diffusion coefficient, and source term.
 
void allocate () override
 Allocate internal storage in the solver.
 
void postInitialize () override
 Post-initialization hook. No operations are performed.
 
void postCheckpointSetup () override
 Post-checkpoint setup. Re-applies velocity, diffusion coefficient, source, and EB flux after a restart so the solver fields are consistent with the loaded state.
 
int getNumberOfPlotVariables () const override
 Return the number of output variables contributed by this stepper.
 
Vector< std::stringgetPlotVariableNames () const override
 Return the names of the output variables contributed by this stepper.
 
void writePlotData (LevelData< EBCellFAB > &a_output, int &a_icomp, const std::string &a_outputRealm, const int a_level) const override
 Write plot data into the output holder.
 
Real computeDt () override
 Compute the next time step.
 
void synchronizeSolverTimes (const int a_step, const Real a_time, const Real a_dt) override
 Update internal time/step counters and forward them to the solver.
 
void printStepReport () override
 Print a step report. No output is produced.
 
void parseRuntimeOptions () override
 Parse runtime options from ParmParse. Re-reads verbosity, CFL bounds, and integrator.
 
void registerRealms () override
 Register the Primal realm with the AMR mesh.
 
void registerOperators () override
 Register the operators required by the solver.
 
void preRegrid (const int a_lbase, const int a_oldFinestLevel) override
 Pre-regrid hook. Notifies the solver to store data before the mesh changes.
 
void setupSolvers () override
 Instantiate the species and configure the solver with realm, phase, and AMR data.
 
Real advance (const Real a_dt) override
 Advance the solution by one time step using the selected integrator.
 
void regrid (const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
 Regrid the solver and re-apply the flow fields on the new mesh.
 
void postRegrid () override
 Post-regrid hook. No operations are performed.
 
void setCFL (const Real a_cfl)
 Force a specific CFL number, overriding the value read from input.
 
void setInitialData (const std::function< Real(const RealVect &a_position)> &a_initData) noexcept
 Override the initial data functor.
 
void setVelocity (const std::function< RealVect(const RealVect &a_position)> &a_velocity) noexcept
 Override the velocity field functor.
 
void setDiffusionCoefficient (const std::function< Real(const RealVect &a_position)> &a_diffusion) noexcept
 Override the diffusion coefficient functor.
 
- 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 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.
 
virtual bool loadBalanceThisRealm (const std::string &a_realm) const
 Load balancing query for a specified realm. If this returns true for a_realm, load balancing routines will be called during regrids.
 
virtual void loadBalanceBoxes (Vector< Vector< int > > &a_procs, Vector< Vector< Box > > &a_boxes, const std::string &a_realm, const Vector< DisjointBoxLayout > &a_grids, int a_lmin, int a_finestLevel)
 Load balance grid boxes for a specified realm.
 

Protected Types

enum  Integrator { Heun , IMEX }
 Supported time integration methods. More...
 

Protected Member Functions

void parseIntegrator ()
 Parse the integration method from ParmParse input.
 

Protected Attributes

RefCountedPtr< CdrSolverm_solver
 The CDR solver used for advancing the scalar field.
 
RefCountedPtr< AdvectionDiffusionSpeciesm_species
 Species definition passed to the CDR solver.
 
std::string m_realm
 Name of the realm on which the solver operates.
 
phase::which_phase m_phase
 Computational phase (gas or solid) on which the solver operates.
 
std::function< RealVect(const RealVect &a_position)> m_velocity
 Functor providing the advection velocity at a given position.
 
std::function< Real(const RealVect &a_position)> m_diffCo
 Functor providing the diffusion coefficient at a given position.
 
std::function< Real(const RealVect &a_initialData)> m_initialData
 Functor providing the initial scalar concentration at a given position.
 
Real m_minDt
 Minimum permissible time step in seconds.
 
Real m_maxDt
 Maximum permissible time step in seconds.
 
Real m_cfl
 CFL number read from input.
 
Real m_forceCFL
 Programmatically forced CFL number. Overrides m_cfl when positive.
 
bool m_debug
 If true, print mass-conservation diagnostics to stdout after each step.
 
bool m_mobile
 If true, the scalar is advected by the velocity field.
 
bool m_diffusive
 If true, the scalar undergoes diffusion.
 
Integrator m_integrator
 Selected time integration method.
 
- 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

TimeStepper implementation for advancing a single advection-diffusion equation.

This class drives a single CdrSolver through a sequence of time steps. The velocity field, diffusion coefficient, and initial data are specified as functors and can be set either through ParmParse input or programmatically via the setter methods. Two explicit integrators are supported: a second-order Heun (explicit trapezoidal) method and an IMEX method that treats advection explicitly and diffusion implicitly via Crank-Nicholson.

Member Enumeration Documentation

◆ Integrator

Supported time integration methods.

Enumerator
Heun 

Second-order explicit Heun (trapezoidal) method.

IMEX 

IMEX: explicit advection, implicit (Crank-Nicholson) diffusion.

Constructor & Destructor Documentation

◆ AdvectionDiffusionStepper()

AdvectionDiffusionStepper::AdvectionDiffusionStepper ( RefCountedPtr< CdrSolver > &  a_solver)

Full constructor. Delegates to the default constructor and then stores the provided solver.

Parameters
[in]a_solverCDR solver to use for the advection-diffusion advance.

Member Function Documentation

◆ advance()

Real AdvectionDiffusionStepper::advance ( const Real  a_dt)
overridevirtual

Advance the solution by one time step using the selected integrator.

Parameters
[in]a_dtTime step size in seconds.
Returns
The time step actually used (equal to a_dt).

Implements TimeStepper.

◆ allocate()

void AdvectionDiffusionStepper::allocate ( )
overridevirtual

Allocate internal storage in the solver.

Implements TimeStepper.

◆ computeDt()

Real AdvectionDiffusionStepper::computeDt ( )
overridevirtual

Compute the next time step.

For Heun integration the advection-diffusion CFL limit is used; for IMEX only the advection CFL limit is used since diffusion is treated implicitly. The result is clamped to [m_minDt, m_maxDt].

Returns
Time step size in seconds.

Implements TimeStepper.

◆ getNumberOfPlotVariables()

int AdvectionDiffusionStepper::getNumberOfPlotVariables ( ) const
overridevirtual

Return the number of output variables contributed by this stepper.

Returns
Number of plot variables (delegated to the solver).

Implements TimeStepper.

◆ getPlotVariableNames()

Vector< std::string > AdvectionDiffusionStepper::getPlotVariableNames ( ) const
overridevirtual

Return the names of the output variables contributed by this stepper.

Returns
Variable name list (delegated to the solver).

Implements TimeStepper.

◆ initialData()

void AdvectionDiffusionStepper::initialData ( )
overridevirtual

Fill the solver with initial data and set velocity, diffusion coefficient, and source term.

Implements TimeStepper.

◆ parseRuntimeOptions()

void AdvectionDiffusionStepper::parseRuntimeOptions ( )
overridevirtual

Parse runtime options from ParmParse. Re-reads verbosity, CFL bounds, and integrator.

Reimplemented from TimeStepper.

◆ postCheckpointSetup()

void AdvectionDiffusionStepper::postCheckpointSetup ( )
overridevirtual

Post-checkpoint setup. Re-applies velocity, diffusion coefficient, source, and EB flux after a restart so the solver fields are consistent with the loaded state.

Implements TimeStepper.

◆ postInitialize()

void Physics::AdvectionDiffusion::AdvectionDiffusionStepper::postInitialize ( )
inlineoverridevirtual

Post-initialization hook. No operations are performed.

Implements TimeStepper.

◆ postRegrid()

void Physics::AdvectionDiffusion::AdvectionDiffusionStepper::postRegrid ( )
inlineoverridevirtual

Post-regrid hook. No operations are performed.

Implements TimeStepper.

◆ preRegrid()

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

Pre-regrid hook. Notifies the solver to store data before the mesh changes.

Parameters
[in]a_lbaseCoarsest level that will change.
[in]a_oldFinestLevelFinest level before the regrid.

Implements TimeStepper.

◆ printStepReport()

void Physics::AdvectionDiffusion::AdvectionDiffusionStepper::printStepReport ( )
inlineoverridevirtual

Print a step report. No output is produced.

Implements TimeStepper.

◆ registerOperators()

void AdvectionDiffusionStepper::registerOperators ( )
overridevirtual

Register the operators required by the solver.

Implements TimeStepper.

◆ registerRealms()

void AdvectionDiffusionStepper::registerRealms ( )
overridevirtual

Register the Primal realm with the AMR mesh.

Implements TimeStepper.

◆ regrid()

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

Regrid the solver and re-apply the flow fields on the new mesh.

Parameters
[in]a_lminCoarsest level that changed.
[in]a_oldFinestLevelFinest level before regridding.
[in]a_newFinestLevelFinest level after regridding.

Implements TimeStepper.

◆ setCFL()

void AdvectionDiffusionStepper::setCFL ( const Real  a_cfl)

Force a specific CFL number, overriding the value read from input.

Parameters
[in]a_cflCFL number to use.

◆ setDiffusionCoefficient()

void AdvectionDiffusionStepper::setDiffusionCoefficient ( const std::function< Real(const RealVect &a_position)> &  a_diffusion)
noexcept

Override the diffusion coefficient functor.

Parameters
[in]a_diffusionFunctor returning the diffusion coefficient at a given position.

◆ setInitialData()

void AdvectionDiffusionStepper::setInitialData ( const std::function< Real(const RealVect &a_position)> &  a_initData)
noexcept

Override the initial data functor.

Parameters
[in]a_initDataFunctor returning the initial scalar concentration at a given position.

◆ setupSolvers()

void AdvectionDiffusionStepper::setupSolvers ( )
overridevirtual

Instantiate the species and configure the solver with realm, phase, and AMR data.

Implements TimeStepper.

◆ setVelocity()

void AdvectionDiffusionStepper::setVelocity ( const std::function< RealVect(const RealVect &a_position)> &  a_velocity)
noexcept

Override the velocity field functor.

Parameters
[in]a_velocityFunctor returning the advection velocity at a given position.

◆ synchronizeSolverTimes()

void AdvectionDiffusionStepper::synchronizeSolverTimes ( const int  a_step,
const Real  a_time,
const Real  a_dt 
)
overridevirtual

Update internal time/step counters and forward them to the solver.

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

Implements TimeStepper.

◆ writePlotData()

void AdvectionDiffusionStepper::writePlotData ( LevelData< EBCellFAB > &  a_output,
int a_icomp,
const std::string a_outputRealm,
const int  a_level 
) const
overridevirtual

Write plot data into the output holder.

Parameters
[in,out]a_outputOutput data holder.
[in,out]a_icompStarting component index in a_output; incremented on return.
[in]a_outputRealmRealm that owns a_output.
[in]a_levelAMR level to write.

Implements TimeStepper.


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