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

Implementation of TimeStepper which advances an ItoSolver. 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 basic options.
 
 BrownianWalkerStepper (RefCountedPtr< ItoSolver > &a_solver)
 Full constructor. Calls the basic constructor and sets solver.
 
virtual ~BrownianWalkerStepper ()
 Destructor (does nothing)
 
void initialData () override
 Fill solver with initial data.
 
void allocate () override
 Allocate storage for solvers and TimeStepper.
 
void postInitialize () override
 Perform post-initialization routines. This does nothing.
 
bool loadBalanceThisRealm (const std::string a_realm) const override
 Check if the input realm should be load balanced. More...
 
Vector< long int > getCheckpointLoads (const std::string a_realm, const int a_level) const override
 Get computational loads to be checkpointed. This is used by Driver both for plotting computational loads AND for checkpointing the loads for restart purposes. More...
 
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 specific realm. More...
 
void postCheckpointSetup () override
 Perform post-initialization routines. More...
 
int getNumberOfPlotVariables () const override
 Get the number of plot variables for this time stepper. More...
 
Vector< std::string > getPlotVariableNames () 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. More...
 
Real computeDt () override
 Compute a time step to be used by Driver. More...
 
void synchronizeSolverTimes (const int a_step, const Real a_time, const Real a_dt) override
 Synchronize solver times. More...
 
void printStepReport () override
 Print a step report – this prints the local and global number of particles in the simulation. More...
 
void registerOperators () override
 Register operators – we only need the ones the solver needs to have the solver do this.
 
void registerRealms () override
 Register realms to be used in the simulation. More...
 
void parseRuntimeOptions () override
 Parse runtime options.
 
bool needToRegrid () override
 Always returns false.
 
void preRegrid (const int a_lbase, const int a_oldFinestLevel) override
 Perform pre-regrid operations. More...
 
void setupSolvers () override
 Set up the Ito solver. This instantiates the solver and parses solver options.
 
Real advance (const Real a_dt) override
 Advancement method. More...
 
void regrid (const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override
 Regrid method. This just regrids the solver. More...
 
void postRegrid () override
 Post-regrid operations.
 
- Public Member Functions inherited from TimeStepper
 TimeStepper ()
 Default constructor (does nothing)
 
virtual ~TimeStepper ()
 Default destructor (does nothing)
 
void setAmr (const RefCountedPtr< AmrMesh > &a_amr)
 Set AmrMesh. More...
 
void setComputationalGeometry (const RefCountedPtr< ComputationalGeometry > &a_computationalGeometry)
 Set the computational geometry. More...
 
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.
 

Protected Types

enum  LoadBalancingMethod { Mesh , Particle }
 For classifying load balancing methods.
 

Protected Member Functions

void setAdvectionDiffusion ()
 Set advection and diffusion fields.
 
void setVelocity ()
 Set the Brownian walker advection field.
 
void setDiffusion ()
 Set the ItoSolver "diffusion field".
 
void makeSuperParticles ()
 Make super particles.
 
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)
 Method that shows how to load balance the application using the number of particles per cell stored on the mesh. More...
 
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)
 Method that shows how to load balance the application using the number of particles per cell stored on the mesh. More...
 

Protected Attributes

LoadBalancingMethod m_whichLoadBalance
 Load balancing method.
 
std::string m_realm
 Realm where the particles live.
 
phase::which_phase m_phase
 Phase where the particles live.
 
bool m_loadBalance
 If true, application will be load balanced.
 
RefCountedPtr< ItoSolverm_solver
 Reference to underlying solver.
 
RefCountedPtr< ItoSpeciesm_species
 Reference to underlying species.
 
EBAMRCellData m_regridPPC
 Number of particles per cell. Used only during regrids.
 
Real m_diffCo
 Fluid diffusion coefficient.
 
Real m_mobility
 Particle mobility coefficients.
 
Real m_omega
 Angular velocity for advection field.
 
int m_ppc
 Number of particles per cell.
 
Real m_cfl
 Effective CFL number for particle hops.
 
- 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.
 
RefCountedPtr< AmrMeshm_amr
 AmrMesh.
 
RefCountedPtr< ComputationalGeometrym_computationalGeometry
 Computational geometry.
 

Detailed Description

Implementation of TimeStepper which advances an ItoSolver.

This class is fairly simple – we want to advance particles using an Ito kernel dX = V*dt + sqrt(2*D*dt)*N0 where N0 is a Gaussian random number. The particle velocity in the ItoSolver is V = mu*v(Xp) where mu is a particle mobility and v is a "velocity field". The ItoSolver has various way of representing the velocity, but here we consider a constant mobility. The diffusion coefficient is also constant (the value is fetched from the input script).

Note that while the ItoSolver CAN interpolate the particle diffusion coefficient from a mesh quantity – this physics module sets it directly.

This physics module shows how to load balance an application introspectively based on the number of particles assigned to each rank. We support two methods, either by estimating the number of particles on the new mesh, or counting them directly.

Member Function Documentation

◆ advance()

Real BrownianWalkerStepper::advance ( const Real  a_dt)
overridevirtual

Advancement method.

Returns
a_dt

Implements TimeStepper.

◆ computeDt()

Real BrownianWalkerStepper::computeDt ( )
overridevirtual

Compute a time step to be used by Driver.

This returns m_cfl*ItoSolver::computeDt (i.e. m_cfl is a CFL-like number)

Implements TimeStepper.

◆ getCheckpointLoads()

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

Get computational loads to be checkpointed. This is used by Driver both for plotting computational loads AND for checkpointing the loads for restart purposes.

This uses the number of computational particles as a load metric.

Parameters
[in]a_realmRealm
[in]a_levelGrid level

Reimplemented from TimeStepper.

◆ getNumberOfPlotVariables()

int BrownianWalkerStepper::getNumberOfPlotVariables ( ) const
overridevirtual

Get the number of plot variables for this time stepper.

Only the solver plots to file so this just returns the number of plot variables specified for the solver

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 boxes for a specific realm.

This will count the number of particles in each box and then load balance them.

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
Note
This should only be called if a_realm==m_realm and m_loadBalance==true

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

Method that shows how to load balance the application using the number of particles per cell stored on the mesh.

This routine will load balance based on an estimated number of particles per cell. This number is computed ON THE MESH, i.e. it does not directly count the particles. Rather, we happen to know that ItoSolver deposited his particle numbers to the mesh before in the preRegrid, and we use that information to estimate the number of particles per patch in the new grids.

This is different from the other method which assign particles to the new grids and then counts them. Because this routine does not remap particles (which can be expensive), this routine is typically faster than loadBalanceBoxesParticles. loadBalanceBoxesParticles

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

◆ 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

Method that shows how to load balance the application using the number of particles per cell stored on the mesh.

This routine will load balance by directly counting the particles on the new mesh. The result of that is that we regrid a particle data holder twice.

Because this routine ends up remapping particles twice (once here, and once in BrownianWalkerStepper::regrid), this routine is usually slower than loadBalanceBoxesMesh when used at large particle counts. In addition, loadBalanceBoxesMesh does it's best at estimating the final number of computatational particles after particle merging/splitting, while this routine only counts the original computational particles before the regrid.

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

◆ loadBalanceThisRealm()

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

Check if the input realm should be load balanced.

Parameters
[in]a_realmRealm to be load balanced.

This returns true if a_realm==m_realm and m_loadBalance==true.

Reimplemented from TimeStepper.

◆ postCheckpointSetup()

void BrownianWalkerStepper::postCheckpointSetup ( )
overridevirtual

Perform post-initialization routines.

This remaps the particles and makes new superparticles. It also sets the velocity fields.

Implements TimeStepper.

◆ preRegrid()

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

Perform pre-regrid operations.

Parameters
[in]a_lminThe coarsest level that changes
[in]a_oldFinestLevelThe finest level before the regrid.

Implements TimeStepper.

◆ printStepReport()

void BrownianWalkerStepper::printStepReport ( )
overridevirtual

Print a step report – this prints the local and global number of particles in the simulation.

This is called by Driver after time step.

Implements TimeStepper.

◆ registerRealms()

void BrownianWalkerStepper::registerRealms ( )
overridevirtual

Register realms to be used in the simulation.

The primal realm is always register – but you can also register a separate particle realm.

Implements TimeStepper.

◆ regrid()

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

Regrid method. This just regrids the solver.

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.

◆ synchronizeSolverTimes()

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

Synchronize solver times.

Parameters
[in]a_stepTime step
[in]a_timeTime (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 to output holder.

Parameters
[in,out]a_outputOutput data holder.
[in,out]a_icompStarting component in a_output to begin at.
[in]a_outputRealmRealm where a_output belongs
[in]a_levelGrid level

Implements TimeStepper.


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