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
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
253protected:
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
321
325 Real m_cfl;
326
330 void
332
336 void
337 setVelocity();
338
343 void
344 setDiffusion();
345
351 void
353
361 Real
363
376 void
377 loadBalanceBoxesMesh(Vector<Vector<int>>& a_procs,
378 Vector<Vector<Box>>& a_boxes,
379 const std::string& a_realm,
380 const Vector<DisjointBoxLayout>& a_grids,
381 const int a_lmin,
382 const int a_finestLevel);
383
395 void
396 loadBalanceBoxesParticles(Vector<Vector<int>>& a_procs,
397 Vector<Vector<Box>>& a_boxes,
398 const std::string& a_realm,
399 const Vector<DisjointBoxLayout>& a_grids,
400 const int a_lmin,
401 const int a_finestLevel);
402};
403} // namespace BrownianWalker
404} // namespace Physics
405
406#include <CD_NamespaceFooter.H>
407
408#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:371
bool needToRegrid() override
Always returns false; regridding is triggered externally by Driver.
Definition CD_BrownianWalkerStepper.cpp:360
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:407
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
bool m_verifyConservation
If true, verify that the superparticle merge conserves the total particle weight.
Definition CD_BrownianWalkerStepper.H:320
int getNumberOfPlotVariables() const override
Return the number of output variables contributed by this stepper.
Definition CD_BrownianWalkerStepper.cpp:276
BrownianWalkerStepper()
Default constructor. Parses all options from the BrownianWalker ParmParse block.
Definition CD_BrownianWalkerStepper.cpp:28
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:325
Real advance(const Real a_dt) override
Advance the particle system by one Euler-Maruyama step.
Definition CD_BrownianWalkerStepper.cpp:457
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:193
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()
Merge to ItoSolver.particles_per_cell, checking weight conservation if asked.
Definition CD_BrownianWalkerStepper.cpp:583
void printStepReport() override
Print a step report showing the local and global particle counts.
Definition CD_BrownianWalkerStepper.cpp:345
void parseRuntimeOptions() override
Parse runtime options from ParmParse. Re-reads verbosity, ppc, CFL, and load balancing flag.
Definition CD_BrownianWalkerStepper.cpp:72
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:328
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:548
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:300
void postCheckpointSetup() override
Post-checkpoint setup. Remaps particles, makes superparticles, and restores advection and diffusion f...
Definition CD_BrownianWalkerStepper.cpp:253
void registerRealms() override
Register the realm(s) used in the simulation.
Definition CD_BrownianWalkerStepper.cpp:426
void postRegrid() override
Post-regrid hook. Clears temporary mesh storage and restores flow fields.
Definition CD_BrownianWalkerStepper.cpp:562
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:448
Vector< std::string > getPlotVariableNames() const override
Return the names of the output variables contributed by this stepper.
Definition CD_BrownianWalkerStepper.cpp:289
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:881
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:788
virtual ~BrownianWalkerStepper()
Destructor.
Definition CD_BrownianWalkerStepper.cpp:66
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:182
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:641
Real m_mobility
Spatially uniform particle mobility.
Definition CD_BrownianWalkerStepper.H:306
Real computeTotalWeight()
Compute the global total weight of the bulk particles.
Definition CD_BrownianWalkerStepper.cpp:613
void setVelocity()
Compute and assign the solid-body rotation velocity field to the solver.
Definition CD_BrownianWalkerStepper.cpp:149
Real computeDt() override
Compute the next time step as m_cfl * ItoSolver::computeDt().
Definition CD_BrownianWalkerStepper.cpp:317
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:437
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