chombo-discharge
CD_MeshODESolverImplem.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2022 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_MeshODESolverImplem_H
13 #define CD_MeshODESolverImplem_H
14 
15 // Chombo includes
16 #include <CH_Timer.H>
17 #include <ParmParse.H>
18 
19 // Our includes
20 #include <CD_MeshODESolver.H>
21 #include <CD_DischargeIO.H>
22 #include <CD_BoxLoops.H>
23 #include <CD_Location.H>
24 #include <CD_NamespaceHeader.H>
25 
26 template <size_t N>
28 {
29  CH_TIME("MeshODESolver::MeshODESolver()");
30 
31  // Default settings.
32  m_verbosity = -1;
33  m_name = "MeshODESolver";
34  m_className = "MeshODESolver";
35  m_phase = phase::gas;
36  m_realm = Realm::Primal;
37 
38  this->parseOptions();
39 }
40 
41 template <size_t N>
42 MeshODESolver<N>::MeshODESolver(const RefCountedPtr<AmrMesh>& a_amr) noexcept : MeshODESolver<N>()
43 {
44  CH_TIME("MeshODESolver::MeshODESolver(AMR)");
45 
46  m_amr = a_amr;
47 }
48 
49 template <size_t N>
51 {
52  CH_TIME("MeshODESolver::~MeshODESolver");
53 }
54 
55 template <size_t N>
56 void
57 MeshODESolver<N>::setAmr(const RefCountedPtr<AmrMesh>& a_amrMesh) noexcept
58 {
59  CH_TIME("MeshODESolver::setAmr");
60  if (m_verbosity > 5) {
61  pout() << m_name + "::setAmr" << endl;
62  }
63 
64  m_amr = a_amrMesh;
65 }
66 
67 template <size_t N>
68 void
70 {
71  CH_TIME("MeshODESolver::parseOptions");
72 
73  ParmParse pp(m_className.c_str());
74 
75  pp.get("verbosity", m_verbosity);
76  pp.get("use_regrid_slopes", m_regridSlopes);
77 
78  this->parsePlotVariables();
79 
80  if (m_verbosity > 5) {
81  pout() << m_name + "::parseOptions()" << endl;
82  }
83 }
84 
85 template <size_t N>
86 void
88 {
89  CH_TIME("MeshODESolver::parseRuntimeOptions()");
90  if (m_verbosity > 5) {
91  pout() << m_name + "::parseRuntimeOptions()" << endl;
92  }
93 
94  ParmParse pp(m_className.c_str());
95 
96  pp.get("verbosity", m_verbosity);
97  pp.get("use_regrid_slopes", m_regridSlopes);
98 
99  this->parsePlotVariables();
100 }
101 
102 template <size_t N>
103 void
105 {
106  CH_TIME("MeshODESolver::parsePlotVariables()");
107  if (m_verbosity > 5) {
108  pout() << m_name + "::parsePlotVariables()" << endl;
109  }
110 
111  m_plotPhi = false;
112  m_plotRHS = false;
113 
114  ParmParse pp(m_className.c_str());
115  const int num = pp.countval("plt_vars");
116 
117  if (num > 0) {
118  Vector<std::string> str(num);
119  pp.getarr("plt_vars", str, 0, num);
120 
121  for (int i = 0; i < num; i++) {
122  if (str[i] == "phi") {
123  m_plotPhi = true;
124  }
125  else if (str[i] == "rhs") {
126  m_plotRHS = true;
127  }
128  }
129  }
130 }
131 
132 template <size_t N>
135 {
136  CH_TIME("MeshODESolver::getPhi()");
137  if (m_verbosity > 5) {
138  pout() << m_name + "::getPhi()" << endl;
139  }
140 
141  return m_phi;
142 }
143 
144 template <size_t N>
145 const EBAMRCellData&
146 MeshODESolver<N>::getPhi() const noexcept
147 {
148  CH_TIME("MeshODESolver::getPhi()");
149  if (m_verbosity > 5) {
150  pout() << m_name + "::getPhi()" << endl;
151  }
152 
153  return m_phi;
154 }
155 
156 template <size_t N>
159 {
160  CH_TIME("MeshODESolver::getRHS()");
161  if (m_verbosity > 5) {
162  pout() << m_name + "::getRHS()" << endl;
163  }
164 
165  return m_rhs;
166 }
167 
168 template <size_t N>
169 const EBAMRCellData&
170 MeshODESolver<N>::getRHS() const noexcept
171 {
172  CH_TIME("MeshODESolver::getRHS()");
173  if (m_verbosity > 5) {
174  pout() << m_name + "::getRHS()" << endl;
175  }
176 
177  return m_rhs;
178 }
179 
180 template <size_t N>
181 void
182 MeshODESolver<N>::setPhi(const std::function<Real(const RealVect& a_pos)>& a_phiFunc, const size_t a_comp) noexcept
183 {
184  CH_TIME("MeshODESolver::setPhi(std::function, size_t)");
185  if (m_verbosity > 5) {
186  pout() << m_name + "::setPhi(std::function, size_t)" << endl;
187  }
188 
189  DataOps::setValue(m_phi, a_phiFunc, m_amr->getProbLo(), m_amr->getDx(), a_comp);
190 }
191 
192 template <size_t N>
193 void
194 MeshODESolver<N>::setPhi(const std::function<std::array<Real, N>(const RealVect& a_pos)>& a_phiFunc) noexcept
195 {
196  CH_TIME("MeshODESolver::setPhi(std::function)");
197  if (m_verbosity > 5) {
198  pout() << m_name + "::setPhi(std::function)" << endl;
199  }
200 
201  constexpr int comp = 0;
202 
203  for (int lvl = 0; lvl <= m_amr->getFinestLevel(); lvl++) {
204  const DisjointBoxLayout& dbl = m_amr->getGrids(m_realm)[lvl];
205  const DataIterator& dit = dbl.dataIterator();
206  const Real& dx = m_amr->getDx()[lvl];
207  const EBISLayout& ebisl = m_amr->getEBISLayout(m_realm, m_phase)[lvl];
208  const RealVect& probLo = m_amr->getProbLo();
209 
210  const int nbox = dit.size();
211 
212 #pragma omp parallel for schedule(runtime)
213  for (int mybox = 0; mybox < nbox; mybox++) {
214  const DataIndex& din = dit[mybox];
215 
216  EBCellFAB& phi = (*m_phi[lvl])[din];
217  const EBISBox& ebisbox = ebisl[din];
218  FArrayBox& phiFAB = phi.getFArrayBox();
219  const BaseFab<bool>& validCells = (*m_amr->getValidCells(m_realm)[lvl])[din];
220 
221  // Regular kernel. Only do cells that are not covered by a finer grid.
222  auto regularKernel = [&](const IntVect& iv) -> void {
223  std::array<Real, N> y{};
224 
225  if (validCells(iv, comp) && ebisbox.isRegular(iv)) {
226  const RealVect pos = probLo + (0.5 * RealVect::Unit + RealVect(iv)) * dx;
227 
228  y = a_phiFunc(pos);
229  }
230 
231  // Put right-hand side in mesh data. This is set to zero if the cell is covered by a finer grid cell.
232  for (size_t i = 0; i < N; i++) {
233  phiFAB(iv, i) = y[i];
234  }
235  };
236 
237  // Irregular kernel. Only do cells that are not covered by a finer grid.
238  auto irregularKernel = [&](const VolIndex& vof) -> void {
239  std::array<Real, N> y{};
240  const IntVect iv = vof.gridIndex();
241 
242  if (validCells(iv, comp)) {
243  const RealVect pos = probLo + Location::position(Location::Cell::Centroid, vof, ebisbox, dx);
244 
245  y = a_phiFunc(pos);
246  }
247 
248  // Put right-hand side in mesh data. This is set to zero if the cell is covered by a finer grid cell.
249  for (size_t i = 0; i < N; i++) {
250  phi(vof, i) = y[i];
251  }
252  };
253 
254  // Kernel regions.
255  const Box cellBox = dbl[din];
256  VoFIterator& vofit = (*m_amr->getVofIterator(m_realm, m_phase)[lvl])[din];
257 
258  // Run the kernels.
259  BoxLoops::loop(cellBox, regularKernel);
260  BoxLoops::loop(vofit, irregularKernel);
261  }
262  }
263 }
264 
265 template <size_t N>
266 void
267 MeshODESolver<N>::setRHS(const std::function<Real(const RealVect& a_pos)>& a_srcFunc, const size_t a_comp) noexcept
268 {
269  CH_TIME("MeshODESolver::setRHS(std::function, size_t)");
270  if (m_verbosity > 5) {
271  pout() << m_name + "::setRHS(std::function, size_t)" << endl;
272  }
273 
274  DataOps::setValue(m_rhs, a_srcFunc, m_amr->getProbLo(), m_amr->getDx(), a_comp);
275 }
276 
277 template <size_t N>
278 void
279 MeshODESolver<N>::computeRHS(const RHSFunction& a_rhsFunction) noexcept
280 {
281  CH_TIME("MeshODESolver::computeRHS(std::function<std::array<Real, N>(...)>)");
282  if (m_verbosity > 5) {
283  pout() << m_name + "::computeRHS(std::function<std::array<Real, N>(...)>)" << endl;
284  }
285 
286  this->computeRHS(m_rhs, a_rhsFunction);
287 }
288 
289 template <size_t N>
290 void
291 MeshODESolver<N>::computeRHS(EBAMRCellData& a_rhs, const RHSFunction& a_rhsFunction) const noexcept
292 {
293  CH_TIME("MeshODESolver::computeRHS(EBAMRCellData, std::function<std::array<Real, N>(...)>)");
294  if (m_verbosity > 5) {
295  pout() << m_name + "::computeRHS(EBAMRCellData, std::function<std::array<Real, N>(...)>)" << endl;
296  }
297 
298  constexpr int comp = 0;
299 
300  for (int lvl = 0; lvl <= m_amr->getFinestLevel(); lvl++) {
301  const DisjointBoxLayout& dbl = m_amr->getGrids(m_realm)[lvl];
302  const EBISLayout& ebisl = m_amr->getEBISLayout(m_realm, m_phase)[lvl];
303  const DataIterator& dit = dbl.dataIterator();
304 
305  const int nbox = dit.size();
306 
307 #pragma omp parallel for schedule(runtime)
308  for (int mybox = 0; mybox < nbox; mybox++) {
309  const DataIndex& din = dit[mybox];
310 
311  EBCellFAB& rhs = (*a_rhs[lvl])[din];
312  const EBCellFAB& phi = (*m_phi[lvl])[din];
313  const EBISBox& ebisbox = ebisl[din];
314 
315  FArrayBox& rhsFAB = rhs.getFArrayBox();
316  const FArrayBox& phiFAB = phi.getFArrayBox();
317 
318  const BaseFab<bool>& validCells = (*m_amr->getValidCells(m_realm)[lvl])[din];
319 
320  // Regular kernel. Only do cells that are not covered by a finer grid.
321  auto regularKernel = [&](const IntVect& iv) -> void {
322  std::array<Real, N> y{};
323  std::array<Real, N> f{};
324 
325  if (validCells(iv, comp) && ebisbox.isRegular(iv)) {
326 
327  // Make y from the mesh data.
328  for (size_t i = 0; i < N; i++) {
329  y[i] = phiFAB(iv, i);
330  }
331 
332  // Compute the right-hand side.
333  f = a_rhsFunction(y, m_time);
334  }
335 
336  // Put right-hand side in mesh data. This is set to zero if the cell is covered by a finer grid cell.
337  for (size_t i = 0; i < N; i++) {
338  rhsFAB(iv, i) = f[i];
339  }
340  };
341 
342  // Irregular kernel. Only do cells that are not covered by a finer grid.
343  auto irregularKernel = [&](const VolIndex& vof) -> void {
344  std::array<Real, N> y{};
345  std::array<Real, N> f{};
346 
347  const IntVect iv = vof.gridIndex();
348 
349  if (validCells(iv, comp)) {
350 
351  // Make y from the mesh data.
352  for (size_t i = 0; i < N; i++) {
353  y[i] = phi(vof, i);
354  }
355 
356  // Compute the right-hand side.
357  f = a_rhsFunction(y, m_time);
358  }
359 
360  // Put right-hand side in mesh data. This is set to zero if the cell is covered by a finer grid cell.
361  for (size_t i = 0; i < N; i++) {
362  rhs(vof, i) = f[i];
363  }
364  };
365 
366  // Kernel regions.
367  const Box cellBox = dbl[din];
368  VoFIterator& vofit = (*m_amr->getVofIterator(m_realm, m_phase)[lvl])[din];
369 
370  // Run the kernels.
371  BoxLoops::loop(cellBox, regularKernel);
372  BoxLoops::loop(vofit, irregularKernel);
373  }
374  }
375 }
376 
377 template <size_t N>
378 void
380 {
381  CH_TIME("MeshODESolver::allocate()");
382  if (m_verbosity > 5) {
383  pout() << m_name + "::allocate()" << endl;
384  }
385 
386  m_amr->allocate(m_phi, m_realm, m_phase, N);
387  m_amr->allocate(m_rhs, m_realm, m_phase, N);
388 }
389 
390 template <size_t N>
391 void
392 MeshODESolver<N>::preRegrid(const int a_lbase, const int a_oldFinestLevel) noexcept
393 {
394  CH_TIME("MeshODESolver::preRegrid(int, int)");
395  if (m_verbosity > 5) {
396  pout() << m_name + "::preRegrid(int, int)" << endl;
397  }
398 
399  m_amr->allocate(m_cache, m_realm, m_phase, N);
400  m_amr->copyData(m_cache, m_phi);
401 
402  m_phi.clear();
403 }
404 
405 template <size_t N>
406 void
407 MeshODESolver<N>::regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) noexcept
408 {
409  CH_TIME("MeshODESolver::regrid(int, int, int)");
410  if (m_verbosity > 5) {
411  pout() << m_name + "::regrid(int, int, int)" << endl;
412  }
413 
414  this->allocate();
415 
416  const EBCoarseToFineInterp::Type interpType = m_regridSlopes ? EBCoarseToFineInterp::Type::ConservativeMinMod
417  : EBCoarseToFineInterp::Type::ConservativePWC;
418 
419  m_amr->interpToNewGrids(m_phi, m_cache, m_phase, a_lmin, a_oldFinestLevel, a_newFinestLevel, interpType);
420 
421  m_amr->conservativeAverage(m_phi, m_realm, m_phase);
422  m_amr->interpGhost(m_phi, m_realm, m_phase);
423 
424  m_cache.clear();
425 }
426 
427 template <size_t N>
428 std::string
430 {
431  CH_TIME("MeshODESolver::getRealm()");
432  if (m_verbosity > 5) {
433  pout() << m_name + "::getRealm()" << endl;
434  }
435 
436  return m_realm;
437 }
438 
439 template <size_t N>
440 std::string
442 {
443  CH_TIME("MeshODESolver::getName()");
444  if (m_verbosity > 5) {
445  pout() << m_name + "::getName()" << endl;
446  }
447 
448  return m_name;
449 }
450 
451 template <size_t N>
452 void
453 MeshODESolver<N>::setName(const std::string& a_name) noexcept
454 {
455  CH_TIME("MeshODESolver::setName()");
456  if (m_verbosity > 5) {
457  pout() << m_name + "::setName()" << endl;
458  }
459 
460  m_name = a_name;
461 }
462 
463 template <size_t N>
464 void
466 {
467  CH_TIME("MeshODESolver::registerOperators()");
468  if (m_verbosity > 5) {
469  pout() << m_name + "::registerOperators()" << endl;
470  }
471 
472  CH_assert(!m_amr.isNull());
473 
474  m_amr->registerOperator(s_eb_coar_ave, m_realm, m_phase);
475  m_amr->registerOperator(s_eb_fill_patch, m_realm, m_phase);
476  m_amr->registerOperator(s_eb_fine_interp, m_realm, m_phase);
477 }
478 
479 template <size_t N>
480 void
481 MeshODESolver<N>::setRealm(const std::string a_realm) noexcept
482 {
483  CH_TIME("MeshODESolver::setRealm(std::string)");
484  if (m_verbosity > 5) {
485  pout() << m_name + "::setRealm(std::string)" << endl;
486  }
487 
488  m_realm.assign(a_realm);
489 }
490 
491 template <size_t N>
492 void
493 MeshODESolver<N>::setPhase(phase::which_phase a_phase) noexcept
494 {
495  CH_TIME("MeshODESolver::setPhase(phase)");
496  if (m_verbosity > 5) {
497  pout() << m_name + "::setPhase(phase)" << endl;
498  }
499 
500  m_phase = a_phase;
501 }
502 
503 template <size_t N>
504 void
505 MeshODESolver<N>::setVerbosity(const int a_verbosity) noexcept
506 {
507  CH_TIME("MeshODESolver::setVerbosity(int)");
508  if (m_verbosity > 5) {
509  pout() << m_name + "::setVerbosity(int)" << endl;
510  }
511 
512  m_verbosity = a_verbosity;
513 }
514 
515 template <size_t N>
516 void
517 MeshODESolver<N>::setTime(const int a_step, const Real a_time, const Real a_dt) noexcept
518 {
519  CH_TIME("MeshODESolver::setTime(int, Real, Real)");
520  if (m_verbosity > 5) {
521  pout() << m_name + "::setTime(int, Real, Real)" << endl;
522  }
523 
524  m_timeStep = a_step;
525  m_time = a_time;
526  m_dt = a_dt;
527 }
528 
529 template <size_t N>
530 void
532 {
533  CH_TIME("MeshODESolver::writePlotFile()");
534  if (m_verbosity > 5) {
535  pout() << m_name + "::writePlotFile()" << endl;
536  }
537 
538  // Number of output components and their names
539  const int numPlotVars = this->getNumberOfPlotVariables();
540  const Vector<std::string> plotVarNames = this->getPlotVariableNames();
541 
542  // Allocate storage
543  EBAMRCellData output;
544  m_amr->allocate(output, m_realm, m_phase, numPlotVars);
545  DataOps::setValue(output, 0.0);
546 
547  int icomp = 0;
548  for (int lvl = 0; lvl <= m_amr->getFinestLevel(); lvl++) {
549  this->writePlotData(*output[lvl], icomp, m_realm, lvl);
550  }
551 
552  char filename[100];
553  sprintf(filename, "%s.step%07d.%dd.hdf5", m_name.c_str(), m_timeStep, SpaceDim);
554  std::string fname(filename);
555 
556  // Alias, because Chombo's EBAMRIO wants raw pointers (but we stick to smart pointers, like God intended).
557  Vector<LevelData<EBCellFAB>*> outputPtr;
558  m_amr->alias(outputPtr, output);
559 
560 #ifdef CH_USE_HDF5
561  constexpr int numPlotGhost = 0;
562 
563  DischargeIO::writeEBHDF5(fname,
564  plotVarNames,
565  m_amr->getGrids(m_realm),
566  outputPtr,
567  m_amr->getDomains(),
568  m_amr->getDx(),
569  m_amr->getRefinementRatios(),
570  m_dt,
571  m_time,
572  m_amr->getProbLo(),
573  m_amr->getFinestLevel() + 1,
574  numPlotGhost);
575 #endif
576 }
577 
578 template <size_t N>
579 int
581 {
582  CH_TIME("MeshODESolver::getNumberOfPlotVariables()");
583  if (m_verbosity > 5) {
584  pout() << m_name + "::getNumberOfPlotVariables()" << endl;
585  }
586 
587  int numPlotVars = 0;
588 
589  if (m_plotPhi) {
590  numPlotVars += int(N);
591  }
592 
593  if (m_plotRHS) {
594  numPlotVars += int(N);
595  }
596 
597  return numPlotVars;
598 }
599 
600 template <size_t N>
601 Vector<std::string>
603 {
604  CH_TIME("MeshODESolver::getPlotVariableNames()");
605  if (m_verbosity > 5) {
606  pout() << m_name + "::getPlotVariableNames()" << endl;
607  }
608 
609  Vector<std::string> plotVarNames(0);
610 
611  if (m_plotPhi) {
612  for (size_t i = 0; i < N; i++) {
613  plotVarNames.push_back(m_name + " phi-" + std::to_string(i));
614  }
615  }
616 
617  if (m_plotRHS) {
618  for (size_t i = 0; i < N; i++) {
619  plotVarNames.push_back(m_name + " source-" + std::to_string(i));
620  }
621  }
622 
623  return plotVarNames;
624 }
625 
626 template <size_t N>
627 void
628 MeshODESolver<N>::writePlotData(LevelData<EBCellFAB>& a_output,
629  int& a_icomp,
630  const std::string a_outputRealm,
631  const int a_level) const noexcept
632 {
633  CH_TIME("MeshODESolver::writePlotData");
634  if (m_verbosity > 5) {
635  pout() << m_name + "::writePlotData" << endl;
636  }
637 
638  if (m_plotPhi) {
639  this->writeData(a_output, a_icomp, m_phi, a_outputRealm, a_level, false, true);
640  }
641 
642  if (m_plotRHS) {
643  this->writeData(a_output, a_icomp, m_rhs, a_outputRealm, a_level, false, true);
644  }
645 }
646 
647 template <size_t N>
648 void
649 MeshODESolver<N>::writeData(LevelData<EBCellFAB>& a_output,
650  int& a_comp,
651  const EBAMRCellData& a_data,
652  const std::string a_outputRealm,
653  const int a_level,
654  const bool a_interpToCentroids,
655  const bool a_interpGhost) const noexcept
656 
657 {
658  CH_TIMERS("MeshODESolver::writeData");
659  CH_TIMER("MeshODESolver::writeData::allocate", t1);
660  CH_TIMER("MeshODESolver::writeData::local_copy", t2);
661  CH_TIMER("MeshODESolver::writeData::interp_ghost", t3);
662  CH_TIMER("MeshODESolver::writeData::interp_centroid", t4);
663  CH_TIMER("MeshODESolver::writeData::final_copy", t5);
664  if (m_verbosity > 5) {
665  pout() << m_name + "::writeData" << endl;
666  }
667 
668  // Number of components we are working with.
669  const int numComp = a_data[a_level]->nComp();
670 
671  // Component ranges that we copy to/from.
672  const Interval srcInterv(0, numComp - 1);
673  const Interval dstInterv(a_comp, a_comp + numComp - 1);
674 
675  CH_START(t1);
676  LevelData<EBCellFAB> scratch;
677  m_amr->allocate(scratch, m_realm, m_phase, a_level, numComp);
678  CH_STOP(t1);
679 
680  CH_START(t2);
681  m_amr->copyData(scratch, *a_data[a_level], a_level, m_realm, m_realm);
682  CH_START(t2);
683 
684  // Interpolate ghost cells
685  CH_START(t3);
686  if (a_level > 0 && a_interpGhost) {
687  m_amr->interpGhost(scratch, *a_data[a_level - 1], a_level, m_realm, m_phase);
688  }
689  CH_STOP(t3);
690 
691  CH_START(t4);
692  if (a_interpToCentroids) {
693  m_amr->interpToCentroids(scratch, m_realm, m_phase, a_level);
694  }
695  CH_STOP(t4);
696 
697  DataOps::setCoveredValue(scratch, 0.0);
698 
699  CH_START(t5);
700  m_amr->copyData(a_output, scratch, a_level, a_outputRealm, m_realm, dstInterv, srcInterv);
701  CH_STOP(t5);
702 
703  a_comp += numComp;
704 }
705 
706 #ifdef CH_USE_HDF5
707 template <size_t N>
708 void
709 MeshODESolver<N>::writeCheckpointLevel(HDF5Handle& a_handle, const int a_level) const noexcept
710 {
711  CH_TIME("MeshODESolver::writeCheckpointLevel(HDF5Handle, int)");
712  if (m_verbosity > 5) {
713  pout() << m_name + "::writeCheckpointLevel(HDF5Handle, int)" << endl;
714  }
715 
716  write(a_handle, *m_phi[a_level], m_name);
717  write(a_handle, *m_rhs[a_level], m_name + "_src");
718 }
719 #endif
720 
721 #ifdef CH_USE_HDF5
722 template <size_t N>
723 void
724 MeshODESolver<N>::readCheckpointLevel(HDF5Handle& a_handle, const int a_level) noexcept
725 {
726  CH_TIME("MeshODESolver::writeCheckpointLevel(HDF5Handle, int)");
727  if (m_verbosity > 5) {
728  pout() << m_name + "::writeCheckpointLevel(HDF5Handle, int)" << endl;
729  }
730 
731  read<EBCellFAB>(a_handle, *m_phi[a_level], m_name, m_amr->getGrids(m_realm)[a_level], Interval(0, N - 1), false);
732  read<EBCellFAB>(a_handle,
733  *m_rhs[a_level],
734  m_name + "_src",
735  m_amr->getGrids(m_realm)[a_level],
736  Interval(0, N - 1),
737  false);
738 }
739 #endif
740 
741 #include <CD_NamespaceFooter.H>
742 
743 #endif
Declaration of a namespace for proto-typing grid and EB loops.
Silly, but useful functions that override standard Chombo HDF5 IO.
Declaration of cell positions.
Encapsulation of an ODE solver on the mesh.
static void setValue(LevelData< MFInterfaceFAB< T >> &a_lhs, const T &a_value)
Set value in an MFInterfaceFAB data holder.
Definition: CD_DataOpsImplem.H:23
static void setCoveredValue(EBAMRCellData &a_lhs, const int a_comp, const Real a_value)
Set value in covered cells. Does specified component.
Definition: CD_DataOps.cpp:2538
Type
Type of interpolation methods supported. PWC = Piecewise constant, ignoring the embedded boundary....
Definition: CD_EBCoarseToFineInterp.H:42
Class for solving dy/dt = f on an AMR hierarchy.
Definition: CD_MeshODESolver.H:28
virtual std::string getRealm() const noexcept
Get the realm where this solver is registered.
Definition: CD_MeshODESolverImplem.H:429
virtual void writePlotData(LevelData< EBCellFAB > &a_output, int &a_icomp, const std::string a_outputRealm, const int a_level) const noexcept
Write plot data to output holder.
Definition: CD_MeshODESolverImplem.H:628
virtual Vector< std::string > getPlotVariableNames() const noexcept
Get output plot names.
Definition: CD_MeshODESolverImplem.H:602
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel) noexcept
Regrid this solver.
Definition: CD_MeshODESolverImplem.H:407
virtual void writePlotFile() const noexcept
Write plot file.
Definition: CD_MeshODESolverImplem.H:531
std::function< std::array< Real, N >(const std::array< Real, N > &, const Real)> RHSFunction
Alias for right-hand side.
Definition: CD_MeshODESolver.H:33
virtual void setName(const std::string &a_name) noexcept
Set solver name.
Definition: CD_MeshODESolverImplem.H:453
virtual void preRegrid(const int a_lbase, const int a_oldFinestLevel) noexcept
Perform pre-regrid operations.
Definition: CD_MeshODESolverImplem.H:392
virtual void setPhi(const std::function< Real(const RealVect &a_pos)> &a_phiFunc, const size_t a_comp) noexcept
Set phi for a specific component.
Definition: CD_MeshODESolverImplem.H:182
virtual void parseRuntimeOptions() noexcept
Parse run-time configurable class options.
Definition: CD_MeshODESolverImplem.H:87
MeshODESolver()
Default constructor. Must subsequently set everything through public member functions.
Definition: CD_MeshODESolverImplem.H:27
virtual void registerOperators() const noexcept
Register operators for AMR operations.
Definition: CD_MeshODESolverImplem.H:465
virtual void setVerbosity(const int a_verbosity) noexcept
Set verbosity.
Definition: CD_MeshODESolverImplem.H:505
virtual void setRHS(const std::function< Real(const RealVect &a_pos)> &a_srcFunc, const size_t a_comp) noexcept
Set right-hand side for specified component.
Definition: CD_MeshODESolverImplem.H:267
virtual void setRealm(const std::string a_realm) noexcept
Set the realm for this solver.
Definition: CD_MeshODESolverImplem.H:481
EBAMRCellData & getPhi() noexcept
Get the solution vector (left-hand side of equation).
Definition: CD_MeshODESolverImplem.H:134
virtual ~MeshODESolver()
Destructor.
Definition: CD_MeshODESolverImplem.H:50
virtual int getNumberOfPlotVariables() const noexcept
Get number of output fields.
Definition: CD_MeshODESolverImplem.H:580
virtual void parseOptions() noexcept
Parse class options.
Definition: CD_MeshODESolverImplem.H:69
virtual void parsePlotVariables() noexcept
Parse plot variables.
Definition: CD_MeshODESolverImplem.H:104
EBAMRCellData & getRHS() noexcept
Get the solution vector (left-hand side of equation).
Definition: CD_MeshODESolverImplem.H:158
virtual void setAmr(const RefCountedPtr< AmrMesh > &a_amrMesh) noexcept
Set AmrMesh.
Definition: CD_MeshODESolverImplem.H:57
virtual void setPhase(phase::which_phase a_phase) noexcept
Set phase.
Definition: CD_MeshODESolverImplem.H:493
virtual void allocate() noexcept
Allocate internal storage.
Definition: CD_MeshODESolverImplem.H:379
virtual void setTime(const int a_step, const Real a_time, const Real a_dt) noexcept
Set the time for this solver.
Definition: CD_MeshODESolverImplem.H:517
virtual std::string getName() const noexcept
Get solver name.
Definition: CD_MeshODESolverImplem.H:441
virtual void computeRHS(const RHSFunction &a_rhsFunction) noexcept
Compute right-hand side from left-hand side. I.e. compute f = f(y,t).
Definition: CD_MeshODESolverImplem.H:279
virtual void writeData(LevelData< EBCellFAB > &a_output, int &a_comp, const EBAMRCellData &a_data, const std::string a_outputRealm, const int a_level, const bool a_interpToCentroids, const bool a_interpGhost) const noexcept
Write data to output. Convenience function.
Definition: CD_MeshODESolverImplem.H:649
static const std::string Primal
Identifier for perimal realm.
Definition: CD_Realm.H:47
ALWAYS_INLINE void loop(const Box &a_computeBox, Functor &&kernel, const IntVect &a_stride=IntVect::Unit)
Launch a C++ kernel over a regular grid.
Definition: CD_BoxLoopsImplem.H:20
RealVect position(const 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:20