chombo-discharge
Loading...
Searching...
No Matches
CD_ItoKMCGodunovStepper.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_ITOKMCGODUNOVSTEPPER_H
14#define CD_ITOKMCGODUNOVSTEPPER_H
15
16// Our includes
17#include <CD_ItoKMCStepper.H>
18#include <CD_Timer.H>
20#include <CD_EBIntersection.H>
21#include <CD_NamespaceHeader.H>
22
23namespace Physics {
24namespace ItoKMC {
25
30template <typename I = ItoSolver, typename C = CdrCTU, typename R = McPhoto, typename F = FieldSolverGMG>
31class ItoKMCGodunovStepper : public ItoKMCStepper<I, C, R, F>
32{
33public:
38
45 ItoKMCGodunovStepper(RefCountedPtr<ItoKMCPhysics>& a_physics, bool a_parseOptions = true);
46
50 virtual ~ItoKMCGodunovStepper();
51
56 virtual Real
57 computeDt() override;
58
64 virtual Real
65 advance(const Real a_dt) override;
66
70 virtual void
71 allocate() noexcept override;
72
76 virtual void
77 parseOptions() noexcept override;
78
82 virtual void
83 parseRuntimeOptions() noexcept override;
84
92 virtual void
93 preRegrid(const int a_lmin, const int a_oldFinestLevel) noexcept override;
94
98 virtual void
99 registerOperators() noexcept override;
100
107 virtual void
108 regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) noexcept override;
109
110#ifdef CH_USE_HDF5
116 virtual void
117 writeCheckpointData(HDF5Handle& a_handle, const int a_lvl) const noexcept override;
118#endif
119
120#ifdef CH_USE_HDF5
125 virtual void
126 readCheckpointHeader(HDF5HeaderData& a_header) noexcept override;
127#endif
128
129#ifdef CH_USE_HDF5
134 virtual void
135 writeCheckpointHeader(HDF5HeaderData& a_header) const noexcept override;
136#endif
137
138#ifdef CH_USE_HDF5
144 virtual void
145 readCheckpointData(HDF5Handle& a_handle, const int a_lvl) noexcept override;
146#endif
147
154 virtual void
155 prePlot() noexcept override;
156
160 virtual void
161 postPlot() noexcept override;
162
163protected:
167 enum class WhichAlgorithm
168 {
169 EulerMaruyama,
170 };
171
197 {
198 Inside,
199 Cancel,
200 ReflectRho,
201 ReflectIto,
202 };
203
208
218
223
229
234
239
244
249
254
259
264
269
274
279
284
289
298
303 Vector<RefCountedPtr<ParticleContainer<NoPayload>>> m_conductivityParticles;
304
308 Vector<RefCountedPtr<ParticleContainer<NoPayload>>> m_irregularParticles;
309
314 Vector<RefCountedPtr<ParticleContainer<NoPayload>>> m_rhoDaggerParticles;
315
321 EBAMRCellData m_semiImplicitRhoCDR;
322
329
335
341
345 Vector<EBAMRCellData> m_cdrDivD;
346
353
361 EBAMRCellData m_particleScratchSum;
362
368
374
379 EBAMRCellData m_fluidScratchSolid;
380
384 virtual void
385 allocateInternals() noexcept override;
386
390 virtual void
391 parseAlgorithm() noexcept;
392
396 virtual void
397 parseFiltering() noexcept;
398
402 virtual void
403 parseCheckpointParticles() noexcept;
404
408 virtual void
410
414 virtual void
415 parseDiffusiveDeposit() noexcept;
416
420 virtual void
421 parseRhoDaggerHop() noexcept;
422
446 virtual RealVect
447 reflectDiffusionHop(const RealVect& a_pos,
448 const RealVect& a_disp,
449 const Real a_fOld,
450 const Real a_dx,
451 const EBIntersection a_intersectionAlg,
452 const Real a_bisectStep) const noexcept;
453
458 virtual void
460
464 virtual void
465 setOldPositions() noexcept;
466
471 virtual void
472 barrier() const noexcept;
473
480 virtual void
481 remapPointParticles(Vector<RefCountedPtr<ParticleContainer<NoPayload>>>& a_particles,
482 const SpeciesSubset a_subset) noexcept;
483
491 virtual void
492 depositPointParticles(const Vector<RefCountedPtr<ParticleContainer<NoPayload>>>& a_particles,
493 const SpeciesSubset a_subset) noexcept;
494
501 virtual void
502 clearPointParticles(const Vector<RefCountedPtr<ParticleContainer<NoPayload>>>& a_particles,
503 const SpeciesSubset a_subset) noexcept;
504
513 virtual void
514 computeCdrConductivity() noexcept;
515
524 virtual void
525 computeConductivities(const Vector<RefCountedPtr<ParticleContainer<NoPayload>>>& a_particles,
526 const bool a_useStoredCdrConductivity) noexcept;
527
536 virtual void
537 computeCellConductivity(EBAMRCellData& a_conductivityCell,
538 const Vector<RefCountedPtr<ParticleContainer<NoPayload>>>& a_particles,
539 const bool a_useStoredCdrConductivity) noexcept;
540
545 virtual void
546 computeFaceConductivity() noexcept;
547
551 virtual void
552 computeSemiImplicitRho() noexcept;
553
558 virtual void
559 setupSemiImplicitPoisson(const Real a_dt) noexcept;
560
567 virtual bool
568 solvePoisson() noexcept override;
569
576 virtual void
577 removeCoveredPointParticles(Vector<RefCountedPtr<ParticleContainer<NoPayload>>>& a_particles,
578 const EBRepresentation a_representation,
579 const Real a_tolerance) const noexcept;
580
586 virtual void
587 copyConductivityParticles(Vector<RefCountedPtr<ParticleContainer<NoPayload>>>& a_conductivityParticles) noexcept;
588
593 virtual void
594 advanceEulerMaruyama(const Real a_dt) noexcept;
595
607 virtual void
608 diffuseParticlesEulerMaruyama(Vector<RefCountedPtr<ParticleContainer<NoPayload>>>& a_rhoDaggerParticles,
609 const Real a_dt) noexcept;
610
619 virtual void
620 computeDiffusionTermCDR(EBAMRCellData& m_semiImplicitRhoCDR, const Real a_dt) noexcept;
621
630 virtual void
631 stepEulerMaruyamaParticles(const Real a_dt) noexcept;
632
638 virtual void
639 stepEulerMaruyamaCDR(const Real a_dt) noexcept;
640
644 virtual void
645 plotParticles() const noexcept;
646};
647} // namespace ItoKMC
648} // namespace Physics
649
650#include <CD_NamespaceFooter.H>
651
653
654#endif
Enum for putting some logic into EB intersection tests.
EBIntersection
Enum for putting some logic into how we think about intersection between particles and EBs.
Definition CD_EBIntersection.H:22
EBRepresentation
Enum for putting some logic into how we think about EBs. This is just a simply supporting class for v...
Definition CD_EBRepresentation.H:23
Implementation of CD_ItoKMCGodunovStepper.H.
Declaration of the Physics::ItoKMC::ItoKMCStepper abstract TimeStepper.
SpeciesSubset
Enum for selecting a subset of plasma species by mobility/diffusion/charge properties.
Definition CD_ItoKMCStepper.H:43
Declaration of an AMR-hierarchy container that owns per-patch ParticleSoA leaves.
Implementation of CD_Timer.H.
AMR-hierarchy container of computational particles, stored per patch in Struct-of-Arrays form.
Definition CD_ParticleContainer.H:123
Implementation of ItoKMCStepper that uses a semi-implicit split-step formalism for advancing the Ito-...
Definition CD_ItoKMCGodunovStepper.H:32
virtual void setupSemiImplicitPoisson(const Real a_dt) noexcept
Set up the semi-implicit Poisson solver.
Definition CD_ItoKMCGodunovStepperImplem.H:1708
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) noexcept override
Regrid methods – puts all data on the new mesh.
Definition CD_ItoKMCGodunovStepperImplem.H:900
virtual void computeDiffusionTermCDR(EBAMRCellData &m_semiImplicitRhoCDR, const Real a_dt) noexcept
Compute the diffusion term for the CDR equations as well as the resulting CDR-contributions to the sp...
Definition CD_ItoKMCGodunovStepperImplem.H:2242
virtual void allocate() noexcept override
Allocate storage required for advancing the equations.
Definition CD_ItoKMCGodunovStepperImplem.H:101
bool m_readCheckpointParticles
If true, then the HDF5 checkpoint file contained particles that we can read.
Definition CD_ItoKMCGodunovStepper.H:222
DiffusiveDeposit
What to do with a diffusion hop that would carry a particle, or its charge, inside the embedded bound...
Definition CD_ItoKMCGodunovStepper.H:197
@ ReflectIto
Reflect the particle's displacement about the boundary. The deposit follows the corrected hop.
@ ReflectRho
Reflect the deposit about the boundary. The particle's own displacement is untouched.
@ Inside
Deposit from inside the solid, into a covered cell that contributes nothing to rho.
@ Cancel
Deposit at the pre-hop position. Conserves charge, but biases density towards where it started.
Vector< RefCountedPtr< ParticleContainer< NoPayload > > > m_rhoDaggerParticles
Storage for particles that gave rho^dagger.
Definition CD_ItoKMCGodunovStepper.H:314
virtual Real advance(const Real a_dt) override
Advance the Ito-Poisson-KMC system over a_dt.
Definition CD_ItoKMCGodunovStepperImplem.H:529
EBAMRCellData m_particleScratchSum
Particle-realm accumulator for per-species sums, one component.
Definition CD_ItoKMCGodunovStepper.H:361
bool m_emitSecondaryParticlesBeforeReactions
If true, particles will be emitted before the reactive step.
Definition CD_ItoKMCGodunovStepper.H:238
virtual void allocateInternals() noexcept override
Allocate "internal" storage.
Definition CD_ItoKMCGodunovStepperImplem.H:134
Real m_maxFieldAbort
Limit for maximum field abort.
Definition CD_ItoKMCGodunovStepper.H:288
Real m_reactiveFieldCentering
Time-centering of the electric field that the chemistry is evaluated at.
Definition CD_ItoKMCGodunovStepper.H:297
virtual void stepEulerMaruyamaCDR(const Real a_dt) noexcept
Step the CDR equations according to the regular Euler-Maruyama scheme.
Definition CD_ItoKMCGodunovStepperImplem.H:2339
EBAMRCellData m_particleScratchSumSolid
Per-species accumulator on the particle realm, solid phase. One component.
Definition CD_ItoKMCGodunovStepper.H:373
DiffusiveDeposit m_diffusiveDeposit
What to do with a rho^dagger deposit that would land inside the embedded boundary....
Definition CD_ItoKMCGodunovStepper.H:243
virtual void computeConductivities(const Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const bool a_useStoredCdrConductivity) noexcept
Compute all conductivities (cell, face, and EB) from the input point particles.
Definition CD_ItoKMCGodunovStepperImplem.H:1430
WhichAlgorithm m_algorithm
Which advancement algorithm to use.
Definition CD_ItoKMCGodunovStepper.H:248
EBAMRCellData m_semiImplicitRhoCDR
Storage for CDR densities used during the semi-implicit solve.
Definition CD_ItoKMCGodunovStepper.H:321
virtual void parseAlgorithm() noexcept
Parse advancement algorithm.
Definition CD_ItoKMCGodunovStepperImplem.H:236
virtual void clearPointParticles(const Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const SpeciesSubset a_subset) noexcept
Clear the input particle data holders.
Definition CD_ItoKMCGodunovStepperImplem.H:1294
int m_condFilterNum
Number of filterings of the conductivity.
Definition CD_ItoKMCGodunovStepper.H:273
WhichAlgorithm
Simple enum for distinguishing between algorithms.
Definition CD_ItoKMCGodunovStepper.H:168
Vector< RefCountedPtr< ParticleContainer< NoPayload > > > m_conductivityParticles
Storage for simplified particles that gave us sigma^k.
Definition CD_ItoKMCGodunovStepper.H:303
virtual void postPlot() noexcept override
Perform post-plot operations.
Definition CD_ItoKMCGodunovStepperImplem.H:2532
EBAMRCellData m_reactiveElectricField
Storage for the electric field that the chemistry is evaluated at.
Definition CD_ItoKMCGodunovStepper.H:352
virtual Real computeDt() override
Compute a time step used for the advance method.
Definition CD_ItoKMCGodunovStepperImplem.H:509
Vector< EBAMRCellData > m_cdrDivD
Storage for the finite-volume approximation of div(D*grad(phi)) for the CDR equations.
Definition CD_ItoKMCGodunovStepper.H:345
EBAMRCellData m_scratchSemiImplicitRhoCDR
Scratch storage for CDR contribution to space charge density.
Definition CD_ItoKMCGodunovStepper.H:334
virtual void diffuseParticlesEulerMaruyama(Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_rhoDaggerParticles, const Real a_dt) noexcept
Perform the explicit half of the Ito advance in the Euler-Maruyama step.
Definition CD_ItoKMCGodunovStepperImplem.H:1968
virtual void parseSecondaryEmissionSpecification() noexcept
Parse when secondary particles are emitted.
Definition CD_ItoKMCGodunovStepperImplem.H:311
virtual void parseFiltering() noexcept
Parse filter settings.
Definition CD_ItoKMCGodunovStepperImplem.H:261
virtual void parseRuntimeOptions() noexcept override
Parse run-time options.
Definition CD_ItoKMCGodunovStepperImplem.H:216
Real m_condFilterAlpha
Factor for strided filter. Alpha=0.5 yields a bilinear filter.
Definition CD_ItoKMCGodunovStepper.H:283
EBAMRCellData m_particleScratchSolid
Deposition target on the particle realm, solid phase. One component.
Definition CD_ItoKMCGodunovStepper.H:367
virtual void depositPointParticles(const Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const SpeciesSubset a_subset) noexcept
Deposit the input point particles on the mesh.
Definition CD_ItoKMCGodunovStepperImplem.H:1192
virtual bool solvePoisson() noexcept override
Solve the electrostatic problem.
Definition CD_ItoKMCGodunovStepperImplem.H:1843
bool m_canRegridOnRestart
If true, then the class supports regrid-on-restart.
Definition CD_ItoKMCGodunovStepper.H:228
virtual void computeFaceConductivity() noexcept
Compute the cell-centered conductivity.
Definition CD_ItoKMCGodunovStepperImplem.H:1531
virtual void computeCellConductivity(EBAMRCellData &a_conductivityCell, const Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const bool a_useStoredCdrConductivity) noexcept
Compute the cell-centered conductivity.
Definition CD_ItoKMCGodunovStepperImplem.H:1445
EBAMRCellData m_fluidScratchSolid
Cross-realm landing buffer on the fluid realm, solid phase. One component.
Definition CD_ItoKMCGodunovStepper.H:379
int m_condFilterMaxStride
Stride when filtering the conductivity.
Definition CD_ItoKMCGodunovStepper.H:278
EBAMRCellData m_semiImplicitConductivityCDR
Storage for conductivity term due to mobile CDR species.
Definition CD_ItoKMCGodunovStepper.H:328
virtual void removeCoveredPointParticles(Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const EBRepresentation a_representation, const Real a_tolerance) const noexcept
Remove covered particles.
Definition CD_ItoKMCGodunovStepperImplem.H:1745
bool m_rhoDaggerHop
If true, the stochastic diffusion hop enters rho^dagger along with the rest of the explicit displacem...
Definition CD_ItoKMCGodunovStepper.H:217
virtual void remapPointParticles(Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_particles, const SpeciesSubset a_subset) noexcept
Remap the input point particles.
Definition CD_ItoKMCGodunovStepperImplem.H:1087
virtual void prePlot() noexcept override
Perform pre-plot operations.
Definition CD_ItoKMCGodunovStepperImplem.H:2504
virtual ~ItoKMCGodunovStepper()
Destructor. Does nothing.
Definition CD_ItoKMCGodunovStepperImplem.H:75
bool m_extendConductivityEB
For achieving a slightly smoother gradient in the conductivity near the EB.
Definition CD_ItoKMCGodunovStepper.H:233
virtual void setOldPositions() noexcept
Set the starting positions for the ItoSolver particles.
Definition CD_ItoKMCGodunovStepperImplem.H:1048
virtual void parseDiffusiveDeposit() noexcept
Parse what happens to a diffusion hop that would cross the embedded boundary.
Definition CD_ItoKMCGodunovStepperImplem.H:439
bool m_writeCheckpointParticles
If true, then the particles are checkpointed so we can regrid on checkpoint-restart.
Definition CD_ItoKMCGodunovStepper.H:207
virtual void parseRhoDaggerHop() noexcept
Parse whether the stochastic diffusion hop enters rho^dagger.
Definition CD_ItoKMCGodunovStepperImplem.H:475
virtual void computeSemiImplicitRho() noexcept
Set up the space charge density for the regrid operation.
Definition CD_ItoKMCGodunovStepperImplem.H:1566
virtual void advanceEulerMaruyama(const Real a_dt) noexcept
Advance the particles using the Euler-Maruyama scheme.
Definition CD_ItoKMCGodunovStepperImplem.H:1882
virtual void preRegrid(const int a_lmin, const int a_oldFinestLevel) noexcept override
Perform pre-regrid operations.
Definition CD_ItoKMCGodunovStepperImplem.H:861
virtual void registerOperators() noexcept override
Register operators used for the simulation.
Definition CD_ItoKMCGodunovStepperImplem.H:85
virtual RealVect reflectDiffusionHop(const RealVect &a_pos, const RealVect &a_disp, const Real a_fOld, const Real a_dx, const EBIntersection a_intersectionAlg, const Real a_bisectStep) const noexcept
Reflect a rho^dagger deposit displacement that crosses the embedded boundary back into the fluid.
Definition CD_ItoKMCGodunovStepperImplem.H:342
EBAMRCellData m_scratchSemiImplicitConductivityCDR
Scratch storage for CDR contribution to conductivity.
Definition CD_ItoKMCGodunovStepper.H:340
virtual void plotParticles() const noexcept
Utility function for plotting the ItoSolver particles. These are written in a particles folder.
Definition CD_ItoKMCGodunovStepperImplem.H:2546
ItoKMCGodunovStepper()=delete
Disallowed default constructor. Use the full constructor.
Vector< RefCountedPtr< ParticleContainer< NoPayload > > > m_irregularParticles
Storage for particles that fell inside the EB but should still contribute to the conductivity.
Definition CD_ItoKMCGodunovStepper.H:308
Real m_rhoFilterAlpha
Factor for strided filter. Alpha=0.5 yields a bilinear filter.
Definition CD_ItoKMCGodunovStepper.H:268
int m_rhoFilterNum
Number of filterings when computing the semi-implicit space charge density.
Definition CD_ItoKMCGodunovStepper.H:258
Timer m_timer
Timer used for run-time logging of routines.
Definition CD_ItoKMCGodunovStepper.H:253
virtual void parseReactiveFieldCentering() noexcept
Parse the time-centering of the electric field used for the reactive substep.
Definition CD_ItoKMCGodunovStepperImplem.H:489
virtual void parseCheckpointParticles() noexcept
Parse checkpoint-restart functionality.
Definition CD_ItoKMCGodunovStepperImplem.H:297
virtual void barrier() const noexcept
Set an MPI barrier if using debug mode.
Definition CD_ItoKMCGodunovStepperImplem.H:182
virtual void parseOptions() noexcept override
Parse options.
Definition CD_ItoKMCGodunovStepperImplem.H:196
int m_rhoFilterMaxStride
Stride when filtering the space charge density.
Definition CD_ItoKMCGodunovStepper.H:263
virtual void computeCdrConductivity() noexcept
Compute the CDR contribution to the semi-implicit conductivity, i.e. sum(|Z| * phi * mu).
Definition CD_ItoKMCGodunovStepperImplem.H:1400
virtual void stepEulerMaruyamaParticles(const Real a_dt) noexcept
Step the particles according to the regular Euler-Maruyama scheme.
Definition CD_ItoKMCGodunovStepperImplem.H:2282
virtual void copyConductivityParticles(Vector< RefCountedPtr< ParticleContainer< NoPayload > > > &a_conductivityParticles) noexcept
Copy particles from the ItoSolver into PointParticles whose weight are ItoParticle::m_weight * ItoPar...
Definition CD_ItoKMCGodunovStepperImplem.H:1785
Abstract TimeStepper for the Ito-KMC-Poisson system of equations.
Definition CD_ItoKMCStepper.H:66
Class which is used for run-time monitoring of events.
Definition CD_Timer.H:32
Namespace containing physics models for use with chombo-discharge.
Definition CD_AdvectionDiffusion.H:16
Empty payload: ParticleSoA<> is a position+weight+metadata point particle.
Definition CD_ParticleSoA.H:289