chombo-discharge
Loading...
Searching...
No Matches
CD_ItoKMCStreamerTaggerImplem.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_ITOKMCSTREAMERTAGGERIMPLEM_H
14#define CD_ITOKMCSTREAMERTAGGERIMPLEM_H
15
16// Chombo includes
17#include <ParmParse.H>
18
19// Our includes
21#include <CD_NamespaceHeader.H>
22
23using namespace Physics::ItoKMC;
24
25template <typename S>
27{
28 CH_TIME("ItoKMCStreamerTagger::ItoKMCStreamerTagger");
29
30 this->m_name = "ItoKMCStreamerTagger";
31 this->m_numTagFields = 2;
32}
33
34template <typename S>
37
38template <typename S>
43{
44 CH_TIME("ItoKMCStreamerTagger::ItoKMCStreamerTagger");
45 if (this->m_verbosity > 5) {
46 pout() << "ItoKMCStreamerTagger::ItoKMCStreamerTagger" << endl;
47 }
48
49 this->define(a_physics, a_timeStepper, a_amr);
50}
51
52template <typename S>
53void
55{
56 CH_TIME("ItoKMCStreamerTagger::parseOptions");
57 if (this->m_verbosity > 5) {
58 pout() << "ItoKMCStreamerTagger::parseOptions" << endl;
59 }
60
61 this->parseVerbosity();
62 this->parseTagBoxes();
63 this->parseRefinementBoxes();
64 this->parseBuffer();
65
66 ParmParse pp(this->m_name.c_str());
67 pp.get("coarsen_curvature", this->m_coarsenCurvature);
68 pp.get("refine_curvature", this->m_refineCurvature);
69 pp.get("refine_alpha", this->m_refineAlpha);
70 pp.get("coarsen_alpha", this->m_coarsenAlpha);
71 pp.get("max_coarsen_lvl", this->m_maxCoarsenLevel);
72}
73
74template <typename S>
75void
77{
78 CH_TIME("ItoKMCStreamerTagger::parseRuntimeOptions");
79 if (this->m_verbosity > 5) {
80 pout() << "ItoKMCStreamerTagger::parseRuntimeOptions" << endl;
81 }
82
83 this->parseVerbosity();
84 this->parseTagBoxes();
85 this->parseRefinementBoxes();
86 this->parseBuffer();
87
88 ParmParse pp(this->m_name.c_str());
89 pp.get("coarsen_curvature", this->m_coarsenCurvature);
90 pp.get("refine_curvature", this->m_refineCurvature);
91 pp.get("refine_alpha", this->m_refineAlpha);
92 pp.get("coarsen_alpha", this->m_coarsenAlpha);
93 pp.get("max_coarsen_lvl", this->m_maxCoarsenLevel);
94}
95
96template <typename S>
99 const Real a_time,
100 const Real a_dx,
101 const RealVect& a_E,
102 const Real a_minE,
103 const Real a_maxE,
104 const RealVect& a_gradE,
105 const Real a_minGradE,
106 const Real a_maxGradE) const noexcept
107{
108 CH_TIME("ItoKMCStreamerTagger::computeTagFields");
109 if (this->m_verbosity > 5) {
110 pout() << "ItoKMCStreamerTagger::computeTagFields" << endl;
111 }
112
113 Vector<Real> tagFields(this->m_numTagFields);
114
115 const Real E = a_E.vectorLength();
116 tagFields[0] = E / a_maxE;
117 tagFields[1] = this->m_physics->computeAlpha(E, a_pos) * a_dx;
118 tagFields[1] -= this->m_physics->computeEta(E, a_pos) * a_dx;
119
120 return tagFields;
121}
122
123template <typename S>
124bool
126 const Real a_time,
127 const Real a_dx,
128 const int a_lvl,
130 const Vector<RealVect>& a_gradTagFields) const noexcept
131{
132 CH_TIME("ItoKMCStreamerTagger::coarsenCell");
133 if (this->m_verbosity > 5) {
134 pout() << "ItoKMCStreamerTagger::coarsenCell" << endl;
135 }
136
137 bool coarsen = false;
138
139 if (a_lvl >= m_maxCoarsenLevel) {
140 const Real E = a_tagFields[0];
141 const Real alphaDx = a_tagFields[1];
142 const RealVect gradE = a_gradTagFields[0];
143
144 const bool coarsenCurv = gradE.vectorLength() * a_dx / E < m_coarsenCurvature;
145 const bool coarsenAlpha = alphaDx < m_coarsenAlpha;
146
148 }
149 else {
150 coarsen = false;
151 }
152
153 return coarsen;
154}
155
156template <typename S>
157bool
159 const Real a_time,
160 const Real a_dx,
161 const int a_lvl,
163 const Vector<RealVect>& a_gradTagFields) const noexcept
164{
165 CH_TIME("ItoKMCStreamerTagger::refineCell");
166 if (this->m_verbosity > 5) {
167 pout() << "ItoKMCStreamerTagger::refineCell" << endl;
168 }
169
170 const Real E = a_tagFields[0];
171 const Real alphaDx = a_tagFields[1];
172 const RealVect gradE = a_gradTagFields[0];
173
174 const bool refineCurv = gradE.vectorLength() * a_dx / E > m_refineCurvature;
175 const bool refineAlpha = alphaDx > m_refineAlpha;
176 const bool refineManual = (a_lvl < this->getManualRefinementLevel(a_pos));
177
179}
180
181#include <CD_NamespaceFooter.H>
182
183#endif
Declaration of the Physics::ItoKMC::ItoKMCStreamerTagger CellTagger.
ItoKMCStreamerTagger() noexcept
Constructor. Must subsequently call the define function.
Definition CD_ItoKMCStreamerTaggerImplem.H:26
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.
Definition CD_ItoKMCStreamerTaggerImplem.H:158
virtual void parseRuntimeOptions() noexcept override
Parse runtime-configurable class options.
Definition CD_ItoKMCStreamerTaggerImplem.H:76
virtual Vector< Real > computeTagFields(const RealVect &a_pos, const Real a_time, const Real a_dx, const RealVect &a_E, const Real a_minE, const Real a_maxE, const RealVect &a_gradE, const Real a_minGradE, const Real a_maxGradE) const noexcept override
Compute per-cell tagging fields from the electric field and its gradient.
Definition CD_ItoKMCStreamerTaggerImplem.H:98
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.
Definition CD_ItoKMCStreamerTaggerImplem.H:125
virtual ~ItoKMCStreamerTagger() noexcept
Destructor.
Definition CD_ItoKMCStreamerTaggerImplem.H:35
virtual void parseOptions() noexcept override
Parse class options.
Definition CD_ItoKMCStreamerTaggerImplem.H:54
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:26
void parseVerbosity()
Parse solver verbosity.
Definition CD_TracerParticleSolverImplem.H:163
int m_verbosity
Verbosity level.
Definition CD_TracerParticleSolver.H:387
std::string m_name
Solver name.
Definition CD_TracerParticleSolver.H:357