13#ifndef CD_ITOKMCFIELDTAGGERIMPLEM_H
14#define CD_ITOKMCFIELDTAGGERIMPLEM_H
20#include <CD_NamespaceHeader.H>
22using namespace Physics::ItoKMC;
27 CH_TIME(
"ItoKMCFieldTagger::ItoKMCFieldTagger");
29 pout() <<
"ItoKMCFieldTagger::ItoKMCFieldTagger" << endl;
32 this->
m_name =
"ItoKMCFieldTagger";
43 CH_TIME(
"ItoKMCFieldTagger::allocateStorage");
45 pout() << this->
m_name +
"::allocateStorage" << endl;
59 CH_TIME(
"ItoKMCFieldTagger::deallocateStorage");
61 pout() << this->
m_name +
"::deallocateStorage" << endl;
73 CH_TIME(
"ItoKMCFieldTagger::computeElectricField");
75 pout() << this->
m_name +
"::computeElectricField" << endl;
79 CH_assert(a_E[0]->nComp() == SpaceDim);
80 CH_assert(a_gradE[0]->nComp() == SpaceDim);
85 this->
m_amr->getNotCoveredCells(this->m_realm, this->m_phase),
86 this->m_amr->getMultiCutVofIterator(this->m_realm, this->m_phase));
101 CH_TIME(
"ItoKMCFieldTagger::computeTagFields");
103 pout() << this->
m_name +
"::computeTagFields" << endl;
111 const RealVect probLo = this->
m_amr->getProbLo();
115 Real maxGradE, minGradE;
121 this->
m_amr->getMultiCutVofIterator(this->m_realm, this->m_phase));
123 for (
int lvl = 0; lvl <= this->
m_amr->getFinestLevel(); lvl++) {
124 const DisjointBoxLayout& dbl = this->
m_amr->getGrids(this->
m_realm)[lvl];
125 const DataIterator& dit = dbl.dataIterator();
127 const Real dx = this->
m_amr->getDx()[lvl];
129 const int nbox = dit.size();
131#pragma omp parallel for schedule(runtime)
132 for (
int mybox = 0; mybox < nbox; mybox++) {
133 const DataIndex& din = dit[mybox];
135 const Box& box = dbl[din];
136 const EBISBox& ebisbox = ebisl[din];
138 const EBCellFAB& electricField = (*
m_E[lvl])[din];
139 const EBCellFAB& gradElectricField = (*
m_gradE[lvl])[din];
141 const FArrayBox& electricFieldReg = electricField.getFArrayBox();
142 const FArrayBox& gradElectricFieldReg = gradElectricField.getFArrayBox();
144 Vector<EBCellFAB*> tagFields;
145 Vector<FArrayBox*> tagFieldsReg;
147 tagFields.push_back(&((*this->
m_tagFields[i][lvl])[din]));
148 tagFieldsReg.push_back(&(tagFields[i]->getFArrayBox()));
151 auto regularKernel = [&](
const IntVect& iv) ->
void {
152 if (ebisbox.isRegular(iv)) {
153 const RealVect pos = probLo + RealVect(iv) * dx;
155 const RealVect E = RealVect(
156 D_DECL(electricFieldReg(iv, 0), electricFieldReg(iv, 1), electricFieldReg(iv, 2)));
157 const RealVect gradE = RealVect(
158 D_DECL(gradElectricFieldReg(iv, 0), gradElectricFieldReg(iv, 1), gradElectricFieldReg(iv, 2)));
161 compTagFields = this->
computeTagFields(pos, time, dx, E, minE, maxE, gradE, minGradE, maxGradE);
163 for (
int i = 0; i < this->m_numTagFields; i++) {
164 (*tagFieldsReg[i])(iv, 0) = compTagFields[i];
170 auto irregularKernel = [&](
const VolIndex& vof) ->
void {
171 const RealVect pos = probLo +
Location::position(Location::Cell::Center, vof, ebisbox, dx);
173 const RealVect E = RealVect(D_DECL(electricField(vof, 0), electricField(vof, 1), electricField(vof, 2)));
174 const RealVect gradE = RealVect(
175 D_DECL(gradElectricField(vof, 0), gradElectricField(vof, 1), gradElectricField(vof, 2)));
178 compTagFields = this->
computeTagFields(pos, time, dx, E, minE, maxE, gradE, minGradE, maxGradE);
180 for (
int i = 0; i < this->m_numTagFields; i++) {
181 (*tagFields[i])(vof, 0) = compTagFields[i];
187 VoFIterator& vofit = (*this->
m_amr->getVofIterator(this->
m_realm, this->
m_phase)[lvl])[din];
198 for (
int i = 0; i < this->m_numTagFields; i++) {
207#include <CD_NamespaceFooter.H>
Agglomeration of useful data operations.
Declaration of the Physics::ItoKMC::ItoKMCFieldTagger abstract CellTagger.
Declaration of cell positions.
int m_verbosity
Class verbosity.
Definition CD_CellTagger.H:138
std::string m_name
Cell tagger class name (default is CellTagger).
Definition CD_CellTagger.H:133
static void getMaxMinNorm(Real &a_max, Real &a_min, EBAMRCellData &data, const Vector< RefCountedPtr< LayoutData< VoFIterator > > > &a_vofIter)
Get maximum and minimum value of normed data.
Definition CD_DataOps.cpp:1940
static void vectorLength(EBAMRCellData &a_lhs, const EBAMRCellData &a_rhs, const EBAMRCellData &a_notCovered, const Vector< RefCountedPtr< LayoutData< VoFIterator > > > &a_vofIter)
Compute the vector length of a data holder. Sets a_lhs = |a_rhs| where a_rhs contains SpaceDim compon...
Definition CD_DataOps.cpp:3561
EBAMRCellData m_gradE
Storage for grad(|E|).
Definition CD_ItoKMCFieldTagger.H:75
ItoKMCFieldTagger() noexcept
Weak constructor. User MUST subsequently call define.
Definition CD_ItoKMCFieldTaggerImplem.H:25
virtual void computeElectricField(EBAMRCellData &a_E, EBAMRCellData &a_gradE) const noexcept
Compute the electric field and its gradient magnitude.
Definition CD_ItoKMCFieldTaggerImplem.H:71
EBAMRCellData m_E
Storage for the electric field E.
Definition CD_ItoKMCFieldTagger.H:70
EBAMRCellData m_scratch
Scratch storage.
Definition CD_ItoKMCFieldTagger.H:65
virtual void allocateStorage() const noexcept
Allocate memory for scratch, electric field, and gradient of electric field.
Definition CD_ItoKMCFieldTaggerImplem.H:41
virtual ~ItoKMCFieldTagger() noexcept
Destructor.
Definition CD_ItoKMCFieldTaggerImplem.H:36
virtual void computeTagFields() const noexcept override
Compute tagging fields.
Definition CD_ItoKMCFieldTaggerImplem.H:99
virtual void deallocateStorage() const noexcept
Deallocate memory.
Definition CD_ItoKMCFieldTaggerImplem.H:57
RefCountedPtr< S > m_timeStepper
Time stepper.
Definition CD_ItoKMCTagger.H:168
bool m_isDefined
Defined or not.
Definition CD_ItoKMCTagger.H:143
Vector< EBAMRCellData > m_tagFields
Tagging fields.
Definition CD_ItoKMCTagger.H:183
int m_numTagFields
Number of tagging fields.
Definition CD_ItoKMCTagger.H:178
RefCountedPtr< AmrMesh > m_amr
AmrMesh. Needed for allocating memory and things like that.
Definition CD_ItoKMCTagger.H:173
phase::which_phase m_phase
Phase where data is allocated.
Definition CD_ItoKMCTagger.H:158
std::string m_realm
Realm where data is allocated.
Definition CD_ItoKMCTagger.H:153
Vector< EBAMRCellData > m_gradTagFields
Gradient of tagging fields.
Definition CD_ItoKMCTagger.H:188
ALWAYS_INLINE void loop(const Box &a_computeBox, Functor &&kernel)
Launch a C++ kernel over a regular grid with compile-time per-dimension strides.
Definition CD_BoxLoopsImplem.H:39
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