chombo-discharge
CD_ItoKMCStreamerTaggerImplem.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2021 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_ItoKMCStreamerTaggerImplem_H
13 #define CD_ItoKMCStreamerTaggerImplem_H
14 
15 // Chombo includes
16 #include <ParmParse.H>
17 
18 // Our includes
20 #include <CD_NamespaceHeader.H>
21 
22 using namespace Physics::ItoKMC;
23 
24 template <typename S>
26 {
27  CH_TIME("ItoKMCStreamerTagger::ItoKMCStreamerTagger");
28 
29  this->m_name = "ItoKMCStreamerTagger";
30  this->m_numTagFields = 2;
31 }
32 
33 template <typename S>
35 {}
36 
37 template <typename S>
38 ItoKMCStreamerTagger<S>::ItoKMCStreamerTagger(const RefCountedPtr<ItoKMCPhysics>& a_physics,
39  const RefCountedPtr<S>& a_timeStepper,
40  const RefCountedPtr<AmrMesh>& a_amr) noexcept
42 {
43  CH_TIME("ItoKMCStreamerTagger::ItoKMCStreamerTagger");
44  if (this->m_verbosity > 5) {
45  pout() << "ItoKMCStreamerTagger::ItoKMCStreamerTagger" << endl;
46  }
47 
48  this->define(a_physics, a_timeStepper, a_amr);
49 }
50 
51 template <typename S>
52 void
54 {
55  CH_TIME("ItoKMCStreamerTagger::parseOptions");
56  if (this->m_verbosity > 5) {
57  pout() << "ItoKMCStreamerTagger::parseOptions" << endl;
58  }
59 
60  this->parseVerbosity();
61  this->parseTagBoxes();
62  this->parseRefinementBoxes();
63  this->parseBuffer();
64 
65  ParmParse pp(this->m_name.c_str());
66  pp.get("coarsen_curvature", this->m_coarsenCurvature);
67  pp.get("refine_curvature", this->m_refineCurvature);
68  pp.get("refine_alpha", this->m_refineAlpha);
69  pp.get("coarsen_alpha", this->m_coarsenAlpha);
70  pp.get("max_coarsen_lvl", this->m_maxCoarsenLevel);
71 }
72 
73 template <typename S>
74 void
76 {
77  CH_TIME("ItoKMCStreamerTagger::parseOptions");
78  if (this->m_verbosity > 5) {
79  pout() << "ItoKMCStreamerTagger::parseOptions" << endl;
80  }
81 
82  this->parseVerbosity();
83  this->parseTagBoxes();
84  this->parseRefinementBoxes();
85  this->parseBuffer();
86 
87  ParmParse pp(this->m_name.c_str());
88  pp.get("coarsen_curvature", this->m_coarsenCurvature);
89  pp.get("refine_curvature", this->m_refineCurvature);
90  pp.get("refine_alpha", this->m_refineAlpha);
91  pp.get("coarsen_alpha", this->m_coarsenAlpha);
92  pp.get("max_coarsen_lvl", this->m_maxCoarsenLevel);
93 }
94 
95 template <typename S>
96 Vector<Real>
98  const Real a_time,
99  const Real a_dx,
100  const RealVect a_E,
101  const Real a_minE,
102  const Real a_maxE,
103  const RealVect a_gradE,
104  const Real a_minGradE,
105  const Real a_maxGradE) const noexcept
106 {
107  CH_TIME("ItoKMCStreamerTagger::computeTagFields");
108  if (this->m_verbosity > 5) {
109  pout() << "ItoKMCStreamerTagger::computeTagFields" << endl;
110  }
111 
112  Vector<Real> tagFields(this->m_numTagFields);
113 
114  const Real E = a_E.vectorLength();
115  tagFields[0] = E / a_maxE;
116  tagFields[1] = this->m_physics->computeAlpha(E, a_pos) * a_dx;
117  tagFields[1] -= this->m_physics->computeEta(E, a_pos) * a_dx;
118 
119  return tagFields;
120 }
121 
122 template <typename S>
123 bool
125  const Real a_time,
126  const Real a_dx,
127  const int a_lvl,
128  const Vector<Real> a_tagFields,
129  const Vector<RealVect> a_gradTagFields) const noexcept
130 {
131  CH_TIME("ItoKMCStreamerTagger::coarsenCell");
132  if (this->m_verbosity > 5) {
133  pout() << "ItoKMCStreamerTagger::coarsenCell" << endl;
134  }
135 
136  bool coarsen = false;
137 
138  if (a_lvl >= m_maxCoarsenLevel) {
139  const Real E = a_tagFields[0];
140  const Real alphaDx = a_tagFields[1];
141  const RealVect gradE = a_gradTagFields[0];
142 
143  const bool coarsenCurv = gradE.vectorLength() * a_dx / E < m_coarsenCurvature;
144  const bool coarsenAlpha = alphaDx < m_coarsenAlpha;
145 
146  coarsen = coarsenCurv && coarsenAlpha;
147  }
148  else {
149  coarsen = false;
150  }
151 
152  return coarsen;
153 }
154 
155 template <typename S>
156 bool
158  const Real a_time,
159  const Real a_dx,
160  const int a_lvl,
161  const Vector<Real> a_tagFields,
162  const Vector<RealVect> a_gradTagFields) const noexcept
163 {
164  CH_TIME("ItoKMCStreamerTagger::refineCell");
165  if (this->m_verbosity > 5) {
166  pout() << "ItoKMCStreamerTagger::refineCell" << endl;
167  }
168 
169  const Real E = a_tagFields[0];
170  const Real alphaDx = a_tagFields[1];
171  const RealVect gradE = a_gradTagFields[0];
172 
173  const bool refineCurv = gradE.vectorLength() * a_dx / E > m_refineCurvature;
174  const bool refineAlpha = alphaDx > m_refineAlpha;
175  const bool refineManual = (a_lvl < this->getManualRefinementLevel(a_pos));
176 
177  return refineCurv || refineAlpha || refineManual;
178 }
179 
180 #include <CD_NamespaceFooter.H>
181 
182 #endif
Implementation ItoKMCTagger which tags on alpha and curvature of field.
virtual void computeTagFields() const noexcept override
Compute tagging fields.
Definition: CD_ItoKMCFieldTaggerImplem.H:95
Cell tagging class for streamers.
Definition: CD_ItoKMCStreamerTagger.H:27
virtual bool refineCell(const RealVect a_pos, const Real a_time, const Real a_dx, const int a_lvl, const Vector< Real > a_tagFields, const Vector< RealVect > a_gradTagFields) const noexcept override
Determine if a particular cell should be refined or not.
Definition: CD_ItoKMCStreamerTaggerImplem.H:157
ItoKMCStreamerTagger() noexcept
Constructor. Must subsequently call the define function.
Definition: CD_ItoKMCStreamerTaggerImplem.H:25
virtual bool coarsenCell(const RealVect a_pos, const Real a_time, const Real a_dx, const int a_lvl, const Vector< Real > a_tagFields, const Vector< RealVect > a_gradTagFields) const noexcept override
Determine if a particular cell should be coarsened or not.
Definition: CD_ItoKMCStreamerTaggerImplem.H:124
virtual void parseRuntimeOptions() noexcept override
Parse class options.
Definition: CD_ItoKMCStreamerTaggerImplem.H:75
virtual ~ItoKMCStreamerTagger() noexcept
Destructor.
Definition: CD_ItoKMCStreamerTaggerImplem.H:34
virtual void parseOptions() noexcept override
Parse class options.
Definition: CD_ItoKMCStreamerTaggerImplem.H:53