chombo-discharge
Loading...
Searching...
No Matches
CD_BrownianWalkerStepper.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_BROWNIANWALKERSTEPPER_H
14#define CD_BROWNIANWALKERSTEPPER_H
15
16// Our includes
17#include <CD_TimeStepper.H>
18#include <CD_ItoSolver.H>
19#include <CD_ItoLayout.H>
20#include <CD_NamespaceHeader.H>
21
22namespace Physics {
23 namespace BrownianWalker {
24
40 {
41 public:
46
51 BrownianWalkerStepper(RefCountedPtr<ItoSolver>& a_solver);
52
56 virtual ~BrownianWalkerStepper();
57
61 void
62 initialData() override;
63
67 void
68 allocate() override;
69
73 void
74 postInitialize() override;
75
81 bool
82 loadBalanceThisRealm(const std::string& a_realm) const override;
83
91 Vector<long int>
92 getCheckpointLoads(const std::string& a_realm, const int a_level) const override;
93
105 void
106 loadBalanceBoxes(Vector<Vector<int>>& a_procs,
107 Vector<Vector<Box>>& a_boxes,
108 const std::string& a_realm,
109 const Vector<DisjointBoxLayout>& a_grids,
110 const int a_lmin,
111 const int a_finestLevel) override;
112
113#ifdef CH_USE_HDF5
119 void
120 writeCheckpointData(HDF5Handle& a_handle, const int a_lvl) const override;
121#endif
122
123#ifdef CH_USE_HDF5
129 void
130 readCheckpointData(HDF5Handle& a_handle, const int a_lvl) override;
131#endif
132
137 void
138 postCheckpointSetup() override;
139
144 int
145 getNumberOfPlotVariables() const override;
146
151 Vector<std::string>
152 getPlotVariableNames() const override;
153
161 void
162 writePlotData(LevelData<EBCellFAB>& a_output,
163 int& a_icomp,
164 const std::string& a_outputRealm,
165 const int a_level) const override;
166
171 Real
172 computeDt() override;
173
180 void
181 synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override;
182
186 void
187 printStepReport() override;
188
192 void
193 registerOperators() override;
194
198 void
199 registerRealms() override;
200
204 void
205 parseRuntimeOptions() override;
206
211 bool
212 needToRegrid() override;
213
219 void
220 preRegrid(const int a_lbase, const int a_oldFinestLevel) override;
221
225 void
226 setupSolvers() override;
227
235 Real
236 advance(const Real a_dt) override;
237
244 void
245 regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
246
250 void
251 postRegrid() override;
252
253 protected:
262
267
271 std::string m_realm;
272
277
282
286 RefCountedPtr<ItoSolver> m_solver;
287
291 RefCountedPtr<ItoSpecies> m_species;
292
296 EBAMRCellData m_regridPPC;
297
302
307
312
316 int m_ppc;
317
321 Real m_cfl;
322
326 void
328
332 void
333 setVelocity();
334
339 void
340 setDiffusion();
341
345 void
347
360 void
361 loadBalanceBoxesMesh(Vector<Vector<int>>& a_procs,
362 Vector<Vector<Box>>& a_boxes,
363 const std::string& a_realm,
364 const Vector<DisjointBoxLayout>& a_grids,
365 const int a_lmin,
366 const int a_finestLevel);
367
379 void
380 loadBalanceBoxesParticles(Vector<Vector<int>>& a_procs,
381 Vector<Vector<Box>>& a_boxes,
382 const std::string& a_realm,
383 const Vector<DisjointBoxLayout>& a_grids,
384 const int a_lmin,
385 const int a_finestLevel);
386 };
387 } // namespace BrownianWalker
388} // namespace Physics
389
390#include <CD_NamespaceFooter.H>
391
392#endif
Declaration of a class that holds a set of ItoSolvers.
Declaration of solver class for Ito diffusion.
Declaration of main (abstract) time stepper class.
TimeStepper implementation for advancing Brownian walker particles.
Definition CD_BrownianWalkerStepper.H:40
phase::which_phase m_phase
Computational phase on which the particles live.
Definition CD_BrownianWalkerStepper.H:276
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.
Definition CD_BrownianWalkerStepper.cpp:370
bool needToRegrid() override
Always returns false; regridding is triggered externally by Driver.
Definition CD_BrownianWalkerStepper.cpp:359
Real m_diffCo
Spatially uniform diffusion coefficient for all particles.
Definition CD_BrownianWalkerStepper.H:301
void setupSolvers() override
Instantiate the species and configure the solver with realm, phase, and AMR data.
Definition CD_BrownianWalkerStepper.cpp:400
LoadBalancingMethod m_whichLoadBalance
Selected load balancing strategy.
Definition CD_BrownianWalkerStepper.H:266
EBAMRCellData m_regridPPC
Temporary storage for the number of particles per cell, used during load balancing.
Definition CD_BrownianWalkerStepper.H:296
int getNumberOfPlotVariables() const override
Return the number of output variables contributed by this stepper.
Definition CD_BrownianWalkerStepper.cpp:275
BrownianWalkerStepper()
Default constructor. Parses all options from the BrownianWalker ParmParse block.
Definition CD_BrownianWalkerStepper.cpp:27
RefCountedPtr< ItoSolver > m_solver
The Ito solver used to advance the particle system.
Definition CD_BrownianWalkerStepper.H:286
Real m_cfl
CFL-like scaling factor applied to the solver's intrinsic time step estimate.
Definition CD_BrownianWalkerStepper.H:321
Real advance(const Real a_dt) override
Advance the particle system by one Euler-Maruyama step.
Definition CD_BrownianWalkerStepper.cpp:450
std::string m_realm
Name of the realm on which the particles live.
Definition CD_BrownianWalkerStepper.H:271
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.
Definition CD_BrownianWalkerStepper.cpp:192
bool m_loadBalance
If true, the application performs particle-based load balancing at each regrid.
Definition CD_BrownianWalkerStepper.H:281
LoadBalancingMethod
Supported load balancing strategies.
Definition CD_BrownianWalkerStepper.H:258
@ Mesh
Estimate particle counts from mesh-deposited data (fast).
Definition CD_BrownianWalkerStepper.H:259
@ Particle
Count particles directly by remapping to the new grids (accurate).
Definition CD_BrownianWalkerStepper.H:260
void makeSuperParticles()
Sort particles by cell, merge to m_ppc per cell, then re-sort by patch.
Definition CD_BrownianWalkerStepper.cpp:563
void printStepReport() override
Print a step report showing the local and global particle counts.
Definition CD_BrownianWalkerStepper.cpp:344
void parseRuntimeOptions() override
Parse runtime options from ParmParse. Re-reads verbosity, ppc, CFL, and load balancing flag.
Definition CD_BrownianWalkerStepper.cpp:71
void setDiffusion()
Set the mesh diffusion function on the solver.
Definition CD_BrownianWalkerStepper.cpp:134
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.
Definition CD_BrownianWalkerStepper.cpp:327
int m_ppc
Target number of computational particles per cell after superparticle merging.
Definition CD_BrownianWalkerStepper.H:316
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.
Definition CD_BrownianWalkerStepper.cpp:527
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.
Definition CD_BrownianWalkerStepper.cpp:299
void postCheckpointSetup() override
Post-checkpoint setup. Remaps particles, makes superparticles, and restores advection and diffusion f...
Definition CD_BrownianWalkerStepper.cpp:252
void registerRealms() override
Register the realm(s) used in the simulation.
Definition CD_BrownianWalkerStepper.cpp:419
void postRegrid() override
Post-regrid hook. Clears temporary mesh storage and restores flow fields.
Definition CD_BrownianWalkerStepper.cpp:542
Real m_omega
Angular velocity of the solid-body rotation advection field.
Definition CD_BrownianWalkerStepper.H:311
void allocate() override
Allocate internal storage in the solver.
Definition CD_BrownianWalkerStepper.cpp:441
Vector< std::string > getPlotVariableNames() const override
Return the names of the output variables contributed by this stepper.
Definition CD_BrownianWalkerStepper.cpp:288
Vector< long int > getCheckpointLoads(const std::string &a_realm, const int a_level) const override
Return per-patch computational loads for checkpointing and plotting.
Definition CD_BrownianWalkerStepper.cpp:806
RefCountedPtr< ItoSpecies > m_species
Species definition passed to the Ito solver.
Definition CD_BrownianWalkerStepper.H:291
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.
Definition CD_BrownianWalkerStepper.cpp:719
virtual ~BrownianWalkerStepper()
Destructor.
Definition CD_BrownianWalkerStepper.cpp:65
void postInitialize() override
Post-initialization hook. No operations are performed.
Definition CD_BrownianWalkerStepper.cpp:108
bool loadBalanceThisRealm(const std::string &a_realm) const override
Return whether the given realm should be load balanced by this stepper.
Definition CD_BrownianWalkerStepper.cpp:181
void initialData() override
Fill the solver with initial particles, make superparticles, and set flow fields.
Definition CD_BrownianWalkerStepper.cpp:86
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.
Definition CD_BrownianWalkerStepper.cpp:581
Real m_mobility
Spatially uniform particle mobility.
Definition CD_BrownianWalkerStepper.H:306
void setVelocity()
Compute and assign the solid-body rotation velocity field to the solver.
Definition CD_BrownianWalkerStepper.cpp:148
Real computeDt() override
Compute the next time step as m_cfl * ItoSolver::computeDt().
Definition CD_BrownianWalkerStepper.cpp:316
void setAdvectionDiffusion()
Set the velocity and diffusion fields on the mesh if the solver is mobile/diffusive.
Definition CD_BrownianWalkerStepper.cpp:117
void registerOperators() override
Register the operators required by the solver.
Definition CD_BrownianWalkerStepper.cpp:430
Base class for advancing equations.
Definition CD_TimeStepper.H:31
Namespace containing physics models for use with chombo-discharge.
Definition CD_AdvectionDiffusion.H:16
which_phase
Enumeration of supported phases.
Definition CD_MultiFluidIndexSpace.H:38