12 #ifndef CD_EBAMRSurfaceDepositionImplem_H
13 #define CD_EBAMRSurfaceDepositionImplem_H
16 #include <ParmParse.H>
24 #include <CD_NamespaceHeader.H>
26 template <
class P, const Real& (P::*particleScalarField)() const>
30 CH_TIME(
"EBAMRSurfaceDeposition::deposit");
32 pout() <<
"EBAMRSurfaceDeposition::deposit<P, const Real& P::*func const>" << endl;
35 CH_assert(a_meshData.getRealm() == a_particles.getRealm());
38 for (
int lvl = 0; lvl <= m_finestLevel; lvl++) {
39 const DisjointBoxLayout& dbl = m_ebGrids[lvl]->getDBL();
40 const EBISLayout& ebisl = m_ebGrids[lvl]->getEBISL();
41 const DataIterator& dit = dbl.dataIterator();
43 const int nbox = dit.size();
44 #pragma omp parallel for schedule(runtime)
45 for (
int mybox = 0; mybox < nbox; mybox++) {
46 const DataIndex& din = dit[mybox];
48 const Box cellBox = dbl[din];
49 const EBISBox& ebisbox = ebisl[din];
50 const BaseIVFAB<VoFStencil>& stencils = (*m_depositionStencils[lvl])[din];
52 BaseIVFAB<Real>& meshData = (*m_data[lvl])[din];
53 const List<P>& particles = a_particles[lvl][din].listItems();
57 for (ListIterator<P> lit(particles); lit.ok(); ++lit) {
63 if (!(cellBox.contains(iv))) {
64 MayDay::Error(
"CD_EBAMRSurfaceDeposition::deposit -- particle is not inside the box");
67 if (ebisbox.isIrregular(iv)) {
68 const VoFStencil& stencil = stencils(VolIndex(iv, 0), 0);
70 for (
int i = 0; i < stencil.size(); i++) {
71 const VolIndex& stencilVoF = stencil.vof(i);
72 const Real& stencilWeight = stencil.weight(i);
73 const Real depositionWeight = stencilWeight * (p.*particleScalarField)();
75 meshData(stencilVoF, 0) += depositionWeight;
82 m_data[lvl]->exchange(Interval(0, 0), m_copierLevel[lvl],
IrregAddOp());
87 this->addInvalidCoarseDataToFineData();
88 this->addFineGhostDataToValidCoarData();
91 for (
int lvl = 0; lvl <= m_finestLevel; lvl++) {
92 CH_assert(!(a_meshData[lvl].isNull()));
93 CH_assert(a_meshData[lvl]->nComp() == 1);
95 const Interval interv = Interval(0, 0);
97 m_data[lvl]->copyTo(interv, *a_meshData[lvl], interv, m_validToValidCopiers[lvl]);
101 template <
class P, Real (P::*particleScalarField)()>
105 CH_TIME(
"EBAMRSurfaceDeposition::deposit");
107 pout() <<
"EBAMRSurfaceDeposition::deposit<P, Real P::*func>" << endl;
110 CH_assert(a_meshData.getRealm() == a_particles.getRealm());
113 for (
int lvl = 0; lvl <= m_finestLevel; lvl++) {
114 const DisjointBoxLayout& dbl = m_ebGrids[lvl]->getDBL();
115 const EBISLayout& ebisl = m_ebGrids[lvl]->getEBISL();
116 const DataIterator& dit = dbl.dataIterator();
118 const int nbox = dit.size();
119 #pragma omp parallel for schedule(runtime)
120 for (
int mybox = 0; mybox < nbox; mybox++) {
121 const DataIndex& din = dit[mybox];
123 const Box cellBox = dbl[din];
124 const EBISBox& ebisbox = ebisl[din];
125 const BaseIVFAB<VoFStencil>& stencils = (*m_depositionStencils[lvl])[din];
127 BaseIVFAB<Real>& meshData = (*m_data[lvl])[din];
128 const List<P>& particles = a_particles[lvl][din].listItems();
130 meshData.setVal(0.0);
132 for (ListIterator<P> lit(particles); lit.ok(); ++lit) {
138 if (!(cellBox.contains(iv))) {
139 MayDay::Error(
"CD_EBAMRSurfaceDeposition::deposit -- particle is not inside the box");
142 if (ebisbox.isIrregular(iv)) {
143 const VoFStencil& stencil = stencils(VolIndex(iv, 0), 0);
145 for (
int i = 0; i < stencil.size(); i++) {
146 const VolIndex& stencilVoF = stencil.vof(i);
147 const Real& stencilWeight = stencil.weight(i);
148 const Real depositionWeight = stencilWeight * (p.*particleScalarField)();
150 meshData(stencilVoF, 0) += depositionWeight;
157 m_data[lvl]->exchange(Interval(0, 0), m_copierLevel[lvl],
IrregAddOp());
162 this->addInvalidCoarseDataToFineData();
163 this->addFineGhostDataToValidCoarData();
166 for (
int lvl = 0; lvl <= m_finestLevel; lvl++) {
167 CH_assert(!(a_meshData[lvl].isNull()));
168 CH_assert(a_meshData[lvl]->nComp() == 1);
170 const Interval interv = Interval(0, 0);
172 m_data[lvl]->copyTo(interv, *a_meshData[lvl], interv, m_validToValidCopiers[lvl]);
176 #include <CD_NamespaceFooter.H>
Agglomeration of useful data operations.
Declaration of a class for handling surface deposition of particles with EB and AMR.
Declaration of a Copier class for making incrementation between LevelData<BaseIVFAB<Real>> easier.
Declaration of a static class containing some common useful particle routines that would otherwise be...
void deposit(EBAMRIVData &a_meshData, const ParticleContainer< P > &a_particles) const noexcept
Deposit function. Deposits particle on surface.
Definition: CD_EBAMRSurfaceDepositionImplem.H:28
A Copier class for making copying between LevelData<BaseIVFAB<Real>> easier. This is an incrementatio...
Definition: CD_IrregAddOp.H:26
Templated class for holding particles on an AMR hierarchy with particle remapping.
Definition: CD_ParticleContainer.H:50
static IntVect getParticleCellIndex(const RealVect &a_particlePosition, const RealVect &a_probLo, const Real &a_dx) noexcept
Get the cell index corresponding to the particle position.
Definition: CD_ParticleOpsImplem.H:26