chombo-discharge
|
Implementation of TimeStepper which advances an ItoSolver. More...
#include <CD_BrownianWalkerStepper.H>
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< ItoSolver > | m_solver |
Reference to underlying solver. | |
RefCountedPtr< ItoSpecies > | m_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< AmrMesh > | m_amr |
AmrMesh. | |
RefCountedPtr< ComputationalGeometry > | m_computationalGeometry |
Computational geometry. | |
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.
|
overridevirtual |
|
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.
|
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.
[in] | a_realm | Realm |
[in] | a_level | Grid level |
Reimplemented from TimeStepper.
|
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.
|
overridevirtual |
Load balance grid boxes for a specific realm.
This will count the number of particles in each box and then load balance them.
[out] | a_procs | MPI ranks owning the various grid boxes. |
[out] | a_boxes | Grid boxes on every level (obtain them with a_grids[lvl].boxArray()) |
[in] | a_realm | Realm identifier |
[in] | a_grids | Original grids |
[in] | a_lmin | Coarsest grid level that changed |
[in] | a_finestLevel | New finest grid level |
Reimplemented from TimeStepper.
|
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
[out] | a_procs | MPI ranks owning the various grid boxes. |
[out] | a_boxes | Grid boxes on every level (obtain them with a_grids[lvl].boxArray()) |
[in] | a_realm | Realm identifier |
[in] | a_grids | Original grids |
[in] | a_lmin | Coarsest grid level that changed |
[in] | a_finestLevel | New finest grid level |
|
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.
[out] | a_procs | MPI ranks owning the various grid boxes. |
[out] | a_boxes | Grid boxes on every level (obtain them with a_grids[lvl].boxArray()) |
[in] | a_realm | Realm identifier |
[in] | a_grids | Original grids |
[in] | a_lmin | Coarsest grid level that changed |
[in] | a_finestLevel | New finest grid level |
|
overridevirtual |
Check if the input realm should be load balanced.
[in] | a_realm | Realm to be load balanced. |
This returns true if a_realm==m_realm and m_loadBalance==true.
Reimplemented from TimeStepper.
|
overridevirtual |
Perform post-initialization routines.
This remaps the particles and makes new superparticles. It also sets the velocity fields.
Implements TimeStepper.
|
overridevirtual |
Perform pre-regrid operations.
[in] | a_lmin | The coarsest level that changes |
[in] | a_oldFinestLevel | The finest level before the regrid. |
Implements TimeStepper.
|
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.
|
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.
|
overridevirtual |
Regrid method. This just regrids the solver.
[in] | a_lmin | The coarsest level that changed. |
[in] | a_oldFinestLevel | The finest level before the regrid. |
[in] | a_newFinestLevel | The finest level after the regrid. |
Implements TimeStepper.
|
overridevirtual |
Synchronize solver times.
[in] | a_step | Time step |
[in] | a_time | Time (in seconds) |
[in] | a_dt | Time step that was used. |
Implements TimeStepper.
|
overridevirtual |
Write plot data to output holder.
[in,out] | a_output | Output data holder. |
[in,out] | a_icomp | Starting component in a_output to begin at. |
[in] | a_outputRealm | Realm where a_output belongs |
[in] | a_level | Grid level |
Implements TimeStepper.