13#ifndef CD_AMRMESHIMPLEM_H
14#define CD_AMRMESHIMPLEM_H
19#include <CD_NamespaceHeader.H>
28 CH_TIME(
"AmrMesh::copyData(EBAMRData, simple)");
30 pout() <<
"AmrMesh::copyData(EBAMRData, simple)" << endl;
33 const int nComp = a_dst[0]->nComp();
34 const Interval dstComps = Interval(0, nComp - 1);
35 const Interval srcComps = Interval(0, nComp - 1);
37 const std::string toRealm = a_dst.getRealm();
38 const std::string fromRealm = a_src.getRealm();
41 CH_assert(!(a_dst[lvl].isNull()));
42 CH_assert(!(a_src[lvl].isNull()));
44 this->
copyData(*a_dst[lvl], *a_src[lvl], lvl, toRealm, fromRealm, dstComps, srcComps, a_toRegion, a_fromRegion);
52 const Interval& a_dstComps,
53 const Interval& a_srcComps,
57 CH_TIME(
"AmrMesh::copyData(EBAMRData, full)");
59 pout() <<
"AmrMesh::copyData(EBAMRData, full)" << endl;
62 const std::string toRealm = a_dst.getRealm();
63 const std::string fromRealm = a_src.getRealm();
66 CH_assert(!(a_dst[lvl].isNull()));
67 CH_assert(!(a_src[lvl].isNull()));
69 this->
copyData(*a_dst[lvl], *a_src[lvl], lvl, toRealm, fromRealm, a_dstComps, a_srcComps, a_toRegion, a_fromRegion);
76 const LevelData<T>& a_src,
78 const std::string a_toRealm,
79 const std::string a_fromRealm,
83 CH_TIME(
"AmrMesh::copyData(LD<T>_full)");
85 pout() <<
"AmrMesh::copyData(LD<T>_full)" << endl;
88 const Interval dstComps = Interval(0, a_dst.nComp() - 1);
89 const Interval srcComps = Interval(0, a_src.nComp() - 1);
91 this->
copyData(a_dst, a_src, a_level, a_toRealm, a_fromRealm, dstComps, srcComps, a_toRegion, a_fromRegion);
97 const LevelData<T>& a_src,
99 const std::string a_toRealm,
100 const std::string a_fromRealm,
101 const Interval& a_dstComps,
102 const Interval& a_srcComps,
106 CH_TIME(
"AmrMesh::copyData(LD<T>_full)");
108 pout() <<
"AmrMesh::copyData(LD<T>_full)" << endl;
111 CH_assert(a_dstComps.size() == a_srcComps.size());
112 CH_assert(a_dst.nComp() > a_dstComps.end());
113 CH_assert(a_src.nComp() > a_srcComps.end());
115 if (a_toRealm != a_fromRealm) {
116 const auto id = std::make_pair(a_fromRealm, a_toRealm);
118 if (a_toRegion == CopyStrategy::ValidGhost) {
121 if (a_fromRegion == CopyStrategy::ValidGhost) {
131 if (a_fromRegion == CopyStrategy::Valid) {
132 if (a_toRegion == CopyStrategy::Valid) {
135 else if (a_toRegion == CopyStrategy::ValidGhost) {
139 MayDay::Abort(
"AmrMesh::copyData - logic bust 1");
142 else if (a_fromRegion == CopyStrategy::ValidGhost) {
143 if (a_toRegion == CopyStrategy::Valid) {
146 else if (a_toRegion == CopyStrategy::ValidGhost) {
150 MayDay::Abort(
"AmrMesh::copyData - logic bust 2");
154 MayDay::Abort(
"AmrMesh::copyData - logic bust 3");
157 a_src.copyTo(a_srcComps, a_dst, a_dstComps, copier);
160 a_src.localCopyTo(a_srcComps, a_dst, a_dstComps);
168 CH_TIME(
"AmrMesh::deallocate(Vector<T*>)");
170 pout() <<
"AmrMesh::deallocate(Vector<T*>)" << endl;
182 CH_TIME(
"AmrMesh::deallocate(Vector<RefCountedPtr<T>)");
184 pout() <<
"AmrMesh::deallocate(Vector<RefCountedPtr<T>)" << endl;
187 for (
int lvl = 0; lvl < a_data.size(); lvl++) {
189 a_data[lvl] = RefCountedPtr<T>(0);
191 if(!a_data[lvl].isNull()){
192 delete &(*a_data[lvl]);
193 a_data[lvl] = RefCountedPtr<T> (NULL);
204 CH_TIME(
"AmrMesh::deallocate(EBAMRData<T>)");
206 pout() <<
"AmrMesh::deallocate(EBAMRData<T>)" << endl;
216 CH_TIME(
"AmrMesh::alias(Vector<T*>, Vector<RefCountedPtr<T>)");
218 pout() <<
"AmrMesh::alias(Vector<T*>, Vector<RefCountedPtr<T>)" << endl;
221 a_alias.resize(a_data.size());
223 for (
int lvl = 0; lvl < a_data.size(); lvl++) {
224 a_alias[lvl] = &(*a_data[lvl]);
228template <
typename T,
typename S>
232 CH_TIME(
"AmrMesh::alias(Vector<T*>, EBAMRData<S>)");
234 pout() <<
"AmrMesh::alias(Vector<T*>, EBAMRData<S>" << endl;
240template <
typename P,
typename Traits>
244 CH_TIME(
"AmrMesh::allocate(ParticleContainer<P, Traits>, string)");
246 pout() <<
"AmrMesh::allocate(ParticleContainer<P, Traits>, string)" << endl;
250 const std::string str =
"AmrMesh::allocate(ParticleContainer<P, Traits>, string) - could not find Realm '" +
252 MayDay::Abort(str.c_str());
271 CH_TIME(
"AmrMesh::allocatePointer(Vector<RefCountedPtr<T> >)");
273 pout() <<
"AmrMesh::allocatePointer(Vector<RefCountedPtr<T> >)" << endl;
278 a_data[lvl] = RefCountedPtr<T>(
new T());
286 CH_TIME(
"AmrMesh::allocatePointer(Vector<RefCountedPtr<T> >, int)");
288 pout() <<
"AmrMesh::allocatePointer(Vector<RefCountedPtr<T> >, int)" << endl;
291 a_data.resize(1 + a_finestLevel);
293 for (
int lvl = 0; lvl <= a_finestLevel; lvl++) {
294 a_data[lvl] = RefCountedPtr<T>(
new T());
302 CH_TIME(
"AmrMesh::allocatePointer(EBAMRData<T>, std::string)");
304 pout() <<
"AmrMesh::allocatePointer(EBAMRData<T>, std::string)" << endl;
316 CH_TIME(
"AmrMesh::allocatePointer(EBAMRData<T>, std::string, int)");
318 pout() <<
"AmrMesh::allocatePointer(EBAMRData<T>, std::string, int)" << endl;
326template <
typename P,
typename Traits>
330 const int a_newFinestLevel)
const noexcept
332 CH_TIME(
"AmrMesh::remapToNewGrids(ParticleContainer)");
334 pout() <<
"AmrMesh::remapToNewGrids(ParticleContainer)" << endl;
339 const std::string realm = a_particles.getRealm();
341 a_particles.regrid(this->
getGrids(realm),
350template <
typename P,
typename Traits>
353 const std::string& a_realm,
357 CH_TIME(
"AmrMesh::depositParticles(surface, SoA)");
359 pout() <<
"AmrMesh::depositParticles(surface, SoA)" << endl;
362 CH_assert(a_meshData[0]->nComp() == 1);
363 CH_assert(a_meshData.getRealm() == a_particles.getRealm());
367 surfaceDeposition.
deposit<P, Traits>(a_meshData, a_particles);
370template <
typename P,
typename Traits>
373 const std::string& a_realm,
380 CH_TIME(
"AmrMesh::depositWeight(ParticleContainer)");
382 pout() <<
"AmrMesh::depositWeight(ParticleContainer)" << endl;
387 particleMesh.
depositWeight(a_meshData, a_particles, a_depositionType, a_coarseFineDeposition, a_irregularDeposition);
390template <
typename P,
typename Traits,
typename CellGather>
393 const std::string& a_realm,
399 CellGather a_cellGather)
401 CH_TIME(
"AmrMesh::depositGathered(ParticleContainer)");
403 pout() <<
"AmrMesh::depositGathered(ParticleContainer)" << endl;
411 a_coarseFineDeposition,
412 a_irregularDeposition,
416template <
auto... Members,
typename P,
typename Traits>
419 const std::string& a_realm,
426 CH_TIME(
"AmrMesh::depositParticles(ParticleContainer)");
428 pout() <<
"AmrMesh::depositParticles(ParticleContainer)" << endl;
433 particleMesh.template deposit<Members...>(a_meshData,
436 a_coarseFineDeposition,
437 a_irregularDeposition);
440template <
typename P,
typename Traits>
443 const std::string& a_realm,
445 const EBAMRCellData& a_meshScalarField,
447 const bool a_forceIrregNGP)
const
449 CH_TIME(
"AmrMesh::interpolateWeight(ParticleContainer)");
451 pout() <<
"AmrMesh::interpolateWeight(ParticleContainer)" << endl;
456 particleMesh.
interpolateWeight(a_particles, a_meshScalarField, a_interpType, a_forceIrregNGP);
459template <
auto... Members,
typename P,
typename Traits>
462 const std::string& a_realm,
464 const EBAMRCellData& a_meshField,
466 const bool a_forceIrregNGP)
const
468 CH_TIME(
"AmrMesh::interpolateParticles(ParticleContainer)");
470 pout() <<
"AmrMesh::interpolateParticles(ParticleContainer)" << endl;
475 particleMesh.template interpolate<Members...>(a_particles, a_meshField, a_interpType, a_forceIrregNGP);
478template <
typename P,
typename Traits>
482 const Real a_tolerance)
const
484 CH_TIME(
"AmrMesh::removeCoveredParticlesIF(ParticleContainer)");
486 pout() <<
"AmrMesh::removeCoveredParticlesIF(ParticleContainer)" << endl;
490 RefCountedPtr<BaseIF> implicitFunction;
504 MayDay::Error(
"AmrMesh::removeCoveredParticlesIF(ParticleContainer) - logic bust");
508 const std::string whichRealm = a_particles.
getRealm();
511 const DisjointBoxLayout& dbl = this->
getGrids(whichRealm)[lvl];
512 const DataIterator& dit = dbl.dataIterator();
513 const Real dx = this->
getDx()[lvl];
514 const Real tol = a_tolerance * dx;
516 const int nbox = dit.size();
517#pragma omp parallel for schedule(runtime)
518 for (
int mybox = 0; mybox < nbox; mybox++) {
519 const DataIndex& din = dit[mybox];
525 while (i < leaf.
size()) {
526 if (implicitFunction->value(leaf.
position(i)) > tol) {
537template <
typename P,
typename Traits>
541 const Real a_tolerance)
const
543 CH_TIME(
"AmrMesh::removeCoveredParticlesDiscrete(ParticleContainer)");
545 pout() <<
"AmrMesh::removeCoveredParticlesDiscrete(ParticleContainer)" << endl;
548 const std::string whichRealm = a_particles.
getRealm();
551 const DisjointBoxLayout& dbl = this->
getGrids(whichRealm)[lvl];
552 const DataIterator& dit = dbl.dataIterator();
553 const EBISLayout& ebisl = this->
getEBISLayout(whichRealm, a_phase)[lvl];
554 const Real dx = this->
getDx()[lvl];
555 const Real tol = a_tolerance * dx;
557 const int nbox = dit.size();
558#pragma omp parallel for schedule(runtime)
559 for (
int mybox = 0; mybox < nbox; mybox++) {
560 const DataIndex& din = dit[mybox];
561 const EBISBox& ebisBox = ebisl[din];
562 const Box region = ebisBox.getRegion();
564 const bool isRegular = ebisBox.isAllRegular();
565 const bool isCovered = ebisBox.isAllCovered();
566 const bool isIrregular = !isRegular && !isCovered;
573 else if (isIrregular) {
576 while (i < leaf.
size()) {
577 const RealVect pos = leaf.
position(i);
580 CH_assert(region.contains(iv));
582 if (ebisBox.isCovered(iv)) {
585 else if (ebisBox.isIrregular(iv)) {
587 bool insideAtLeastOneVoF =
false;
589 const std::vector<VolIndex> vofs = ebisBox.getVoFs(iv).stdVector();
590 for (
const auto& vof : vofs) {
591 const RealVect ebNormal = ebisBox.normal(vof);
593 const Real faceProjection = ebNormal.dotProduct(pos - ebCentroid);
595 if (faceProjection >= -tol) {
596 insideAtLeastOneVoF =
true;
601 if (!insideAtLeastOneVoF) {
617template <
typename P,
typename Traits>
622 CH_TIME(
"AmrMesh::removeCoveredParticlesVoxels(ParticleContainer)");
624 pout() <<
"AmrMesh::removeCoveredParticlesVoxels(ParticleContainer)" << endl;
627 const std::string whichRealm = a_particles.
getRealm();
630 const DisjointBoxLayout& dbl = this->
getGrids(whichRealm)[lvl];
631 const DataIterator& dit = dbl.dataIterator();
632 const EBISLayout& ebisl = this->
getEBISLayout(whichRealm, a_phase)[lvl];
633 const Real dx = this->
getDx()[lvl];
635 const int nbox = dit.size();
636#pragma omp parallel for schedule(runtime)
637 for (
int mybox = 0; mybox < nbox; mybox++) {
638 const DataIndex& din = dit[mybox];
639 const EBISBox& ebisBox = ebisl[din];
640 const Box region = ebisBox.getRegion();
642 const bool isRegular = ebisBox.isAllRegular();
643 const bool isCovered = ebisBox.isAllCovered();
644 const bool isIrregular = !isRegular && !isCovered;
651 else if (isIrregular) {
653 while (i < leaf.
size()) {
654 const RealVect pos = leaf.
position(i);
655 const RealVect rv = (pos -
m_probLo) / dx;
656 const IntVect iv = IntVect(D_DECL(floor(rv[0]), floor(rv[1]), floor(rv[2])));
658 CH_assert(region.contains(iv));
660 if (ebisBox.isCovered(iv)) {
672template <
typename P,
typename Traits>
677 const Real a_tolerance)
const
679 CH_TIME(
"AmrMesh::transferCoveredParticlesIF(ParticleContainer)");
681 pout() <<
"AmrMesh::transferCoveredParticlesIF(ParticleContainer)" << endl;
685 RefCountedPtr<BaseIF> implicitFunction;
699 MayDay::Error(
"AmrMesh::transferCoveredParticlesIF(ParticleContainer) - logic bust");
703 const std::string realmFrom = a_particlesFrom.
getRealm();
704 const std::string realmTo = a_particlesTo.
getRealm();
706 CH_assert(realmFrom == realmTo);
709 const DisjointBoxLayout& dbl = this->
getGrids(realmFrom)[lvl];
710 const DataIterator& dit = dbl.dataIterator();
711 const Real dx = this->
getDx()[lvl];
712 const Real tol = a_tolerance * dx;
714 const int nbox = dit.size();
715#pragma omp parallel for schedule(runtime)
716 for (
int mybox = 0; mybox < nbox; mybox++) {
717 const DataIndex& din = dit[mybox];
724 while (i < from.
size()) {
725 if (implicitFunction->value(from.
position(i)) > tol) {
737template <
typename P,
typename Traits>
742 const Real a_tolerance)
const
744 CH_TIME(
"AmrMesh::transferCoveredParticlesDiscrete(ParticleContainer)");
746 pout() <<
"AmrMesh::transferCoveredParticlesDiscrete(ParticleContainer)" << endl;
749 const std::string realmFrom = a_particlesFrom.
getRealm();
750 const std::string realmTo = a_particlesTo.
getRealm();
752 CH_assert(realmFrom == realmTo);
755 const DisjointBoxLayout& dbl = this->
getGrids(realmFrom)[lvl];
756 const DataIterator& dit = dbl.dataIterator();
757 const EBISLayout& ebisl = this->
getEBISLayout(realmFrom, a_phase)[lvl];
758 const Real dx = this->
getDx()[lvl];
759 const Real tol = a_tolerance * dx;
761 const int nbox = dit.size();
762#pragma omp parallel for schedule(runtime)
763 for (
int mybox = 0; mybox < nbox; mybox++) {
764 const DataIndex& din = dit[mybox];
765 const EBISBox& ebisBox = ebisl[din];
766 const Box region = ebisBox.getRegion();
768 const bool isRegular = ebisBox.isAllRegular();
769 const bool isCovered = ebisBox.isAllCovered();
770 const bool isIrregular = !isRegular && !isCovered;
778 else if (isIrregular) {
781 while (i < from.
size()) {
782 const RealVect pos = from.
position(i);
785 CH_assert(region.contains(iv));
787 if (ebisBox.isCovered(iv)) {
791 else if (ebisBox.isIrregular(iv)) {
793 bool insideAtLeastOneVoF =
false;
795 const std::vector<VolIndex> vofs = ebisBox.getVoFs(iv).stdVector();
796 for (
const auto& vof : vofs) {
798 const RealVect ebNormal = ebisBox.normal(vof);
799 const Real faceProjection = ebNormal.dotProduct(pos - ebCentroid);
801 if (faceProjection >= -tol) {
802 insideAtLeastOneVoF =
true;
807 if (!insideAtLeastOneVoF) {
824template <
typename P,
typename Traits>
830 CH_TIME(
"AmrMesh::transferCoveredParticlesVoxels(ParticleContainer)");
832 pout() <<
"AmrMesh::transferCoveredParticlesVoxels(ParticleContainer)" << endl;
835 const std::string realmFrom = a_particlesFrom.
getRealm();
836 const std::string realmTo = a_particlesTo.
getRealm();
838 CH_assert(realmFrom == realmTo);
841 const DisjointBoxLayout& dbl = this->
getGrids(realmFrom)[lvl];
842 const DataIterator& dit = dbl.dataIterator();
843 const EBISLayout& ebisl = this->
getEBISLayout(realmFrom, a_phase)[lvl];
844 const Real dx = this->
getDx()[lvl];
846 const int nbox = dit.size();
847#pragma omp parallel for schedule(runtime)
848 for (
int mybox = 0; mybox < nbox; mybox++) {
849 const DataIndex& din = dit[mybox];
850 const EBISBox& ebisBox = ebisl[din];
851 const Box region = ebisBox.getRegion();
853 const bool isRegular = ebisBox.isAllRegular();
854 const bool isCovered = ebisBox.isAllCovered();
855 const bool isIrregular = !isRegular && !isCovered;
863 else if (isIrregular) {
865 while (i < from.
size()) {
866 const RealVect pos = from.
position(i);
869 CH_assert(region.contains(iv));
871 if (ebisBox.isCovered(iv)) {
884template <
auto... OldPosition,
typename P,
typename Traits>
891 const Real a_tolerance,
892 const bool a_deleteParticles,
895 CH_TIME(
"AmrMesh::intersectParticlesRaycastIF(ParticleContainer)");
897 pout() <<
"AmrMesh::intersectParticlesRaycastIF(ParticleContainer)" << endl;
900 static_assert(
sizeof...(OldPosition) == SpaceDim,
901 "AmrMesh::intersectParticlesRaycastIF(ParticleContainer) - need exactly SpaceDim oldPosition members");
909 const std::string whichRealm = a_activeParticles.
getRealm();
912 RefCountedPtr<BaseIF> implicitFunction;
926 MayDay::Error(
"AmrMesh::intersectParticlesRaycastIF(ParticleContainer) - logic bust");
935 constexpr Real safety = 1.E-6;
941 const DisjointBoxLayout& dbl = this->
getGrids(whichRealm)[lvl];
942 const DataIterator& dit = dbl.dataIterator();
947 const Real tolerance = a_tolerance *
m_dx[lvl];
949 const int nbox = dit.size();
950#pragma omp parallel for schedule(runtime)
951 for (
int mybox = 0; mybox < nbox; mybox++) {
952 const DataIndex& din = dit[mybox];
960 while (i < active.
size()) {
961 const RealVect newPos = active.
position(i);
966 ((oldPos[odir++] = active.template get<OldPosition>(i)), ...);
968 const RealVect path = newPos - oldPos;
971 bool checkEB =
false;
972 bool checkDomain =
false;
974 if (!implicitFunction.isNull()) {
977 for (
int dir = 0; dir < SpaceDim; dir++) {
978 const bool outsideLo = newPos[dir] <
m_probLo[dir];
979 const bool outsideHi = newPos[dir] >
m_probHi[dir];
981 if (outsideLo || outsideHi) {
987 if (checkEB || checkDomain) {
990 Real sDomain = std::numeric_limits<Real>::max();
991 Real sEB = std::numeric_limits<Real>::max();
993 bool contactDomain =
false;
994 bool contactEB =
false;
1005 if (contactDomain || contactEB) {
1006 if (sEB <= sDomain) {
1007 const RealVect intersectionPos = oldPos + sEB * path;
1012 if (a_deleteParticles) {
1017 a_nonDeletionModifier(active, i);
1022 RealVect intersectionPos = oldPos + sDomain * path;
1024 for (
int dir = 0; dir < SpaceDim; dir++) {
1025 intersectionPos[dir] = std::max(intersectionPos[dir],
m_probLo[dir] + safety *
m_dx[lvl]);
1026 intersectionPos[dir] = std::min(intersectionPos[dir],
m_probHi[dir] - safety *
m_dx[lvl]);
1032 if (a_deleteParticles) {
1037 a_nonDeletionModifier(active, i);
1054 a_ebParticles.
remap();
1055 a_domainParticles.
remap();
1058template <
auto... OldPosition,
typename P,
typename Traits>
1065 const Real a_bisectionStep,
1066 const bool a_deleteParticles,
1069 CH_TIME(
"AmrMesh::intersectParticlesBisectIF(ParticleContainer)");
1071 pout() <<
"AmrMesh::intersectParticlesBisectIF(ParticleContainer)" << endl;
1074 static_assert(
sizeof...(OldPosition) == SpaceDim,
1075 "AmrMesh::intersectParticlesBisectIF(ParticleContainer) - need exactly SpaceDim oldPosition members");
1086 const std::string whichRealm = a_activeParticles.
getRealm();
1089 RefCountedPtr<BaseIF> implicitFunction;
1103 MayDay::Error(
"AmrMesh::intersectParticlesBisectIF(ParticleContainer) - logic bust");
1112 constexpr Real safety = 1.E-6;
1118 const DisjointBoxLayout& dbl = this->
getGrids(whichRealm)[lvl];
1119 const DataIterator& dit = dbl.dataIterator();
1121 const int nbox = dit.size();
1122#pragma omp parallel for schedule(runtime)
1123 for (
int mybox = 0; mybox < nbox; mybox++) {
1124 const DataIndex& din = dit[mybox];
1132 while (i < active.
size()) {
1133 const RealVect newPos = active.
position(i);
1138 ((oldPos[odir++] = active.template get<OldPosition>(i)), ...);
1140 const RealVect path = newPos - oldPos;
1143 bool checkEB =
false;
1144 bool checkDomain =
false;
1146 if (!implicitFunction.isNull()) {
1149 for (
int dir = 0; dir < SpaceDim; dir++) {
1150 const bool outsideLo = newPos[dir] <
m_probLo[dir];
1151 const bool outsideHi = newPos[dir] >
m_probHi[dir];
1153 if (outsideLo || outsideHi) {
1159 if (checkEB || checkDomain) {
1162 Real sDomain = std::numeric_limits<Real>::max();
1163 Real sEB = std::numeric_limits<Real>::max();
1165 bool contactDomain =
false;
1166 bool contactEB =
false;
1177 if (contactDomain || contactEB) {
1178 if (sEB <= sDomain) {
1179 const RealVect intersectionPos = oldPos + sEB * path;
1184 if (a_deleteParticles) {
1189 a_nonDeletionModifier(active, i);
1194 RealVect intersectionPos = oldPos + sDomain * path;
1196 for (
int dir = 0; dir < SpaceDim; dir++) {
1197 intersectionPos[dir] = std::max(intersectionPos[dir],
m_probLo[dir] + safety *
m_dx[lvl]);
1198 intersectionPos[dir] = std::min(intersectionPos[dir],
m_probHi[dir] - safety *
m_dx[lvl]);
1204 if (a_deleteParticles) {
1209 a_nonDeletionModifier(active, i);
1226 a_ebParticles.
remap();
1227 a_domainParticles.
remap();
1230template <
typename P,
typename Traits>
1236 CH_TIME(
"AmrMesh::transferIrregularParticles(ParticleContainer)");
1238 pout() <<
"AmrMesh::transferIrregularParticles(ParticleContainer)" << endl;
1241 CH_assert(a_dstParticles.getRealm() == a_srcParticles.getRealm());
1243 const std::string realm = a_dstParticles.getRealm();
1246 const DisjointBoxLayout& dbl = this->
getGrids(realm)[lvl];
1247 const DataIterator& dit = dbl.dataIterator();
1248 const EBISLayout& ebisl = this->
getEBISLayout(realm, a_phase)[lvl];
1249 const Real dx =
m_dx[lvl];
1251 const int nbox = dit.size();
1252#pragma omp parallel for schedule(runtime)
1253 for (
int mybox = 0; mybox < nbox; mybox++) {
1254 const DataIndex& din = dit[mybox];
1255 const Box cellBox = dbl[din];
1256 const EBISBox& ebisbox = ebisl[din];
1263 while (i < src.
size()) {
1264 const RealVect pos = src.
position(i);
1269 if (cellBox.contains(iv) && ebisbox.isIrregular(iv)) {
1270 bool insideAnyVoF =
false;
1272 const Vector<VolIndex> allVoFs = ebisbox.getVoFs(iv);
1273 for (
int k = 0; k < allVoFs.size(); k++) {
1274 const RealVect normal = ebisbox.normal(allVoFs[k]);
1277 if ((pos - ebPos).dotProduct(normal) >= 0.0) {
1278 insideAnyVoF =
true;
1282 if (!insideAnyVoF) {
1283 const VolIndex& vof = allVoFs[0];
1302#include <CD_NamespaceFooter.H>
Declaration of core class for handling AMR-related operations (with embedded boundaries).
CoarseFineDeposition
Coarse-fine deposition types (see CD_EBAMRParticleMesh for how these are handled).
Definition CD_CoarseFineDeposition.H:28
CopyStrategy
Enum for distinguishing how we copy data Valid => valid region ValidGhost => valid+ghost region.
Definition CD_CopyStrategy.H:24
DepositionType
Deposition types.
Definition CD_DepositionType.H:24
IrregularDeposition
How a deposition scheme treats the cut cells.
Definition CD_IrregularDeposition.H:36
Declaration of a static class containing some common useful particle routines that would otherwise be...
void depositGathered(EBAMRCellData &a_meshData, const std::string &a_realm, const phase::which_phase &a_phase, const ParticleContainer< P, Traits > &a_particles, const DepositionType a_depositionType, const CoarseFineDeposition a_coarseFineDeposition, const IrregularDeposition a_irregularDeposition, CellGather a_cellGather)
Deposit a custom per-particle scalar (a_cellGather) of an SoA container on the mesh.
Definition CD_AmrMeshImplem.H:392
void allocatePointer(Vector< RefCountedPtr< T > > &a_data) const
Allocate pointer but not any memory blocks.
Definition CD_AmrMeshImplem.H:269
EBAMRSurfaceDeposition & getSurfaceDeposition(const std::string &a_realm, const phase::which_phase a_phase) const
Get EBAMRSurfaceDeposition surface deposition operator.
Definition CD_AmrMesh.cpp:3969
void transferCoveredParticlesIF(ParticleContainer< P, Traits > &a_particlesFrom, ParticleContainer< P, Traits > &a_particlesTo, const phase::which_phase &a_phase, const Real a_tolerance) const
Transfer SoA particles inside the EB (implicit-function test) from one container to another: f(x) > a...
Definition CD_AmrMeshImplem.H:674
void allocate(ParticleContainer< P, Traits > &a_container, const std::string &a_realm) const
Allocate a struct-of-arrays particle container on the given realm.
Definition CD_AmrMeshImplem.H:242
const Vector< RefCountedPtr< LevelTiles > > & getLevelTiles(const std::string &a_realm) const
Get the tiled space representation.
Definition CD_AmrMesh.cpp:3561
void depositWeight(EBAMRCellData &a_meshData, const std::string &a_realm, const phase::which_phase &a_phase, const ParticleContainer< P, Traits > &a_particles, const DepositionType a_depositionType, const CoarseFineDeposition a_coarseFineDeposition, const IrregularDeposition a_irregularDeposition)
Deposit the SoA container's weight column on the mesh (all coarse-fine strategies).
Definition CD_AmrMeshImplem.H:372
void copyData(EBAMRData< T > &a_dst, const EBAMRData< T > &a_src, const CopyStrategy &a_toRegion=CopyStrategy::Valid, const CopyStrategy &a_fromRegion=CopyStrategy::Valid) const noexcept
Method for copying from a source container to a destination container. User supplies information abou...
Definition CD_AmrMeshImplem.H:23
RealVect m_probHi
Domain simulation corner.
Definition CD_AmrMesh.H:2403
const AMRMask & getValidCells(const std::string &a_realm) const
Get a map of all valid cells on a specified realm.
Definition CD_AmrMesh.cpp:3545
void interpolateWeight(ParticleContainer< P, Traits > &a_particles, const std::string &a_realm, const phase::which_phase &a_phase, const EBAMRCellData &a_meshScalarField, const DepositionType a_interpType, const bool a_forceIrregNGP) const
Interpolate a mesh scalar field onto the SoA container's weight column.
Definition CD_AmrMeshImplem.H:442
RealVect m_probLo
Domain simulation corner.
Definition CD_AmrMesh.H:2398
void intersectParticlesBisectIF(ParticleContainer< P, Traits > &a_activeParticles, ParticleContainer< P, Traits > &a_ebParticles, ParticleContainer< P, Traits > &a_domainParticles, const phase::which_phase a_phase, const Real a_bisectionStep, const bool a_deleteParticles, const std::function< void(ParticleSoA< P, Traits > &, std::size_t)> &a_nonDeletionModifier) const noexcept
SoA bisection-based particle intersection algorithm.
Definition CD_AmrMeshImplem.H:1060
const Vector< DisjointBoxLayout > & getGrids(const std::string &a_realm) const
Get the grids.
Definition CD_AmrMesh.cpp:3393
int m_verbosity
Verbosity.
Definition CD_AmrMesh.H:2413
int m_minBlockSize
Blocking factor.
Definition CD_AmrMesh.H:2453
std::map< std::pair< std::string, std::string >, Vector< Copier > > m_validToValidRealmCopiers
Map for copying between various Realms. First index is the "from" realm and second index is the "to" ...
Definition CD_AmrMesh.H:2340
std::map< std::pair< std::string, std::string >, Vector< Copier > > m_validGhostToValidRealmCopiers
Map for copying between various Realms. First index is the "from" realm and second index is the "to" ...
Definition CD_AmrMesh.H:2352
int m_numGhostCells
Number of ghost cells.
Definition CD_AmrMesh.H:2473
std::map< std::pair< std::string, std::string >, Vector< Copier > > m_validGhostToValidGhostRealmCopiers
Map for copying between various Realms. First index is the "from" realm and second index is the "to" ...
Definition CD_AmrMesh.H:2358
void transferCoveredParticlesDiscrete(ParticleContainer< P, Traits > &a_particlesFrom, ParticleContainer< P, Traits > &a_particlesTo, const phase::which_phase &a_phase, const Real a_tolerance) const
Transfer SoA particles inside the EB using discrete (EBISBox) information from one container to anoth...
Definition CD_AmrMeshImplem.H:739
void removeCoveredParticlesVoxels(ParticleContainer< P, Traits > &a_particles, const phase::which_phase &a_phase) const
Remove SoA particles that live in covered cells (voxel test).
Definition CD_AmrMeshImplem.H:619
Vector< Real > m_dx
Level resolutions.
Definition CD_AmrMesh.H:2569
void transferIrregularParticles(ParticleContainer< P, Traits > &a_dstParticles, ParticleContainer< P, Traits > &a_srcParticles, const phase::which_phase a_phase) const noexcept
Transfer SoA particles that are on the covered side of the EB to a different container.
Definition CD_AmrMeshImplem.H:1232
int m_finestLevel
Finest level.
Definition CD_AmrMesh.H:2418
void removeCoveredParticlesIF(ParticleContainer< P, Traits > &a_particles, const phase::which_phase &a_phase, const Real a_tolerance) const
Remove SoA particles that fall inside the EB (implicit-function test): f(x) > a_tolerance*dx.
Definition CD_AmrMeshImplem.H:480
std::map< phase::which_phase, RefCountedPtr< BaseIF > > m_baseif
Implicit functions.
Definition CD_AmrMesh.H:2317
bool queryRealm(const std::string &a_realm) const
Query if a realm exists.
Definition CD_AmrMesh.cpp:4184
void intersectParticlesRaycastIF(ParticleContainer< P, Traits > &a_activeParticles, ParticleContainer< P, Traits > &a_ebParticles, ParticleContainer< P, Traits > &a_domainParticles, const phase::which_phase a_phase, const Real a_tolerance, const bool a_deleteParticles, const std::function< void(ParticleSoA< P, Traits > &, std::size_t)> &a_nonDeletionModifier) const noexcept
SoA ray-casting particle intersection algorithm.
Definition CD_AmrMeshImplem.H:886
std::map< std::pair< std::string, std::string >, Vector< Copier > > m_validToValidGhostRealmCopiers
Map for copying between various Realms. First index is the "from" realm and second index is the "to" ...
Definition CD_AmrMesh.H:2346
const Vector< Real > & getDx() const
Get spatial resolutions.
Definition CD_AmrMesh.cpp:3337
EBAMRParticleMesh & getParticleMesh(const std::string &a_realm, const phase::which_phase a_phase) const
Get EBAMRParticleMesh operator.
Definition CD_AmrMesh.cpp:3952
const Vector< EBISLayout > & getEBISLayout(const std::string &a_realm, const phase::which_phase a_phase) const
Get EBISLayouts for a Realm and phase.
Definition CD_AmrMesh.cpp:3409
std::map< std::string, RefCountedPtr< Realm > > m_realms
These are all the Realms.
Definition CD_AmrMesh.H:2312
void interpolateParticles(ParticleContainer< P, Traits > &a_particles, const std::string &a_realm, const phase::which_phase &a_phase, const EBAMRCellData &a_meshField, const DepositionType a_interpType, const bool a_forceIrregNGP) const
Interpolate a mesh field onto one or more SoA payload columns.
Definition CD_AmrMeshImplem.H:461
void depositParticles(EBAMRIVData &a_meshData, const std::string &a_realm, const phase::which_phase &a_phase, const ParticleContainer< P, Traits > &a_particles) const noexcept
Deposit the weight column of an SoA particle container onto the surface (EB).
Definition CD_AmrMeshImplem.H:352
void remapToNewGrids(ParticleContainer< P, Traits > &a_particles, const int a_lmin, const int a_newFinestLevel) const noexcept
Regrid a struct-of-arrays particle container to new grids.
Definition CD_AmrMeshImplem.H:328
void alias(Vector< T * > &a_alias, const Vector< RefCountedPtr< T > > &a_data) const
Turn smart-pointer data structure into regular-pointer data structure.
Definition CD_AmrMeshImplem.H:214
void deallocate(Vector< T * > &a_data) const
Deallocate data.
Definition CD_AmrMeshImplem.H:166
void transferCoveredParticlesVoxels(ParticleContainer< P, Traits > &a_particlesFrom, ParticleContainer< P, Traits > &a_particlesTo, const phase::which_phase &a_phase) const
Transfer SoA particles that live in covered cells (voxel test) from one container to another.
Definition CD_AmrMeshImplem.H:826
const Vector< int > & getRefinementRatios() const
Get refinement ratios.
Definition CD_AmrMesh.cpp:3348
void removeCoveredParticlesDiscrete(ParticleContainer< P, Traits > &a_particles, const phase::which_phase &a_phase, const Real a_tolerance) const
Remove SoA particles inside the EB using discrete (EBISBox) information: covered cells,...
Definition CD_AmrMeshImplem.H:539
const Vector< ProblemDomain > & getDomains() const
Get domains.
Definition CD_AmrMesh.cpp:3371
Default class for holding LevelData<T> data across an EBAMR realm.
Definition CD_EBAMRData.H:41
Vector< RefCountedPtr< LevelData< T > > > & getData() noexcept
Get underlying data. Returns m_data.
Definition CD_EBAMRDataImplem.H:154
void setRealm(const std::string &a_realm) noexcept
Sets the realm for this object.
Definition CD_EBAMRDataImplem.H:182
AMR driver that deposits/interpolates ParticleContainer particles across the hierarchy.
Definition CD_EBAMRParticleMesh.H:95
void interpolateWeight(ParticleContainer< P, Traits > &a_particles, const EBAMRCellData &a_meshData, const DepositionType a_interpType, const bool a_forceIrregNGP) const
Interpolate a mesh field onto the container-owned weight column, across all levels.
Definition CD_EBAMRParticleMesh.H:225
void depositWeight(EBAMRCellData &a_meshData, const ParticleContainer< P, Traits > &a_particles, const DepositionType a_depositionType, const CoarseFineDeposition a_coarseFineDeposition, const IrregularDeposition a_irregularDeposition)
Deposit the container-owned weight onto the AMR mesh.
Definition CD_EBAMRParticleMesh.H:272
void depositGathered(EBAMRCellData &a_meshData, const ParticleContainer< P, Traits > &a_particles, const DepositionType a_depositionType, const CoarseFineDeposition a_coarseFineDeposition, const IrregularDeposition a_irregularDeposition, CellGather a_cellGather)
Deposit a custom per-particle scalar (computed by a_cellGather) onto the AMR mesh.
Definition CD_EBAMRParticleMesh.H:342
class for handling surface deposition of particles with EB and AMR.
Definition CD_EBAMRSurfaceDeposition.H:30
void deposit(EBAMRIVData &a_meshData, const ParticleContainer< P, Traits > &a_particles) const noexcept
Deposit the container-owned weight column of an SoA particle container onto the surface.
Definition CD_EBAMRSurfaceDepositionImplem.H:32
AMR-hierarchy container of computational particles, stored per patch in Struct-of-Arrays form.
Definition CD_ParticleContainer.H:123
void clearParticles()
Drop all valid particles on every level (keeps each leaf's arena capacity).
Definition CD_ParticleContainer.H:447
void define(const Vector< DisjointBoxLayout > &a_grids, const Vector< ProblemDomain > &a_domains, const Vector< Real > &a_dx, const Vector< int > &a_refRat, const RealVect &a_probLo, const int a_minBlockSize, const Vector< RefCountedPtr< LevelTiles > > &a_levelTiles, const int a_finestLevel, const std::string &a_realm, const Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > *a_validCells)
Allocate the per-level holders and the per-level tile-ownership maps over the AMR grids.
Definition CD_ParticleContainer.H:194
std::string getRealm() const
Realm label.
Definition CD_ParticleContainer.H:305
void remap()
Redistribute every valid particle to the patch/level/rank that owns its cell.
Definition CD_ParticleContainerImplem.H:502
static bool ebIntersectionRaycast(const RefCountedPtr< BaseIF > &a_impFunc, const RealVect &a_oldPos, const RealVect &a_newPos, const Real &a_tolerance, Real &a_s)
Compute the intersection point between a particle path and an implicit function using a ray-casting a...
Definition CD_ParticleOpsImplem.H:224
static bool ebIntersectionBisect(const RefCountedPtr< BaseIF > &a_impFunc, const RealVect &a_oldPos, const RealVect &a_newPos, const Real &a_bisectStep, Real &a_s)
Compute the intersection point between a particle path and an implicit function using a bisection alg...
Definition CD_ParticleOpsImplem.H:175
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:32
static bool domainIntersection(const RealVect &a_oldPos, const RealVect &a_newPos, const RealVect &a_probLo, const RealVect &a_probHi, Real &a_s)
Compute the intersection point between a particle path and a domain side.
Definition CD_ParticleOpsImplem.H:126
Arena-backed Struct-of-Arrays particle container for a single grid patch.
Definition CD_ParticleSoA.H:655
RealVect position(const std::size_t a_index) const noexcept
Position of particle i as a RealVect (by value, assembled from the scalar columns).
Definition CD_ParticleSoA.H:1195
std::size_t size() const noexcept
Number of particles currently stored.
Definition CD_ParticleSoA.H:882
void setPosition(const std::size_t a_index, const RealVect &a_position) noexcept
Set the position of particle i.
Definition CD_ParticleSoA.H:1213
void catenate(ParticleSoA &a_other)
Move every particle of another container into this one, leaving a_other empty (catenate).
Definition CD_ParticleSoA.H:1009
void remove(const std::size_t a_index) noexcept
Remove particle i using swap-and-pop (O(1), does NOT preserve order).
Definition CD_ParticleSoA.H:1040
void clear() noexcept
Drop all particles (keeps the arena; invalidates the cell sort unless there was nothing to drop).
Definition CD_ParticleSoA.H:915
void appendParticle(const ParticleSoA &a_src, const std::size_t a_index)
Append a single particle (all columns, incl. id/rank) copied from another container.
Definition CD_ParticleSoAImplem.H:172
RealVect position(Location::Cell a_location, const VolIndex &a_vof, const EBISBox &a_ebisbox, const Real &a_dx)
Compute the position (ignoring the "origin) of a Vof.
Definition CD_LocationImplem.H:21
which_phase
Enumeration of supported phases.
Definition CD_MultiFluidIndexSpace.H:38
@ solid
Solid (dielectric) phase.
Definition CD_MultiFluidIndexSpace.H:40
@ gas
Gas phase.
Definition CD_MultiFluidIndexSpace.H:39