13 #ifndef CD_ItoSolverImplem_H
14 #define CD_ItoSolverImplem_H
27 #include <CD_NamespaceHeader.H>
34 auto sign = [](
const Real& a) -> Real {
35 return (a > 0) - (a < 0);
38 RealVect r = RealVect::Zero;
39 for (
int i = 0; i < SpaceDim; i++) {
48 template <ItoSolver::WhichContainer C>
52 const DataIndex a_dit,
53 const bool a_destructive)
55 CH_TIME(
"ItoSolver::addParticles");
57 pout() <<
m_name +
"::addParticles" << endl;
62 ListBox<ItoParticle>& my_particles = particles[a_lvl][a_dit];
64 my_particles.addItemsDestructive(a_inputParticles.listItems());
67 my_particles.addItems(a_inputParticles.listItems());
71 template <
class P, const Real& (P::*particleScalarField)() const>
75 CH_TIME(
"ItoSolver::depositParticles");
77 pout() <<
m_name +
"::depositParticles" << endl;
83 template <
class P, const Real& (P ::*particleScalarField)() const>
87 const int a_level)
const noexcept
89 CH_TIME(
"ItoSolver::depositParticles(NGP)");
90 if (m_verbosity > 5) {
91 pout() << m_name +
"::depositParticles(NGP)" << endl;
94 CH_assert(a_level >= 0);
95 CH_assert(a_level <= m_amr->getFinestLevel());
97 const ProblemDomain& domain = m_amr->getDomains()[a_level];
98 const DisjointBoxLayout& dbl = m_amr->getGrids(a_particles.getRealm())[a_level];
99 const DataIterator& dit = dbl.dataIterator();
100 const EBISLayout& ebisl = m_amr->getEBISLayout(a_particles.getRealm(), m_phase)[a_level];
101 const Real dx = m_amr->getDx()[a_level];
102 const RealVect probLo = m_amr->getProbLo();
104 CH_assert(a_output.disjointBoxLayout() == dbl);
106 const int nbox = dit.size();
108 #pragma omp parallel for schedule(runtime)
109 for (
int mybox = 0; mybox < nbox; mybox++) {
110 const DataIndex& din = dit[mybox];
112 const Box cellBox = dbl[din];
113 const EBISBox& ebisbox = ebisl[din];
115 EBParticleMesh particleMesh(domain, cellBox, ebisbox, dx * RealVect::Unit, probLo);
117 EBCellFAB& output = a_output[din];
118 const List<P>& particles = a_particles[a_level][din].listItems();
120 particleMesh.
deposit<P, particleScalarField>(particles, output, DepositionType::NGP,
true);
124 template <
class P, Real (P ::*particleScalarField)() const>
128 const int a_level)
const noexcept
130 CH_TIME(
"ItoSolver::depositParticles(NGP)");
131 if (m_verbosity > 5) {
132 pout() << m_name +
"::depositParticles(NGP)" << endl;
135 CH_assert(a_level >= 0);
136 CH_assert(a_level <= m_amr->getFinestLevel());
138 const ProblemDomain& domain = m_amr->getDomains()[a_level];
139 const DisjointBoxLayout& dbl = m_amr->getGrids(a_particles.getRealm())[a_level];
140 const DataIterator& dit = dbl.dataIterator();
141 const EBISLayout& ebisl = m_amr->getEBISLayout(a_particles.getRealm(), m_phase)[a_level];
142 const Real dx = m_amr->getDx()[a_level];
143 const RealVect probLo = m_amr->getProbLo();
145 CH_assert(a_output.disjointBoxLayout() == dbl);
147 const int nbox = dit.size();
149 #pragma omp parallel for schedule(runtime)
150 for (
int mybox = 0; mybox < nbox; mybox++) {
151 const DataIndex& din = dit[mybox];
153 const Box cellBox = dbl[din];
154 const EBISBox& ebisbox = ebisl[din];
156 EBParticleMesh particleMesh(domain, cellBox, ebisbox, dx * RealVect::Unit, probLo);
158 EBCellFAB& output = a_output[din];
159 const List<P>& particles = a_particles[a_level][din].listItems();
161 particleMesh.deposit<P, particleScalarField>(particles, output, DepositionType::NGP,
true);
165 template <
class P, const Real& (P::*particleScalarField)() const>
172 CH_TIME(
"ItoSolver::depositParticles");
174 pout() <<
m_name +
"::depositParticles" << endl;
177 CH_assert(a_phi[0]->nComp() == 1);
182 this->depositKappaConservative<P, particleScalarField>(a_phi, a_particles, a_deposition, a_coarseFineDeposition);
192 template <
class P, Real (P::*particleScalarField)() const>
199 CH_TIME(
"ItoSolver::depositParticles");
201 pout() <<
m_name +
"::depositParticles" << endl;
204 CH_assert(a_phi[0]->nComp() == 1);
209 this->depositKappaConservative<P, particleScalarField>(a_phi, a_particles, a_deposition, a_coarseFineDeposition);
219 template <
class P, const Real& (P::*particleScalarField)() const>
226 CH_TIME(
"ItoSolver::depositKappaConservative");
228 pout() <<
m_name +
"::depositKappaConservative" << endl;
231 CH_assert(a_phi[0]->nComp() == 1);
235 switch (a_coarseFineDeposition) {
236 case CoarseFineDeposition::Interp: {
237 m_amr->depositParticles<P, particleScalarField>(a_phi,
242 CoarseFineDeposition::Interp,
246 case CoarseFineDeposition::Halo: {
252 m_amr->depositParticles<P, particleScalarField>(a_phi,
257 CoarseFineDeposition::Halo,
260 a_particles.clearMaskParticles();
264 case CoarseFineDeposition::HaloNGP: {
270 m_amr->depositParticles<P, particleScalarField>(a_phi,
275 CoarseFineDeposition::HaloNGP,
278 a_particles.transferParticles(a_particles.getMaskParticles());
283 MayDay::Error(
"ItoSolverImplem.H in function ItoSolver::depositKappaConservative -- logic bust!");
289 template <
class P, Real (P::*particleScalarField)() const>
296 CH_TIME(
"ItoSolver::depositKappaConservative");
298 pout() <<
m_name +
"::depositKappaConservative" << endl;
301 CH_assert(a_phi[0]->nComp() == 1);
305 switch (a_coarseFineDeposition) {
306 case CoarseFineDeposition::Interp: {
307 m_amr->depositParticles<P, particleScalarField>(a_phi,
312 CoarseFineDeposition::Interp,
316 case CoarseFineDeposition::Halo: {
322 m_amr->depositParticles<P, particleScalarField>(a_phi,
327 CoarseFineDeposition::Halo,
330 a_particles.clearMaskParticles();
334 case CoarseFineDeposition::HaloNGP: {
338 a_particles.transferMaskParticles(mask);
340 m_amr->depositParticles<P, particleScalarField>(a_phi,
345 CoarseFineDeposition::HaloNGP,
348 a_particles.transferParticles(a_particles.getMaskParticles());
353 MayDay::Error(
"ItoSolverImplem.H in function ItoSolver::depositKappaConservative -- logic bust!");
360 #include <CD_NamespaceFooter.H>
CoarseFineDeposition
Coarse-fine deposition types (see CD_EBAMRParticleMesh for how these are handled).
Definition: CD_CoarseFineDeposition.H:26
Agglomeration of useful data operations.
DepositionType
Deposition types.
Definition: CD_DepositionType.H:23
Declaration of solver class for Ito diffusion.
File containing some useful static methods related to random number generation.
Vector< RefCountedPtr< LevelData< BaseFab< bool > >> > AMRMask
Alias for cutting down on the typic of booleans defined over AMR grids.
Definition: CD_Realm.H:36
A class for depositing and interpolating particles. Contains various useful routines for interpolatio...
Definition: CD_EBParticleMesh.H:34
void deposit(const List< P > &a_particleList, EBCellFAB &a_rho, const DepositionType a_depositionType, const bool a_forceIrregNGP=false) const
Deposit particle onto the mesh using a standard cloud width.
Definition: CD_EBParticleMeshImplem.H:25
CoarseFineDeposition m_coarseFineDeposition
Coarse-fine deposition strategy.
Definition: CD_ItoSolver.H:1246
virtual void depositParticles()
Deposit particles onto mesh.
Definition: CD_ItoSolver.cpp:1752
void depositKappaConservative(EBAMRCellData &a_phi, ParticleContainer< P > &a_particles, const DepositionType a_deposition, const CoarseFineDeposition a_coarseFineDeposition) const
Compute the cell-centered deposition – this is the main deposition function.
Definition: CD_ItoSolverImplem.H:221
bool m_forceIrregDepositionNGP
NGP deposition in cut cells or not.
Definition: CD_ItoSolver.H:1156
void depositParticlesNGP(LevelData< EBCellFAB > &a_output, const ParticleContainer< P > &a_particles, const int a_level) const noexcept
Do an NGP deposit on a specific grid level. Used for IO.
Definition: CD_ItoSolverImplem.H:85
std::string m_realm
Realm where this solve lives.
Definition: CD_ItoSolver.H:1084
DepositionType m_deposition
Deposition method when depositing particles to the mesh.
Definition: CD_ItoSolver.H:1241
std::string m_name
Solver name.
Definition: CD_ItoSolver.H:1109
RealVect randomGaussian() const
Draw a random N-dimensional Gaussian number from a normal distribution with zero with and unit standa...
Definition: CD_ItoSolverImplem.H:30
std::map< WhichContainer, ParticleContainer< ItoParticle > > m_particleContainers
Various particle containers with identifiers.
Definition: CD_ItoSolver.H:1286
int m_haloBuffer
Size of refinement boundary halo.
Definition: CD_ItoSolver.H:1141
int m_verbosity
Verbosity level for this solver.
Definition: CD_ItoSolver.H:1131
void addParticles(ListBox< ItoParticle > &a_inputParticles, const int a_lvl, const DataIndex a_dit, const bool a_destructive)
Add particles to a contain. This adds into a specific grid level and patch. The user can delete the i...
Definition: CD_ItoSolverImplem.H:50
Real m_normalDistributionTruncation
Truncation value for normal distribution.
Definition: CD_ItoSolver.H:1121
RefCountedPtr< AmrMesh > m_amr
AMR; needed for grid stuff.
Definition: CD_ItoSolver.H:1094
virtual void redistributeAMR(EBAMRCellData &a_phi) const
Redistribute mass in an AMR context.
Definition: CD_ItoSolver.cpp:1777
phase::which_phase m_phase
Phase where this solver lives.
Definition: CD_ItoSolver.H:1104
Templated class for holding particles on an AMR hierarchy with particle remapping.
Definition: CD_ParticleContainer.H:50
void transferMaskParticles(const Vector< RefCountedPtr< LevelData< BaseFab< bool >>>> &a_mask)
Copy particles to the mask particle data holder.
Definition: CD_ParticleContainerImplem.H:1599
bool isOrganizedByCell() const
Is cell-sorted or not.
Definition: CD_ParticleContainerImplem.H:224
void copyMaskParticles(const Vector< RefCountedPtr< LevelData< BaseFab< bool >>>> &a_mask) const
Copy particles to mask particle data holder.
Definition: CD_ParticleContainerImplem.H:1533
static Real getNormal01()
Get a number from a normal distribution centered on zero and variance 1.
Definition: CD_RandomImplem.H:163
Real min(const Real &a_input) noexcept
Get the minimum of the input, reduced over MPI ranks (in the Chombo communicator)
Definition: CD_ParallelOpsImplem.H:58