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

TimeStepper implementation for advancing Brownian walker particles. More...

#include <CD_BrownianWalkerStepper.H>

Inheritance diagram for Physics::BrownianWalker::BrownianWalkerStepper:
Inheritance graph
[legend]
Collaboration diagram for Physics::BrownianWalker::BrownianWalkerStepper:
Collaboration graph
[legend]

Public Member Functions

 BrownianWalkerStepper ()
 Default constructor. Parses all options from the BrownianWalker ParmParse block.
 
 BrownianWalkerStepper (RefCountedPtr< ItoSolver > &a_solver)
 Full constructor. Delegates to the default constructor and stores the provided solver.
 
virtual ~BrownianWalkerStepper ()
 Destructor.
 
void initialData () override
 Fill the solver with initial particles, make superparticles, and set flow fields.
 
void allocate () override
 Allocate internal storage in the solver.
 
void postInitialize () override
 Post-initialization hook. No operations are performed.
 
bool loadBalanceThisRealm (const std::string &a_realm) const override
 Return whether the given realm should be load balanced by this stepper.
 
Vector< long intgetCheckpointLoads (const std::string &a_realm, const int a_level) const override
 Return per-patch computational loads for checkpointing and plotting.
 
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 patches for the specified realm.
 
void postCheckpointSetup () override
 Post-checkpoint setup. Remaps particles, makes superparticles, and restores advection and diffusion fields after a restart.
 
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 as m_cfl * ItoSolver::computeDt().
 
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 showing the local and global particle counts.
 
void registerOperators () override
 Register the operators required by the solver.
 
void registerRealms () override
 Register the realm(s) used in the simulation.
 
void parseRuntimeOptions () override
 Parse runtime options from ParmParse. Re-reads verbosity, ppc, CFL, and load balancing flag.
 
bool needToRegrid () override
 Always returns false; regridding is triggered externally by Driver.
 
void preRegrid (const int a_lbase, const int a_oldFinestLevel) override
 Pre-regrid hook. Deposits particle counts onto the mesh and puts the solver in pre-regrid mode.
 
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 particle system by one Euler-Maruyama step.
 
void regrid (const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
 Regrid the solver onto the new mesh and remake superparticles.
 
void postRegrid () override
 Post-regrid hook. Clears temporary mesh storage and restores flow fields.
 
- 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.
 
bool keepGoing () const
 Query whether the time stepper wants to continue stepping.
 

Protected Types

enum  LoadBalancingMethod { Mesh , Particle }
 Supported load balancing strategies. More...
 

Protected Member Functions

void setAdvectionDiffusion ()
 Set the velocity and diffusion fields on the mesh if the solver is mobile/diffusive.
 
void setVelocity ()
 Compute and assign the solid-body rotation velocity field to the solver.
 
void setDiffusion ()
 Set the mesh diffusion function on the solver.
 
void makeSuperParticles ()
 Sort particles by cell, merge to m_ppc per cell, then re-sort by patch.
 
void loadBalanceBoxesMesh (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)
 Load balance using particle counts estimated from mesh-deposited data.
 
void loadBalanceBoxesParticles (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)
 Load balance by directly remapping particles to the new grids and counting them.
 

Protected Attributes

LoadBalancingMethod m_whichLoadBalance
 Selected load balancing strategy.
 
std::string m_realm
 Name of the realm on which the particles live.
 
phase::which_phase m_phase
 Computational phase on which the particles live.
 
bool m_loadBalance
 If true, the application performs particle-based load balancing at each regrid.
 
RefCountedPtr< ItoSolverm_solver
 The Ito solver used to advance the particle system.
 
RefCountedPtr< ItoSpeciesm_species
 Species definition passed to the Ito solver.
 
EBAMRCellData m_regridPPC
 Temporary storage for the number of particles per cell, used during load balancing.
 
Real m_diffCo
 Spatially uniform diffusion coefficient for all particles.
 
Real m_mobility
 Spatially uniform particle mobility.
 
Real m_omega
 Angular velocity of the solid-body rotation advection field.
 
int m_ppc
 Target number of computational particles per cell after superparticle merging.
 
Real m_cfl
 CFL-like scaling factor applied to the solver's intrinsic time step estimate.
 
- 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 Brownian walker particles.

This class drives a single ItoSolver using an Euler-Maruyama scheme:

\[ \mathbf{X}^{n+1} = \mathbf{X}^n + \mathbf{V}\,\Delta t + \sqrt{2D\,\Delta t}\,\mathbf{N}(0,1) \]

where \(\mathbf{V}\) is the advection velocity, \(D\) is the diffusion coefficient, and \(\mathbf{N}(0,1)\) is a standard Gaussian random vector.

The velocity field is a solid-body rotation with angular velocity \(\omega\), and both the mobility and diffusion coefficient are spatially uniform and set directly on each particle.

This module demonstrates two particle-based load balancing strategies:

Member Enumeration Documentation

◆ LoadBalancingMethod

Supported load balancing strategies.

Enumerator
Mesh 

Estimate particle counts from mesh-deposited data (fast).

Particle 

Count particles directly by remapping to the new grids (accurate).

Constructor & Destructor Documentation

◆ BrownianWalkerStepper()

BrownianWalkerStepper::BrownianWalkerStepper ( RefCountedPtr< ItoSolver > &  a_solver)

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

Parameters
[in]a_solverIto solver to use for particle advancement.

Member Function Documentation

◆ advance()

Real BrownianWalkerStepper::advance ( const Real  a_dt)
overridevirtual

Advance the particle system by one Euler-Maruyama step.

Performs: advection hop, diffusion hop, remap, EB absorption, superparticle merging, field update, and mesh deposition.

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

Implements TimeStepper.

◆ allocate()

void BrownianWalkerStepper::allocate ( )
overridevirtual

Allocate internal storage in the solver.

Implements TimeStepper.

◆ computeDt()

Real BrownianWalkerStepper::computeDt ( )
overridevirtual

Compute the next time step as m_cfl * ItoSolver::computeDt().

Returns
Time step size in seconds.

Implements TimeStepper.

◆ getCheckpointLoads()

Vector< long int > BrownianWalkerStepper::getCheckpointLoads ( const std::string a_realm,
const int  a_level 
) const
overridevirtual

Return per-patch computational loads for checkpointing and plotting.

Uses the number of particles in each grid patch as the load metric.

Parameters
[in]a_realmRealm identifier.
[in]a_levelAMR level.
Returns
Vector of particle counts, one entry per grid patch on a_level.

Reimplemented from TimeStepper.

◆ getNumberOfPlotVariables()

int BrownianWalkerStepper::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 > BrownianWalkerStepper::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 BrownianWalkerStepper::initialData ( )
overridevirtual

Fill the solver with initial particles, make superparticles, and set flow fields.

Implements TimeStepper.

◆ loadBalanceBoxes()

void BrownianWalkerStepper::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 patches for the specified realm.

Dispatches to either loadBalanceBoxesMesh or loadBalanceBoxesParticles depending on m_whichLoadBalance.

Parameters
[out]a_procsMPI rank assigned to each grid patch.
[out]a_boxesGrid patches on each level.
[in]a_realmRealm identifier.
[in]a_gridsCurrent grids before load balancing.
[in]a_lminCoarsest level that changed.
[in]a_finestLevelFinest level after regridding.

Reimplemented from TimeStepper.

◆ loadBalanceBoxesMesh()

void BrownianWalkerStepper::loadBalanceBoxesMesh ( 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 
)
protected

Load balance using particle counts estimated from mesh-deposited data.

Uses the particle-per-cell data deposited during preRegrid to estimate the post-regrid particle distribution without remapping particles. Faster than loadBalanceBoxesParticles but may be less accurate after superparticle merging.

Parameters
[out]a_procsMPI rank assigned to each grid patch.
[out]a_boxesGrid patches on each level.
[in]a_realmRealm identifier.
[in]a_gridsCurrent grids.
[in]a_lminCoarsest level that changed.
[in]a_finestLevelFinest level after regridding.

◆ loadBalanceBoxesParticles()

void BrownianWalkerStepper::loadBalanceBoxesParticles ( 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 
)
protected

Load balance by directly remapping particles to the new grids and counting them.

More accurate than loadBalanceBoxesMesh, but requires remapping the particle data twice (once here and once in regrid), making it slower at large particle counts.

Parameters
[out]a_procsMPI rank assigned to each grid patch.
[out]a_boxesGrid patches on each level.
[in]a_realmRealm identifier.
[in]a_gridsCurrent grids.
[in]a_lminCoarsest level that changed.
[in]a_finestLevelFinest level after regridding.

◆ loadBalanceThisRealm()

bool BrownianWalkerStepper::loadBalanceThisRealm ( const std::string a_realm) const
overridevirtual

Return whether the given realm should be load balanced by this stepper.

Parameters
[in]a_realmRealm identifier to query.
Returns
True if a_realm matches m_realm and load balancing is enabled.

Reimplemented from TimeStepper.

◆ needToRegrid()

bool BrownianWalkerStepper::needToRegrid ( )
overridevirtual

Always returns false; regridding is triggered externally by Driver.

Returns
False.

Reimplemented from TimeStepper.

◆ parseRuntimeOptions()

void BrownianWalkerStepper::parseRuntimeOptions ( )
overridevirtual

Parse runtime options from ParmParse. Re-reads verbosity, ppc, CFL, and load balancing flag.

Reimplemented from TimeStepper.

◆ postCheckpointSetup()

void BrownianWalkerStepper::postCheckpointSetup ( )
overridevirtual

Post-checkpoint setup. Remaps particles, makes superparticles, and restores advection and diffusion fields after a restart.

Implements TimeStepper.

◆ postInitialize()

void BrownianWalkerStepper::postInitialize ( )
overridevirtual

Post-initialization hook. No operations are performed.

Implements TimeStepper.

◆ postRegrid()

void BrownianWalkerStepper::postRegrid ( )
overridevirtual

Post-regrid hook. Clears temporary mesh storage and restores flow fields.

Implements TimeStepper.

◆ preRegrid()

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

Pre-regrid hook. Deposits particle counts onto the mesh and puts the solver in pre-regrid mode.

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

Implements TimeStepper.

◆ printStepReport()

void BrownianWalkerStepper::printStepReport ( )
overridevirtual

Print a step report showing the local and global particle counts.

Implements TimeStepper.

◆ registerOperators()

void BrownianWalkerStepper::registerOperators ( )
overridevirtual

Register the operators required by the solver.

Implements TimeStepper.

◆ registerRealms()

void BrownianWalkerStepper::registerRealms ( )
overridevirtual

Register the realm(s) used in the simulation.

Implements TimeStepper.

◆ regrid()

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

Regrid the solver onto the new mesh and remake superparticles.

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

Implements TimeStepper.

◆ setDiffusion()

void BrownianWalkerStepper::setDiffusion ( )
protected

Set the mesh diffusion function on the solver.

Sets a sentinel large value since actual per-particle diffusion is assigned directly.

◆ setupSolvers()

void BrownianWalkerStepper::setupSolvers ( )
overridevirtual

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

Implements TimeStepper.

◆ synchronizeSolverTimes()

void BrownianWalkerStepper::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 BrownianWalkerStepper::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: