chombo-discharge
Loading...
Searching...
No Matches
CD_ItoSolver.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_ITOSOLVER_H
14#define CD_ITOSOLVER_H
15
16// Std includes
17#include <optional>
18
19// Our includes
20#include <CD_AmrMesh.H>
22#include <CD_ItoSpecies.H>
23#include <CD_ItoParticle.H>
24#include <CD_ItoMergeParticle.H>
26#include <CD_EBRepresentation.H>
27#include <CD_EBIntersection.H>
28#include <CD_CellInfo.H>
30#include <CD_NamespaceHeader.H>
31
40{
41public:
50 enum class WhichContainer
51 {
52 Bulk,
53 EB,
54 Domain,
55 Source,
56 Covered,
57 Scratch
58 };
59
63 ItoSolver();
64
68 virtual ~ItoSolver();
69
73 ItoSolver(const ItoSolver&) = delete;
74
79 operator=(const ItoSolver&) = delete;
80
84 ItoSolver(ItoSolver&&) = default;
85
91 operator=(ItoSolver&&) = default;
92
102 virtual void
104
109 virtual std::string
110 getName() const;
111
116 virtual std::string
117 getRealm() const;
118
123 virtual void
124 setRealm(const std::string& a_realm);
125
129 virtual void
130 parseOptions();
131
135 virtual void
137
142 virtual EBIntersection
143 getIntersectionAlgorithm() const noexcept;
144
149 virtual void
150 initialData();
151
163 virtual void
165 const std::function<Real(const RealVect x)>& a_densityFunc,
166 const Vector<int>& a_maxParticlesPerCell) const noexcept;
167
174 virtual void
176 const std::function<Real(const RealVect x)>& a_densityFunc,
177 int a_maxParticlesPerCell) const noexcept;
178
185 virtual void
186 regrid(int a_lmin, int a_oldFinestLevel, int a_newFinestLevel);
187
193 virtual void
194 allocate();
195
200 virtual void
201 clear(WhichContainer a_container);
202
207 virtual void
208 clear(ParticleContainer<ItoParticle>& a_particles) const;
209
216 virtual void
217 depositConductivity(EBAMRCellData& a_phi, ParticleContainer<ItoParticle>& a_particles) const;
218
227 virtual void
228 depositConductivity(EBAMRCellData& a_phi,
229 ParticleContainer<ItoParticle>& a_particles,
230 DepositionType a_deposition,
231 CoarseFineDeposition a_coarseFineDeposition) const;
232
240 virtual void
241 depositDiffusivity(EBAMRCellData& a_phi, ParticleContainer<ItoParticle>& a_particles) const;
242
251 virtual void
252 depositDiffusivity(EBAMRCellData& a_phi,
253 ParticleContainer<ItoParticle>& a_particles,
254 DepositionType a_deposition,
255 CoarseFineDeposition a_coarseFineDeposition) const;
256
264 virtual void
265 depositEnergyDensity(EBAMRCellData& a_phi, ParticleContainer<ItoParticle>& a_particles) const;
266
275 virtual void
276 depositEnergyDensity(EBAMRCellData& a_phi,
277 ParticleContainer<ItoParticle>& a_particles,
278 DepositionType a_deposition,
279 CoarseFineDeposition a_coarseFineDeposition) const;
280
287 virtual void
288 computeAverageMobility(EBAMRCellData& a_phi, ParticleContainer<ItoParticle>& a_particles) const;
289
297 virtual void
298 computeAverageDiffusion(EBAMRCellData& a_phi, ParticleContainer<ItoParticle>& a_particles) const;
299
306 virtual void
307 computeAverageEnergy(EBAMRCellData& a_phi, ParticleContainer<ItoParticle>& a_particles) const;
308
314 virtual void
316
324 virtual void
325 depositParticles(WhichContainer a_container);
326
333 void
334 depositWeightNGP(LevelData<EBCellFAB>& a_output,
335 const ParticleContainer<ItoParticle>& a_particles,
336 int a_level) const noexcept;
337
346 template <typename Gather>
347 void
348 depositGatheredNGP(LevelData<EBCellFAB>& a_output,
349 const ParticleContainer<ItoParticle>& a_particles,
350 int a_level,
351 Gather a_gather) const noexcept;
352
361 void
362 coarsenAndFillGhosts(EBAMRCellData& a_phi) const;
363
379 template <typename P, typename Traits>
380 void
381 depositWeight(EBAMRCellData& a_phi,
382 const ParticleContainer<P, Traits>& a_particles,
383 DepositionType a_deposition,
384 CoarseFineDeposition a_coarseFineDeposition) const;
385
397 template <typename Gather>
398 void
399 depositGathered(EBAMRCellData& a_phi,
400 const ParticleContainer<ItoParticle>& a_particles,
401 DepositionType a_deposition,
402 CoarseFineDeposition a_coarseFineDeposition,
403 Gather a_gather) const;
404
411 virtual void
412 removeCoveredParticles(EBRepresentation a_representation, Real a_tol);
413
421 virtual void
422 removeCoveredParticles(WhichContainer a_container, EBRepresentation a_representation, Real a_tol);
423
430 virtual void
432 EBRepresentation a_representation,
433 Real a_tol) const;
434
441 virtual void
442 transferCoveredParticles(EBRepresentation a_representation, Real a_tol);
443
451 virtual void
453 WhichContainer a_containerTo,
454 EBRepresentation a_representation,
455 Real a_tol);
456
464 virtual void
466 ParticleContainer<ItoParticle>& a_particlesTo,
467 EBRepresentation a_representation,
468 Real a_tol) const;
469
482 virtual void
484 const EBIntersection a_ebIntersection,
485 const bool a_deleteParticles,
486 const std::function<void(ParticleSoA<ItoParticle>&, std::size_t)>& a_nonDeletionModifier =
487 [](ParticleSoA<ItoParticle>&, std::size_t) -> void {
488 return;
489 });
490
506 virtual void
508 const WhichContainer a_particles,
509 const WhichContainer a_ebParticles,
510 const WhichContainer a_domainParticles,
511 const EBIntersection a_ebIntersection,
512 const bool a_deleteParticles,
513 const std::function<void(ParticleSoA<ItoParticle>&, std::size_t)>& a_nonDeletionModifier =
514 [](ParticleSoA<ItoParticle>&, std::size_t) -> void {
515 return;
516 });
517
532 virtual void
535 ParticleContainer<ItoParticle>& a_ebParticles,
536 ParticleContainer<ItoParticle>& a_domainParticles,
537 const EBIntersection a_ebIntersection,
538 const bool a_deleteParticles,
539 const std::function<void(ParticleSoA<ItoParticle>&, std::size_t)>& a_nonDeletionModifier =
540 [](ParticleSoA<ItoParticle>&, std::size_t) -> void {
541 return;
542 });
543
551 virtual void
552 computeLoads(Vector<long int>& a_loads, const DisjointBoxLayout& a_dbl, int a_level);
553
558 virtual int
560
565 virtual Vector<std::string>
566 getPlotVariableNames() const;
567
576 virtual void
577 writePlotData(LevelData<EBCellFAB>& a_output,
578 int& a_comp,
579 const std::string& a_outputRealm,
580 int a_level) const noexcept;
581
588 virtual unsigned long long
589 getNumParticles(WhichContainer a_whichContainer, bool a_localOnly) const;
590
595 virtual void
596 registerOperators() const;
597
602 virtual void
603 setComputationalGeometry(const RefCountedPtr<ComputationalGeometry>& a_computationalGeometry);
604
609 virtual void
610 setAmr(const RefCountedPtr<AmrMesh>& a_amr);
611
616 virtual void
618
623 virtual void
624 setVerbosity(int a_verbosity);
625
633 virtual void
634 setTime(int a_step, Real a_time, Real a_dt);
635
636#ifdef CH_USE_HDF5
645 virtual void
646 writeCheckpointLevel(HDF5Handle& a_handle, int a_level) const;
647#endif
648
649#ifdef CH_USE_HDF5
657 virtual void
658 readCheckpointLevel(HDF5Handle& a_handle, int a_level);
659#endif
660
665 virtual void
666 setSpecies(const RefCountedPtr<ItoSpecies>& a_species);
667
674 virtual void
675 preRegrid(int a_lbase, int a_oldFinestLevel);
676
681 virtual bool
682 isMobile() const;
683
688 virtual bool
689 isDiffusive() const;
690
697 getParticles(WhichContainer a_container);
698
704 virtual const ParticleContainer<ItoParticle>&
705 getParticles(WhichContainer a_container) const;
706
711 virtual const RefCountedPtr<ItoSpecies>&
712 getSpecies() const;
713
718 virtual EBAMRCellData&
719 getPhi();
720
725 virtual EBAMRCellData&
727
732 virtual const EBAMRCellData&
733 getVelocityFunction() const;
734
739 virtual EBAMRCellData&
741
746 virtual const EBAMRCellData&
747 getDiffusionFunction() const;
748
753 virtual EBAMRCellData&
755
760 virtual const EBAMRCellData&
761 getMobilityFunction() const;
762
767 virtual void
768 setDiffusionFunction(Real a_diffusionCoefficient);
769
774 virtual void
775 setVelocityFunction(const RealVect& a_velocity);
776
781 virtual void
782 setParticleMobility(Real a_mobility);
783
788 virtual void
789 setParticleDiffusion(Real a_diffCo);
790
796 virtual void
798
806 virtual void
807 interpolateVelocities(int a_lvl, const DataIndex& a_dit);
808
813 virtual void
815
821 virtual void
823
828 virtual void
830
836 virtual void
838
843 virtual void
845
850 virtual void
852
859 virtual void
861
867 virtual void
868 makeSuperparticles(WhichContainer a_container, int a_particlesPerCell);
869
875 virtual void
876 makeSuperparticles(WhichContainer a_container, const Vector<int>& a_particlesPerCell);
877
889 virtual void
891 const Vector<int>& a_particlesPerCell,
893
902 virtual const Vector<int>&
903 getParticlesPerCell() const noexcept;
904
915 getRegridParticles() noexcept;
916
920 virtual void
921 remap();
922
927 virtual void
928 remap(WhichContainer a_container);
929
933 virtual void
934 remapAll();
935
943 inline RealVect
944 randomGaussian() const;
945
951 inline RealVect
953
963 virtual Real
964 computeDt() const;
965
977 virtual Real
978 computeDt(int a_lvl) const;
979
992 virtual Real
993 computeDt(int a_lvl, const DataIndex& a_dit) const;
994
1010 virtual Real
1011 computeHopDt(Real a_maxCellsToMove) const;
1012
1029 virtual Real
1030 computeHopDt(Real a_maxCellsToMove, int a_lvl) const;
1031
1049 virtual Real
1050 computeHopDt(Real a_maxCellsToMove, int a_lvl, const DataIndex& a_dit) const;
1051
1056 virtual Real
1057 computeAdvectiveDt() const;
1058
1064 virtual Real
1065 computeAdvectiveDt(int a_lvl) const;
1066
1073 virtual Real
1074 computeAdvectiveDt(int a_lvl, const DataIndex& a_dit) const;
1075
1080 virtual Real
1081 computeDiffusiveDt() const;
1082
1088 virtual Real
1089 computeDiffusiveDt(int a_lvl) const;
1090
1097 virtual Real
1098 computeDiffusiveDt(int a_lvl, const DataIndex& a_dit) const;
1099
1105 getDeposition() const;
1106
1113
1118 phase::which_phase
1119 getPhase() const;
1120
1121protected:
1125 static constexpr int m_comp = 0;
1126
1130 static constexpr int m_nComp = 1;
1131
1137 {
1138 Particles,
1139 Numbers
1140 };
1141
1148 {
1149 Direct,
1150 Velocity
1151 };
1152
1157
1163
1170
1178
1193
1204 std::optional<ParticleManagement::ParticleMergeMethod> m_regridMergeMethod;
1205
1212 bool m_nnPairIterate = true;
1213
1219
1226
1235
1245
1251
1255 std::string m_realm;
1256
1260 RefCountedPtr<ComputationalGeometry> m_computationalGeometry;
1261
1265 RefCountedPtr<AmrMesh> m_amr;
1266
1270 RefCountedPtr<ItoSpecies> m_species;
1271
1276
1280 std::string m_name;
1281
1286 std::string m_className;
1287
1294
1299
1304
1309
1314
1318 Real m_dt;
1319
1324
1329
1334
1339
1344
1349
1354
1359
1364
1369
1374
1379
1384
1389
1394
1399
1404
1409
1414
1419
1423 EBAMRCellData m_phi;
1424
1428 EBAMRCellData m_mobilityFunction;
1429
1433 EBAMRCellData m_velocityFunction;
1434
1438 EBAMRCellData m_diffusionFunction;
1439
1447
1452
1456 mutable EBAMRIVData m_depositionNC;
1457
1461 mutable EBAMRIVData m_massDiff;
1462
1466 std::map<WhichContainer, ParticleContainer<ItoParticle>> m_particleContainers;
1467
1486
1491
1495 void
1496 parseRNG();
1497
1501 void
1503
1507 void
1509
1513 void
1515
1534 void
1536 const Vector<int>& a_particlesPerCell,
1538
1549 void
1551 const Vector<int>& a_particlesPerCell,
1553
1562 void
1564
1577 void
1579
1588 void
1589 splitFromMergeContainer(ParticleContainer<ItoMergeParticle>& a_merge, int a_numParticlesPerCellThresh);
1590
1599 void
1601
1607 {
1608 Tree,
1609 Hash
1610 };
1611
1620 void
1621 mergeEqualWeightKD(ParticleContainer<ItoMergeParticle>& a_particles, const Vector<int>& a_particlesPerCell);
1622
1631 void
1632 mergeReinitialize(ParticleContainer<ItoMergeParticle>& a_particles, const Vector<int>& a_particlesPerCell);
1633
1641 void
1642 mergeReinitializeBVH(ParticleContainer<ItoMergeParticle>& a_particles, const Vector<int>& a_particlesPerCell);
1643
1652 void
1653 mergeNnSfc(ParticleContainer<ItoMergeParticle>& a_particles, const Vector<int>& a_particlesPerCell);
1654
1669 template <NnPairSearchBackend Backend>
1670 void
1671 mergeNnPairSearch(ParticleContainer<ItoMergeParticle>& merge, const Vector<int>& a_particlesPerCell);
1672
1682 void
1683 mergeNnPairOneCell(ParticleContainer<ItoMergeParticle>& merge, const Vector<int>& a_particlesPerCell);
1684
1700 void
1701 mergeKDSkinNn(ParticleContainer<ItoMergeParticle>& merge, const Vector<int>& a_particlesPerCell);
1702
1718 void
1720 const Vector<int>& a_particlesPerCell,
1721 bool a_enableBoundaryCarve);
1722
1726 void
1728
1732 void
1734
1738 void
1740
1744 void
1746
1750 void
1752
1756 void
1758
1762 void
1764
1765#ifdef CH_USE_HDF5
1774 virtual void
1775 writeCheckPointLevelParticles(HDF5Handle& a_handle, int a_level) const;
1776#endif
1777
1778#ifdef CH_USE_HDF5
1788 virtual void
1789 writeCheckPointLevelFluid(HDF5Handle& a_handle, int a_level) const;
1790#endif
1791
1792#ifdef CH_USE_HDF5
1799 virtual void
1800 readCheckpointLevelParticles(HDF5Handle& a_handle, int a_level);
1801#endif
1802
1803#ifdef CH_USE_HDF5
1811 virtual void
1812 readCheckpointLevelFluid(HDF5Handle& a_handle, int a_level);
1813#endif
1814
1822 void
1823 drawNewParticles(const LevelData<EBCellFAB>& a_particlesPerCell, int a_level, int a_newPPC);
1824
1836 virtual void
1837 redistributeAMR(EBAMRCellData& a_phi) const;
1838
1845 virtual void
1846 depositNonConservative(EBAMRIVData& a_depositionNC, const EBAMRCellData& a_depositionKappaC) const;
1847
1855 virtual void
1856 depositHybrid(EBAMRCellData& a_depositionH, EBAMRIVData& a_massDifference, const EBAMRIVData& a_depositionNC) const;
1857
1864 virtual void
1865 interpolateMobilities(int a_lvl, const DataIndex& a_dit, const EBCellFAB& a_velocityMagnitude) noexcept;
1866
1872 virtual void
1873 interpolateMobilitiesDirect(int a_lvl, const DataIndex& a_dit) noexcept;
1874
1881 virtual void
1882 interpolateMobilitiesVelocity(int a_lvl, const DataIndex& a_dit, const EBCellFAB& a_velocityMagnitude) noexcept;
1883
1891 virtual void
1892 updateMobilities(int a_level, const DataIndex& a_dit);
1893
1900 virtual void
1901 interpolateDiffusion(int a_lvl, const DataIndex& a_dit);
1902
1910 virtual void
1911 updateDiffusion(int a_level, const DataIndex& a_dit);
1912
1924 virtual void
1925 writeData(LevelData<EBCellFAB>& a_output,
1926 int& a_comp,
1927 const EBAMRCellData& a_data,
1928 const std::string& a_outputRealm,
1929 int a_level,
1930 bool a_interpToCentroids,
1931 bool a_interpGhost) const noexcept;
1932};
1933
1934#include <CD_NamespaceFooter.H>
1935
1936#include <CD_ItoSolverImplem.H>
1937
1938#endif
Declaration of core class for handling AMR-related operations (with embedded boundaries)
Simple class for holding some quantities relevant in a grid cell.
CoarseFineDeposition
Coarse-fine deposition types (see CD_EBAMRParticleMesh for how these are handled).
Definition CD_CoarseFineDeposition.H:28
Declaration of base class for defining geometries.
DepositionType
Deposition types.
Definition CD_DepositionType.H:24
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
Enum for putting some logic into EB intersection tests.
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
Declaration of the reduced Ito particle used for merging and for regrid transport.
SoA payload for Ito diffusion particles (drifting Brownian walkers)
Implementation of CD_ItoSolver.H.
Declaration of an ItoSpecies class that passes in names and initial data to ItoSolvers.
Declaration of an AMR-hierarchy container that owns per-patch ParticleSoA leaves.
Namespace containing various particle management utilities.
Base class for Ito diffusion particle models.
Definition CD_ItoSolver.H:40
void mergeKDImpl(ParticleContainer< ItoMergeParticle > &merge, const Vector< int > &a_particlesPerCell, bool a_enableBoundaryCarve)
Whole-container merge: whole-patch kd-tree build – shared implementation behind the kd_carve and kd_p...
Definition CD_ItoSolver.cpp:4698
virtual void computeAverageEnergy(EBAMRCellData &a_phi, ParticleContainer< ItoParticle > &a_particles) const
Compute average particle energy..
Definition CD_ItoSolver.cpp:2018
RealVect randomDirection() const
Draw a random direction in N-dimensional space.
virtual Real computeHopDt(Real a_maxCellsToMove) const
Compute the largest possible time step such that the particles does not move more than a specified nu...
Definition CD_ItoSolver.cpp:2979
int m_nnPairMaxCellDistance
nn_pair_tree/nn_pair_hash: maximum merge distance in whole cells (Chebyshev). A negative value means ...
Definition CD_ItoSolver.H:1225
void mergeNnPairSearch(ParticleContainer< ItoMergeParticle > &merge, const Vector< int > &a_particlesPerCell)
Whole-container merge: distributed nearest-neighbour pair merge – shared implementation behind the nn...
Definition CD_ItoSolver.cpp:4124
virtual void interpolateMobilities()
Interpolate mobilities.
Definition CD_ItoSolver.cpp:2549
WhichContainer
Enum class for distinguishing various types of particle containers.
Definition CD_ItoSolver.H:51
phase::which_phase getPhase() const
Return phase.
Definition CD_ItoSolver.cpp:3374
void parseDiffusionHop()
Parse diffusion hop.
void mergeEqualWeightKD(ParticleContainer< ItoMergeParticle > &a_particles, const Vector< int > &a_particlesPerCell)
Cell-based merge: equal-weight KD partition, one weighted-centroid particle per leaf.
Definition CD_ItoSolver.cpp:3674
virtual void writeData(LevelData< EBCellFAB > &a_output, int &a_comp, const EBAMRCellData &a_data, const std::string &a_outputRealm, int a_level, bool a_interpToCentroids, bool a_interpGhost) const noexcept
Write data to output. Convenience function.
Definition CD_ItoSolver.cpp:1769
CoarseFineDeposition m_coarseFineDeposition
Coarse-fine deposition strategy.
Definition CD_ItoSolver.H:1413
void mergeLite(ParticleContainer< ItoMergeParticle > &a_particles, const Vector< int > &a_particlesPerCell, ParticleManagement::ParticleMergeMethod a_method)
Run one merge method over an already-extracted reduced-particle container.
Definition CD_ItoSolver.cpp:3470
bool m_plotPhi
Flag for outputting m_phi to plot files.
Definition CD_ItoSolver.H:1358
virtual Vector< std::string > getPlotVariableNames() const
Get output plot names.
Definition CD_ItoSolver.cpp:1604
virtual void setSpecies(const RefCountedPtr< ItoSpecies > &a_species)
Set the species.
Definition CD_ItoSolver.cpp:1175
EBAMRCellData m_diffusionFunction
Diffusion-centerer field used for interpolating diffusion coefficients.
Definition CD_ItoSolver.H:1438
virtual void registerOperators() const
Register operators.
Definition CD_ItoSolver.cpp:582
int m_nnPairMaxRounds
nn_pair_tree/nn_pair_onecell/nn_pair_hash: maximum number of drain rounds run per makeSuperparticles(...
Definition CD_ItoSolver.H:1234
virtual void depositParticles()
Deposit particles onto mesh.
Definition CD_ItoSolver.cpp:2054
CoarseFineDeposition getCoarseFineDeposition() const
Get the coarse-fine deposition strategy.
Definition CD_ItoSolver.cpp:3368
bool m_plotEnergyDensity
Flag for plotting the energy density on the mesh.
Definition CD_ItoSolver.H:1398
Real m_kdSplitWeightLeafDx
Leaf size, in cell widths, at or below which the tree build switches from count-median to weight-medi...
Definition CD_ItoSolver.H:1244
virtual void depositNonConservative(EBAMRIVData &a_depositionNC, const EBAMRCellData &a_depositionKappaC) const
Make the "non-conservative" kappa deposition – computing depositionNC = sum(kappa*depositionC)/sum(ka...
Definition CD_ItoSolver.cpp:2178
virtual void makeSuperparticles(WhichContainer a_container)
Make superparticles for a full container, merging to the solver's configured target.
Definition CD_ItoSolver.cpp:3406
void mergeReinitializeBVH(ParticleContainer< ItoMergeParticle > &a_particles, const Vector< int > &a_particlesPerCell)
Cell-based merge: as mergeEqualWeightKD(), with reinitialized leaf positions.
Definition CD_ItoSolver.cpp:3782
Real m_bisectionStep
Bisection step size to use for particle intersection tests with EBs.
Definition CD_ItoSolver.H:1298
void extractIntoMergeContainer(WhichContainer a_container, ParticleContainer< ItoMergeParticle > &a_merge)
Extract a container's ItoParticles into a minimal ItoMergeParticle container on the same realm/patch,...
Definition CD_ItoSolver.cpp:3927
int m_restartPPC
Number of particles used when restarting a simulation – this is relevant only when restarting from a ...
Definition CD_ItoSolver.H:1250
NnPairSearchBackend
Which EBGeometry point-cloud index backs mergeNnPairSearch()'s per-patch spatial search – see Particl...
Definition CD_ItoSolver.H:1607
@ Tree
EBGeometry::PointCloudBVH – ParticleManagement::mergeNearestNeighborsTree().
@ Hash
EBGeometry::PointCloudHashGrid – ParticleManagement::mergeNearestNeighborsHash().
virtual void setComputationalGeometry(const RefCountedPtr< ComputationalGeometry > &a_computationalGeometry)
Set computational geometry.
Definition CD_ItoSolver.cpp:556
void applyCellMerger(ParticleContainer< ItoMergeParticle > &a_particles, const Vector< int > &a_particlesPerCell, const ParticleManagement::ParticleMerger< ItoMergeParticle > &a_merger)
Apply a per-cell merger over an entire reduced-particle container, cell by cell.
Definition CD_ItoSolver.cpp:3588
ParticleContainer< ItoMergeParticle > m_regridParticles
The bulk particles, in reduced form, between preRegrid() and regrid().
Definition CD_ItoSolver.H:1485
void parseIntersectionEB()
Parse EB intersection algorithms.
Definition CD_ItoSolver.cpp:325
virtual void intersectParticles(const EBIntersection a_ebIntersection, const bool a_deleteParticles, const std::function< void(ParticleSoA< ItoParticle > &, std::size_t)> &a_nonDeletionModifier=[](ParticleSoA< ItoParticle > &, std::size_t) -> void { return;})
Do boundary intersection tests.
Definition CD_ItoSolver.cpp:989
virtual void setAmr(const RefCountedPtr< AmrMesh > &a_amr)
Set the AmrMesh object.
Definition CD_ItoSolver.cpp:569
void mergeNnSfc(ParticleContainer< ItoMergeParticle > &a_particles, const Vector< int > &a_particlesPerCell)
Cell-based merge: Hilbert-curve sort, then merge adjacent pairs down to the target.
Definition CD_ItoSolver.cpp:3875
bool m_forceHaloNGP
Force usage of NGP when depositing "halo" particles.
Definition CD_ItoSolver.H:1333
virtual std::string getRealm() const
Get the realm where this solver is registered.
Definition CD_ItoSolver.cpp:76
static constexpr int m_nComp
Default number of component in data holders (do not touch).
Definition CD_ItoSolver.H:1130
void parseRedistribution()
Parse whether or not to use redistribution.
Definition CD_ItoSolver.cpp:351
bool m_forceIrregInterpolationNGP
NGP interpolation in cut cells or not.
Definition CD_ItoSolver.H:1328
EBAMRIVData m_depositionNC
Scratch storage for holding the non-conservative deposition.
Definition CD_ItoSolver.H:1456
virtual Real computeDiffusiveDt() const
Compute the diffusive dt. This computes dt = dx*dx/(2*SpaceDim*D) for all particles.
Definition CD_ItoSolver.cpp:3236
void parseParticleMerger()
Parse the super-particle merger.
Definition CD_ItoSolver.cpp:401
std::string m_className
Class name.
Definition CD_ItoSolver.H:1286
virtual void updateDiffusion()
Update mobilities parametrically from the particle energy.
Definition CD_ItoSolver.cpp:2811
bool m_plotParticles
Flag for depositing and plotting the bulk particles on the mesh.
Definition CD_ItoSolver.H:1373
int m_timeStep
Time step.
Definition CD_ItoSolver.H:1308
void coarsenAndFillGhosts(EBAMRCellData &a_phi) const
Coarsen the input data and interpolate its ghost cells.
Definition CD_ItoSolver.cpp:2121
virtual EBAMRCellData & getVelocityFunction()
Get cell-centered velocity mesh data.
Definition CD_ItoSolver.cpp:2332
virtual void interpolateMobilitiesDirect(int a_lvl, const DataIndex &a_dit) noexcept
Directly interpolate mobilities. Interpolates for all particles in the specified grid patch.
Definition CD_ItoSolver.cpp:2625
bool m_forceIrregDepositionNGP
NGP deposition in cut cells or not.
Definition CD_ItoSolver.H:1323
std::string m_realm
Realm where this solve lives.
Definition CD_ItoSolver.H:1255
virtual void depositConductivity(EBAMRCellData &a_phi, ParticleContainer< ItoParticle > &a_particles) const
Deposit conductivities (i.e. mass*mobility / volume)
Definition CD_ItoSolver.cpp:1835
virtual const Vector< int > & getParticlesPerCell() const noexcept
Get the configured target number of computational particles per cell, per AMR level.
Definition CD_ItoSolver.cpp:519
virtual void interpolateVelocities()
Interpolate the particle velocities.
Definition CD_ItoSolver.cpp:2482
virtual void interpolateMobilitiesVelocity(int a_lvl, const DataIndex &a_dit, const EBCellFAB &a_velocityMagnitude) noexcept
Interpolate mobilities through the velocity. Interpolates for all particles in the specified grid pat...
Definition CD_ItoSolver.cpp:2657
virtual void parseOptions()
Parse class options.
Definition CD_ItoSolver.cpp:114
bool m_plotParticlesSource
Flag for depositing and plotting the source particles on the mesh.
Definition CD_ItoSolver.H:1388
virtual Real computeDt() const
Compute a time step for the advance – this calls the level function.
Definition CD_ItoSolver.cpp:2862
RefCountedPtr< ItoSpecies > m_species
Species that this solver solves for.
Definition CD_ItoSolver.H:1270
DepositionType m_deposition
Deposition method when depositing particles to the mesh.
Definition CD_ItoSolver.H:1408
virtual void interpolateDiffusion()
Interpolate the diffusion field to the particle positions.
Definition CD_ItoSolver.cpp:2757
virtual void computeAverageMobility(EBAMRCellData &a_phi, ParticleContainer< ItoParticle > &a_particles) const
Compute average mobility.
Definition CD_ItoSolver.cpp:1948
void depositWeight(EBAMRCellData &a_phi, const ParticleContainer< P, Traits > &a_particles, DepositionType a_deposition, CoarseFineDeposition a_coarseFineDeposition) const
Deposit the SoA weight column on the mesh (kappa-conservative + redistribution).
Definition CD_ItoSolverImplem.H:53
Real m_dt
Time step.
Definition CD_ItoSolver.H:1318
ItoSolver()
Constructor – user must subsequently set the realm and, parse class options, set the species etc.
Definition CD_ItoSolver.cpp:42
std::string m_name
Solver name.
Definition CD_ItoSolver.H:1280
virtual std::string getName() const
Get this solver's name.
Definition CD_ItoSolver.cpp:68
ItoSolver & operator=(const ItoSolver &)=delete
Deleted copy assignment operator.
void mergeNnPairOneCell(ParticleContainer< ItoMergeParticle > &merge, const Vector< int > &a_particlesPerCell)
Whole-container merge: distributed nearest-neighbour pair merge, per-cell PointCloudBVH search.
Definition CD_ItoSolver.cpp:4306
EBAMRCellData m_velocityFunction
Cell-centered field used for interpolating velocities.
Definition CD_ItoSolver.H:1433
virtual void removeCoveredParticles(EBRepresentation a_representation, Real a_tol)
Remove particles that are inside the EB.
Definition CD_ItoSolver.cpp:865
WhichCheckpoint m_checkpointing
How to checkpoint files. particles => write particles to HDF5. numbers => write numbers to HDF5.
Definition CD_ItoSolver.H:1156
virtual ~ItoSolver()
Destructor (does nothing).
Definition CD_ItoSolver.cpp:62
void parseCheckpointing()
Parse checkpointing method.
Definition CD_ItoSolver.cpp:377
bool m_isDiffusive
If true, solver is diffusive.
Definition CD_ItoSolver.H:1348
bool m_plotAverageEnergy
Flag for plotting the average particle energy on the mesh.
Definition CD_ItoSolver.H:1403
DepositionType m_plotDeposition
Deposition method when depositing particles to mesh during plotting.
Definition CD_ItoSolver.H:1418
RealVect randomGaussian() const
Draw a random N-dimensional Gaussian number from a normal distribution with zero with and unit standa...
Definition CD_ItoSolverImplem.H:32
virtual ParticleContainer< ItoParticle > & getParticles(WhichContainer a_container)
Get a general particle container.
Definition CD_ItoSolver.cpp:2299
virtual void setPhase(phase::which_phase a_phase)
Set phase where the particles will live.
Definition CD_ItoSolver.cpp:630
virtual unsigned long long getNumParticles(WhichContainer a_whichContainer, bool a_localOnly) const
Get number of particles in a specified particle container.
Definition CD_ItoSolver.cpp:535
virtual void remap()
Remap the bulk particle container.
Definition CD_ItoSolver.cpp:3338
virtual void organizeParticlesByCell(WhichContainer a_container)
Sort the input particle container by cell.
Definition CD_ItoSolver.cpp:3380
virtual void computeLoads(Vector< long int > &a_loads, const DisjointBoxLayout &a_dbl, int a_level)
Compute particle load on a specific grid level – this will compute the number of particles in each bo...
Definition CD_ItoSolver.cpp:836
virtual void setRealm(const std::string &a_realm)
Set the realm where this solver will live.
Definition CD_ItoSolver.cpp:84
bool m_useRedistribution
Use mass redistribution or not.
Definition CD_ItoSolver.H:1338
EBAMRCellData m_mobilityFunction
Mobility function – used when interpolating particle mobilities.
Definition CD_ItoSolver.H:1428
virtual void updateMobilities()
Update mobilities parametrically from the particle energy.
Definition CD_ItoSolver.cpp:2708
std::map< WhichContainer, ParticleContainer< ItoParticle > > m_particleContainers
Various particle containers with identifiers.
Definition CD_ItoSolver.H:1466
virtual bool isMobile() const
Check if solver is mobile.
Definition CD_ItoSolver.cpp:2243
virtual EBAMRCellData & getDiffusionFunction()
Get the diffusion function.
Definition CD_ItoSolver.cpp:2354
void splitFromMergeContainer(ParticleContainer< ItoMergeParticle > &a_merge, int a_numParticlesPerCellThresh)
Split every under-full cell up to the target count.
Definition CD_ItoSolver.cpp:3998
int m_verbosity
Verbosity level for this solver.
Definition CD_ItoSolver.H:1303
ItoSolver(const ItoSolver &)=delete
Deleted copy constructor.
void depositGathered(EBAMRCellData &a_phi, const ParticleContainer< ItoParticle > &a_particles, DepositionType a_deposition, CoarseFineDeposition a_coarseFineDeposition, Gather a_gather) const
Deposit a gathered per-particle quantity on the mesh (kappa-conservative + redistribution).
Definition CD_ItoSolverImplem.H:132
virtual void setParticleDiffusion(Real a_diffCo)
Sets diffusion coefficient for all particles.
Definition CD_ItoSolver.cpp:2452
virtual void depositDiffusivity(EBAMRCellData &a_phi, ParticleContainer< ItoParticle > &a_particles) const
Deposit diffusivity (i.e. mass*D/volume)
Definition CD_ItoSolver.cpp:1876
WhichCheckpoint
How to checkpoint files.
Definition CD_ItoSolver.H:1137
Real m_normalDistributionTruncation
Truncation value for normal distribution.
Definition CD_ItoSolver.H:1293
std::optional< ParticleManagement::ParticleMergeMethod > m_regridMergeMethod
Which merge method to run inside ItoSolver::regrid(), or nullopt for "whatever merge_algorithm says".
Definition CD_ItoSolver.H:1204
void drawNewParticles(const LevelData< EBCellFAB > &a_particlesPerCell, int a_level, int a_newPPC)
Restart particles from a specified number of particles in the grid cell.
Definition CD_ItoSolver.cpp:1450
bool m_plotParticlesEB
Flag for depositing and plotting the EB particles on the mesh.
Definition CD_ItoSolver.H:1378
bool m_blendConservation
Flag for blending the deposition clouds with the "non-conservative" divergence.
Definition CD_ItoSolver.H:1343
virtual EBAMRCellData & getPhi()
Get the mesh data.
Definition CD_ItoSolver.cpp:2321
virtual void allocate()
Allocate internal storage.
Definition CD_ItoSolver.cpp:1189
void mergeKDSkinNn(ParticleContainer< ItoMergeParticle > &merge, const Vector< int > &a_particlesPerCell)
Whole-container merge: kd-tree with a nearest-neighbour skin (the kd_skin_nn selector).
Definition CD_ItoSolver.cpp:4424
virtual void setVelocityFunction(const RealVect &a_velocity)
Utility function – set a constant velocity.
Definition CD_ItoSolver.cpp:2409
WhichMobilityInterpolation m_mobilityInterp
Switch for deciding how to interpolate mobilities, i.e. interpolating either mu*E or just mu (to the ...
Definition CD_ItoSolver.H:1162
void parseVerbosity()
Parse class verbosity.
Definition CD_ItoSolver.cpp:153
static constexpr int m_comp
Default component in data holders (do not touch).
Definition CD_ItoSolver.H:1125
virtual void depositHybrid(EBAMRCellData &a_depositionH, EBAMRIVData &a_massDifference, const EBAMRIVData &a_depositionNC) const
Make the "hybrid" deposition phiH = kappa*phiC + (1-kappa)*phiNC. On input, a_depositionH should cont...
Definition CD_ItoSolver.cpp:2194
void parseDivergenceComputation()
Parse whether or not to compute a "non-conservative" divergence when redistributing mass.
Definition CD_ItoSolver.cpp:364
RefCountedPtr< AmrMesh > m_amr
AMR; needed for grid stuff.
Definition CD_ItoSolver.H:1265
ItoSolver(ItoSolver &&)=default
Default move constructor.
virtual void depositEnergyDensity(EBAMRCellData &a_phi, ParticleContainer< ItoParticle > &a_particles) const
Deposit energy densities (i.e. mass*energy/volume => total energy per unit volume)
Definition CD_ItoSolver.cpp:1912
void parseRNG()
Parse RNG options – this parses the RNG seed and instantiates the distributions.
Definition CD_ItoSolver.cpp:166
void depositWeightNGP(LevelData< EBCellFAB > &a_output, const ParticleContainer< ItoParticle > &a_particles, int a_level) const noexcept
Do an NGP deposit of the SoA weight column on a specific grid level. Used for IO.
Definition CD_ItoSolver.cpp:2078
DepositionType getDeposition() const
Get deposition method.
Definition CD_ItoSolver.cpp:3362
void parseTruncation()
Parse the normal distribution truncation level.
Definition CD_ItoSolver.cpp:180
EBAMRIVData m_massDiff
Scratch storage for holding the mass difference when using hybrid deposition.
Definition CD_ItoSolver.H:1461
virtual void setParticleMobility(Real a_mobility)
Sets mobility coefficient for all particles.
Definition CD_ItoSolver.cpp:2422
bool m_nnPairIterate
nn_pair_tree/nn_pair_onecell/nn_pair_hash: iterate the local trivial tier to convergence within each ...
Definition CD_ItoSolver.H:1212
EBAMRCellData m_phi
Storage for particle mesh data.
Definition CD_ItoSolver.H:1423
virtual void initialData()
Set the initial data.
Definition CD_ItoSolver.cpp:666
virtual void computeAverageDiffusion(EBAMRCellData &a_phi, ParticleContainer< ItoParticle > &a_particles) const
Compute average diffusion coefficient.
Definition CD_ItoSolver.cpp:1983
virtual void parseRuntimeOptions()
Parse class runtime configurable options.
Definition CD_ItoSolver.cpp:134
bool m_plotDiffCo
Flag for outputting m_diffusionFunction to plot files.
Definition CD_ItoSolver.H:1368
ParticleManagement::ParticleMerger< ItoMergeParticle > m_particleCellMerger
User-supplied per-cell merger for merge_algorithm = external (set via setParticleCellMerger())....
Definition CD_ItoSolver.H:1169
virtual void setTime(int a_step, Real a_time, Real a_dt)
Set the time for this solver.
Definition CD_ItoSolver.cpp:653
virtual void transferCoveredParticles(EBRepresentation a_representation, Real a_tol)
Transfer particles that are covered (within a_tol distance from EB) to another container.
Definition CD_ItoSolver.cpp:925
virtual void remapAll()
Remap all particle containers.
Definition CD_ItoSolver.cpp:3325
int m_nnPairFallback
nn_pair_tree/nn_pair_onecell/nn_pair_hash: number of fallback candidates per query....
Definition CD_ItoSolver.H:1218
WhichMobilityInterpolation
Enum for deciding how to interpolate particle mobilities.
Definition CD_ItoSolver.H:1148
virtual const RefCountedPtr< ItoSpecies > & getSpecies() const
Get the species.
Definition CD_ItoSolver.cpp:101
bool m_isMobile
If true, solver is mobile, i.e. advection is turned on.
Definition CD_ItoSolver.H:1353
void mergeReinitialize(ParticleContainer< ItoMergeParticle > &a_particles, const Vector< int > &a_particlesPerCell)
Cell-based merge: redistribute each cell's physical particles into near-equal integer weights at rand...
Definition CD_ItoSolver.cpp:3734
virtual int getNumberOfPlotVariables() const
Get number of plot variables.
Definition CD_ItoSolver.cpp:1560
void depositGatheredNGP(LevelData< EBCellFAB > &a_output, const ParticleContainer< ItoParticle > &a_particles, int a_level, Gather a_gather) const noexcept
Do an NGP deposit of a gathered per-particle quantity on a specific grid level. Used for IO.
Definition CD_ItoSolverImplem.H:84
virtual void preRegrid(int a_lbase, int a_oldFinestLevel)
Perform pre-regrid operations.
Definition CD_ItoSolver.cpp:2259
virtual void writePlotData(LevelData< EBCellFAB > &a_output, int &a_comp, const std::string &a_outputRealm, int a_level) const noexcept
Write plot data.
Definition CD_ItoSolver.cpp:1652
Vector< int > m_particlesPerCell
Target number of computational particles per cell, per AMR level.
Definition CD_ItoSolver.H:1192
virtual void generateParticlesFromDensity(ParticleContainer< ItoParticle > &a_particles, const std::function< Real(const RealVect x)> &a_densityFunc, const Vector< int > &a_maxParticlesPerCell) const noexcept
Fill a particle container randomly with particles such that we obtain the target uniform density,...
Definition CD_ItoSolver.cpp:729
EBAMRFAB m_kdMergeCellHistogram
Per-cell occupancy scratch for the kd merges (see ParticleManagement::mergeKDCarve).
Definition CD_ItoSolver.H:1446
virtual void redistributeAMR(EBAMRCellData &a_phi) const
Redistribute mass in an AMR context.
Definition CD_ItoSolver.cpp:2133
bool m_plotParticlesCovered
Flag for depositing and plotting the covered particles on the mesh.
Definition CD_ItoSolver.H:1393
EBIntersection m_intersectionAlg
Algorithm for EB intersection.
Definition CD_ItoSolver.H:1490
Real m_time
Current time.
Definition CD_ItoSolver.H:1313
virtual void setParticleCellMerger(const ParticleManagement::ParticleMerger< ItoMergeParticle > &a_particleCellMerger) noexcept
Set the user-supplied per-cell particle merger used by merge_algorithm = external.
Definition CD_ItoSolver.cpp:92
virtual void regrid(int a_lmin, int a_oldFinestLevel, int a_newFinestLevel)
Regrid this solver.
Definition CD_ItoSolver.cpp:1084
virtual void clear(WhichContainer a_container)
Clear a particle container – this will delete all the particles in the input container.
Definition CD_ItoSolver.cpp:4828
ParticleManagement::ParticleMergeMethod m_mergeMethod
The configured merge method (which specific algorithm).
Definition CD_ItoSolver.H:1177
phase::which_phase m_phase
Phase where this solver lives.
Definition CD_ItoSolver.H:1275
virtual bool isDiffusive() const
Check if solver is diffusive.
Definition CD_ItoSolver.cpp:2251
void rebuildFromMergeContainer(WhichContainer a_container, ParticleContainer< ItoMergeParticle > &a_merge)
Rebuild a container's ItoParticles from the reduced particles.
Definition CD_ItoSolver.cpp:4073
virtual EBIntersection getIntersectionAlgorithm() const noexcept
Get the EB-particle intersection algorithm.
Definition CD_ItoSolver.cpp:508
virtual EBAMRCellData & getMobilityFunction()
Get mobility function.
Definition CD_ItoSolver.cpp:2376
void parseDeposition()
Parse particle deposition methods.
Definition CD_ItoSolver.cpp:252
RefCountedPtr< ComputationalGeometry > m_computationalGeometry
Computational geometry.
Definition CD_ItoSolver.H:1260
virtual void setDiffusionFunction(Real a_diffusionCoefficient)
Utility function – set a constant diffusion coefficient.
Definition CD_ItoSolver.cpp:2398
virtual ParticleContainer< ItoMergeParticle > & getRegridParticles() noexcept
Get the reduced holder the bulk particles ride across a regrid in.
Definition CD_ItoSolver.cpp:527
ItoSolver & operator=(ItoSolver &&)=default
Default move assignment operator.
virtual Real computeAdvectiveDt() const
Compute advection time step dt = dx/vMax where vMax is the largest velocity component of the particle...
Definition CD_ItoSolver.cpp:3145
void invalidateParticleIDs(ParticleContainer< ItoMergeParticle > &a_particles) const
Set every particle id in a reduced-particle container to ParticleSoA::s_invalidID.
Definition CD_ItoSolver.cpp:3567
virtual void organizeParticlesByPatch(WhichContainer a_container)
Sort the input particle container by patch.
Definition CD_ItoSolver.cpp:3393
EBAMRFAB m_kdMergeLeafQuota
Per-cell merge-quota scratch for the kd merges. Same lifetime as m_kdMergeCellHistogram.
Definition CD_ItoSolver.H:1451
virtual void setVerbosity(int a_verbosity)
Set verbosity level for this solver.
Definition CD_ItoSolver.cpp:641
void parsePlotVariables()
Parse plot variables.
Definition CD_ItoSolver.cpp:193
bool m_plotParticlesDomain
Flag for depositing and plotting the domain particles on the mesh.
Definition CD_ItoSolver.H:1383
bool m_plotVelocity
Flag for outputting m_velocityFunction to plot files.
Definition CD_ItoSolver.H:1363
AMR-hierarchy container of computational particles, stored per patch in Struct-of-Arrays form.
Definition CD_ParticleContainer.H:123
Arena-backed Struct-of-Arrays particle container for a single grid patch.
Definition CD_ParticleSoA.H:655
std::function< void(ParticleSoA< P, Traits > &a_particles, const CellInfo &a_cellInfo, const int a_numTargetParticles)> ParticleMerger
Concept for splitting/merging particles.
Definition CD_ParticleManagement.H:84
ParticleMergeMethod
The specific super-particle merge methods.
Definition CD_ParticleManagement.H:40
@ EqualWeightKD
Cell: makeEqualWeightKDMerger.
Phase names namespace.
Definition CD_MultiFluidIndexSpace.H:28
which_phase
Enumeration of supported phases.
Definition CD_MultiFluidIndexSpace.H:38
Reduced Ito particle: everything an ItoParticle carries that is not recomputed from the mesh.
Definition CD_ItoMergeParticle.H:40
SoA payload for ItoSolver particles, i.e. drifting Brownian walkers.
Definition CD_ItoParticle.H:31