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 {
23namespace BrownianWalker {
24
40{
41public:
46
54 BrownianWalkerStepper(const std::string& a_className);
55
61 BrownianWalkerStepper(RefCountedPtr<ItoSolver>& a_solver, const std::string& a_className);
62
67 BrownianWalkerStepper(RefCountedPtr<ItoSolver>& a_solver);
68
72 virtual ~BrownianWalkerStepper();
73
77 void
78 initialData() override;
79
83 void
84 allocate() override;
85
89 void
90 postInitialize() override;
91
97 bool
98 loadBalanceThisRealm(const std::string& a_realm) const override;
99
107 Vector<long int>
108 getCheckpointLoads(const std::string& a_realm, const int a_level) const override;
109
121 void
122 loadBalanceBoxes(Vector<Vector<int>>& a_procs,
123 Vector<Vector<Box>>& a_boxes,
124 const std::string& a_realm,
125 const Vector<DisjointBoxLayout>& a_grids,
126 const int a_lmin,
127 const int a_finestLevel) override;
128
129#ifdef CH_USE_HDF5
135 void
136 writeCheckpointData(HDF5Handle& a_handle, const int a_lvl) const override;
137#endif
138
139#ifdef CH_USE_HDF5
145 void
146 readCheckpointData(HDF5Handle& a_handle, const int a_lvl) override;
147#endif
148
153 void
154 postCheckpointSetup() override;
155
160 int
161 getNumberOfPlotVariables() const override;
162
167 Vector<std::string>
168 getPlotVariableNames() const override;
169
177 void
178 writePlotData(LevelData<EBCellFAB>& a_output,
179 int& a_icomp,
180 const std::string& a_outputRealm,
181 const int a_level) const override;
182
187 Real
188 computeDt() override;
189
196 void
197 synchronizeSolverTimes(const int a_step, const Real a_time, const Real a_dt) override;
198
202 void
203 printStepReport() override;
204
208 void
209 postPlot() override;
210
217 void
218 plotParticles() const noexcept;
219
223 void
224 registerOperators() override;
225
229 void
230 registerRealms() override;
231
235 void
236 parseRuntimeOptions() override;
237
242 bool
243 needToRegrid() override;
244
250 void
251 preRegrid(const int a_lbase, const int a_oldFinestLevel) override;
252
256 void
257 setupSolvers() override;
258
266 Real
267 advance(const Real a_dt) override;
268
275 void
276 regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) override;
277
281 void
282 postRegrid() override;
283
284protected:
293
298
302 std::string m_realm;
303
308
313
317 RefCountedPtr<ItoSolver> m_solver;
318
322 RefCountedPtr<ItoSpecies> m_species;
323
327 EBAMRCellData m_regridPPC;
328
333
338
343
349 std::string m_className;
350
358
363 RealVect m_velocity;
364
373
377 Real m_cfl;
378
382 void
384
388 void
389 setVelocity();
390
397 void
398 setDiffusion();
399
405 void
407
415 Real
417
430 void
431 loadBalanceBoxesMesh(Vector<Vector<int>>& a_procs,
432 Vector<Vector<Box>>& a_boxes,
433 const std::string& a_realm,
434 const Vector<DisjointBoxLayout>& a_grids,
435 const int a_lmin,
436 const int a_finestLevel);
437
449 void
450 loadBalanceBoxesParticles(Vector<Vector<int>>& a_procs,
451 Vector<Vector<Box>>& a_boxes,
452 const std::string& a_realm,
453 const Vector<DisjointBoxLayout>& a_grids,
454 const int a_lmin,
455 const int a_finestLevel);
456};
457} // namespace BrownianWalker
458} // namespace Physics
459
460#include <CD_NamespaceFooter.H>
461
462#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:307
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:461
bool needToRegrid() override
Always returns false; regridding is triggered externally by Driver.
Definition CD_BrownianWalkerStepper.cpp:450
Real m_diffCo
Spatially uniform diffusion coefficient for all particles.
Definition CD_BrownianWalkerStepper.H:332
std::string m_className
Input-script prefix this stepper reads its options under.
Definition CD_BrownianWalkerStepper.H:349
void setupSolvers() override
Instantiate the species and configure the solver with realm, phase, and AMR data.
Definition CD_BrownianWalkerStepper.cpp:497
LoadBalancingMethod m_whichLoadBalance
Selected load balancing strategy.
Definition CD_BrownianWalkerStepper.H:297
EBAMRCellData m_regridPPC
Temporary storage for the number of particles per cell, used during load balancing.
Definition CD_BrownianWalkerStepper.H:327
bool m_verifyConservation
If true, verify that the superparticle merge conserves the total particle weight.
Definition CD_BrownianWalkerStepper.H:372
int getNumberOfPlotVariables() const override
Return the number of output variables contributed by this stepper.
Definition CD_BrownianWalkerStepper.cpp:310
BrownianWalkerStepper()
Default constructor. Parses all options from the BrownianWalker ParmParse block.
Definition CD_BrownianWalkerStepper.cpp:29
RefCountedPtr< ItoSolver > m_solver
The Ito solver used to advance the particle system.
Definition CD_BrownianWalkerStepper.H:317
Real m_cfl
CFL-like scaling factor applied to the solver's intrinsic time step estimate.
Definition CD_BrownianWalkerStepper.H:377
Real advance(const Real a_dt) override
Advance the particle system by one Euler-Maruyama step.
Definition CD_BrownianWalkerStepper.cpp:547
std::string m_realm
Name of the realm on which the particles live.
Definition CD_BrownianWalkerStepper.H:302
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:227
bool m_loadBalance
If true, the application performs particle-based load balancing at each regrid.
Definition CD_BrownianWalkerStepper.H:312
LoadBalancingMethod
Supported load balancing strategies.
Definition CD_BrownianWalkerStepper.H:289
@ Mesh
Estimate particle counts from mesh-deposited data (fast).
Definition CD_BrownianWalkerStepper.H:290
@ Particle
Count particles directly by remapping to the new grids (accurate).
Definition CD_BrownianWalkerStepper.H:291
void makeSuperParticles()
Merge to ItoSolver.particles_per_cell, checking weight conservation if asked.
Definition CD_BrownianWalkerStepper.cpp:706
void printStepReport() override
Print a step report showing the local and global particle counts.
Definition CD_BrownianWalkerStepper.cpp:379
void parseRuntimeOptions() override
Parse runtime options from ParmParse. Re-reads verbosity, ppc, CFL, and load balancing flag.
Definition CD_BrownianWalkerStepper.cpp:99
void setDiffusion()
Set the mesh diffusion function on the solver.
Definition CD_BrownianWalkerStepper.cpp:161
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:362
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:671
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:334
RealVect m_velocity
The advective field used when m_constantVelocity is true.
Definition CD_BrownianWalkerStepper.H:363
void postCheckpointSetup() override
Post-checkpoint setup. Remaps particles, makes superparticles, and restores advection and diffusion f...
Definition CD_BrownianWalkerStepper.cpp:287
void registerRealms() override
Register the realm(s) used in the simulation.
Definition CD_BrownianWalkerStepper.cpp:516
void postRegrid() override
Post-regrid hook. Clears temporary mesh storage and restores flow fields.
Definition CD_BrownianWalkerStepper.cpp:685
Real m_omega
Angular velocity of the solid-body rotation advection field.
Definition CD_BrownianWalkerStepper.H:342
void allocate() override
Allocate internal storage in the solver.
Definition CD_BrownianWalkerStepper.cpp:538
Vector< std::string > getPlotVariableNames() const override
Return the names of the output variables contributed by this stepper.
Definition CD_BrownianWalkerStepper.cpp:323
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:1004
RefCountedPtr< ItoSpecies > m_species
Species definition passed to the Ito solver.
Definition CD_BrownianWalkerStepper.H:322
bool m_constantVelocity
If true, the advective field is spatially constant rather than rotational.
Definition CD_BrownianWalkerStepper.H:357
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:911
virtual ~BrownianWalkerStepper()
Destructor.
Definition CD_BrownianWalkerStepper.cpp:93
void plotParticles() const noexcept
Write the solver's bulk particles to an H5Part file, one per plot step.
Definition CD_BrownianWalkerStepper.cpp:405
void postInitialize() override
Post-initialization hook. No operations are performed.
Definition CD_BrownianWalkerStepper.cpp:135
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:216
void postPlot() override
Perform post-plot operations. Writes the particles if asked to.
Definition CD_BrownianWalkerStepper.cpp:394
void initialData() override
Fill the solver with initial particles, make superparticles, and set flow fields.
Definition CD_BrownianWalkerStepper.cpp:113
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:764
Real m_mobility
Spatially uniform particle mobility.
Definition CD_BrownianWalkerStepper.H:337
Real computeTotalWeight()
Compute the global total weight of the bulk particles.
Definition CD_BrownianWalkerStepper.cpp:736
void setVelocity()
Compute and assign the solid-body rotation velocity field to the solver.
Definition CD_BrownianWalkerStepper.cpp:178
Real computeDt() override
Compute the next time step as m_cfl * ItoSolver::computeDt().
Definition CD_BrownianWalkerStepper.cpp:351
void setAdvectionDiffusion()
Set the velocity and diffusion fields on the mesh if the solver is mobile/diffusive.
Definition CD_BrownianWalkerStepper.cpp:144
void registerOperators() override
Register the operators required by the solver.
Definition CD_BrownianWalkerStepper.cpp:527
Base class for advancing equations.
Definition CD_TimeStepper.H:32
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