14#ifndef CD_ITOSOLVERIMPLEM_H
15#define CD_ITOSOLVERIMPLEM_H
29#include <CD_NamespaceHeader.H>
37 auto sign = [](
const Real& a) -> Real {
38 return (a > 0) - (a < 0);
41 RealVect r = RealVect::Zero;
42 for (
int i = 0; i < SpaceDim; i++) {
51template <
typename P,
typename Traits>
58 CH_TIME(
"ItoSolver::depositWeight");
60 pout() <<
m_name +
"::depositWeight" << endl;
63 CH_assert(a_phi[0]->nComp() == 1);
64 CH_assert(a_phi.getRealm() ==
m_realm);
71 m_amr->depositWeight(a_phi,
76 a_coarseFineDeposition,
82template <
typename Gather>
87 Gather a_gather)
const noexcept
89 CH_TIME(
"ItoSolver::depositGatheredNGP");
90 if (m_verbosity > 5) {
91 pout() << m_name +
"::depositGatheredNGP" << 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];
124 .
depositGathered(output, 0, leaf, DepositionType::NGP, 1.0,
true, [&](
const std::size_t a_i, Real* a_out) {
125 a_out[0] = a_gather(leaf, a_i);
130template <
typename Gather>
136 Gather a_gather)
const
138 CH_TIME(
"ItoSolver::depositGathered");
140 pout() <<
m_name +
"::depositGathered" << endl;
143 CH_assert(a_phi[0]->nComp() == 1);
148 m_amr->depositGathered(a_phi,
153 a_coarseFineDeposition,
160#include <CD_NamespaceFooter.H>
CoarseFineDeposition
Coarse-fine deposition types (see CD_EBAMRParticleMesh for how these are handled).
Definition CD_CoarseFineDeposition.H:28
Agglomeration of useful data operations.
DepositionType
Deposition types.
Definition CD_DepositionType.H:24
Single-patch ParticleSoA deposit/interpolate onto an embedded-boundary mesh.
Declaration of solver class for Ito diffusion.
File containing some useful static methods related to random number generation.
Deposits/interpolates ParticleSoA leaves on a single patch, with embedded-boundary (cut-cell) awarene...
Definition CD_EBParticleMesh.H:71
void depositGathered(EBCellFAB &a_meshData, const int a_comp, const ParticleSoA< P, Traits > &a_particles, const DepositionType a_depositionType, const Real a_widthScale, const bool a_forceIrregNGP, GatherFunc &&a_gather) const
Deposit a custom per-particle scalar (computed by a_gather) onto mesh component a_comp.
Definition CD_EBParticleMesh.H:263
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
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
std::string m_name
Solver name.
Definition CD_ItoSolver.H:1280
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
int m_verbosity
Verbosity level for this solver.
Definition CD_ItoSolver.H:1303
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
Real m_normalDistributionTruncation
Truncation value for normal distribution.
Definition CD_ItoSolver.H:1293
RefCountedPtr< AmrMesh > m_amr
AMR; needed for grid stuff.
Definition CD_ItoSolver.H:1265
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 redistributeAMR(EBAMRCellData &a_phi) const
Redistribute mass in an AMR context.
Definition CD_ItoSolver.cpp:2133
phase::which_phase m_phase
Phase where this solver lives.
Definition CD_ItoSolver.H:1275
AMR-hierarchy container of computational particles, stored per patch in Struct-of-Arrays form.
Definition CD_ParticleContainer.H:123
bool isOrganizedByCell() const
Whether the valid leaves are currently cell-sorted.
Definition CD_ParticleContainer.H:416
std::string getRealm() const
Realm label.
Definition CD_ParticleContainer.H:300
Arena-backed Struct-of-Arrays particle container for a single grid patch.
Definition CD_ParticleSoA.H:655
static Real getNormal01()
Get a number from a normal distribution centered on zero and variance 1.
Definition CD_RandomImplem.H:172