chombo-discharge
CD_TracerParticleSolverImplem.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_TracerParticleSolverImplem_H
13 #define CD_TracerParticleSolverImplem_H
14 
15 // Chombo includes
16 #include <ParmParse.H>
17 
18 // Our includes
20 #include <CD_DischargeIO.H>
21 #include <CD_ParallelOps.H>
22 #include <CD_NamespaceHeader.H>
23 
24 template <typename P>
26 {
27  CH_TIME("TracerParticleSolver::TracerParticleSolver()");
28 
29  // Default settings
30  m_verbosity = -1;
31  m_name = "TracerParticleSolver";
32  m_className = "TracerParticleSolver";
33  m_realm = Realm::primal;
34  m_phase = phase::gas;
35  m_haloBuffer = 1;
36  m_plotVelocity = true;
37  m_plotWeight = true;
38  m_volumeScale = false;
39  m_deposition = DepositionType::CIC;
40  m_interpolation = DepositionType::CIC;
41  m_coarseFineDeposition = CoarseFineDeposition::Halo;
42 }
43 
44 template <typename P>
45 inline TracerParticleSolver<P>::TracerParticleSolver(const RefCountedPtr<AmrMesh>& a_amr,
46  const RefCountedPtr<ComputationalGeometry> a_compGeom)
48 {
49  CH_TIME("TracerParticleSolver::TracerParticleSolver(RefCountedPtr<AmrMesh>, RefCountedPtr<ComputationalGeometry>)");
50 
51  m_amr = a_amr;
52  m_computationalGeometry = a_compGeom;
53 }
54 
55 template <typename P>
57 {
58  CH_TIME("TracerParticleSolver::~TracerParticleSolver()");
59 }
60 
61 template <typename P>
62 inline void
64 {
65  CH_TIME("TracerParticleSolver::parseOptions()");
66  if (m_verbosity > 5) {
67  pout() << m_name + "::parseOptions()" << endl;
68  }
69 
70  this->parseDeposition();
71  this->parsePlotVariables();
72  this->parseVerbosity();
73 }
74 
75 template <typename P>
76 inline void
78 {
79  CH_TIME("TracerParticleSolver::parseRuntimeOptions()");
80  if (m_verbosity > 5) {
81  pout() << m_name + "::parseRuntimeOptions()" << endl;
82  }
83 
84  this->parseDeposition();
85  this->parsePlotVariables();
86  this->parseVerbosity();
87 }
88 
89 template <typename P>
90 inline void
92 {
93  CH_TIME("TracerParticleSolver::parseDeposition()");
94  if (m_verbosity > 5) {
95  pout() << m_name + "::parseDeposition()" << endl;
96  }
97 
98  ParmParse pp(m_className.c_str());
99 
100  std::string str;
101 
102  // Deposition for particle-mesh operations
103  pp.get("deposition", str);
104  if (str == "ngp") {
105  m_deposition = DepositionType::NGP;
106  }
107  else if (str == "cic") {
108  m_deposition = DepositionType::CIC;
109  }
110  else {
111  MayDay::Error("TracerParticleSolver::parseDeposition - unknown deposition method requested.");
112  }
113 
114  pp.get("deposition_cf", str);
115  if (str == "interp") {
116  m_coarseFineDeposition = CoarseFineDeposition::Interp;
117  }
118  else if (str == "halo") {
119  m_coarseFineDeposition = CoarseFineDeposition::Halo;
120  }
121  else if (str == "halo_ngp") {
122  m_coarseFineDeposition = CoarseFineDeposition::HaloNGP;
123  }
124  else {
125  MayDay::Error("TracerParticleSolver::parseDeposition - unknown coarse-fine deposition method requested.");
126  }
127 
128  // Interpolation type particle-mesh operations
129  pp.get("interpolation", str);
130  if (str == "ngp") {
131  m_interpolation = DepositionType::NGP;
132  }
133  else if (str == "cic") {
134  m_interpolation = DepositionType::CIC;
135  }
136  else {
137  MayDay::Error("TracerParticleSolver::parseDeposition - unknown interpolation method requested.");
138  }
139 
140  pp.get("volume_scale", m_volumeScale);
141 }
142 
143 template <typename P>
144 inline void
146 {
147  CH_TIME("TracerParticleSolver::parsePlotVariables()");
148  if (m_verbosity > 5) {
149  pout() << m_name + "::parsePlotVariables()" << endl;
150  }
151 
152  ParmParse pp(m_className.c_str());
153 
154  pp.get("plot_weight", m_plotWeight);
155  pp.get("plot_velocity", m_plotVelocity);
156 }
157 
158 template <typename P>
159 inline void
161 {
162  CH_TIME("TracerParticleSolver::parseVerbosity()");
163  if (m_verbosity > 5) {
164  pout() << m_name + "::parseVerbosity()" << endl;
165  }
166 
167  ParmParse pp(m_className.c_str());
168 
169  pp.get("verbosity", m_verbosity);
170 }
171 
172 template <typename P>
173 inline void
175 {
176  CH_TIME("TracerParticleSolver::registerOperators()");
177  if (m_verbosity > 5) {
178  pout() << m_name + "::registerOperators()" << endl;
179  }
180 
181  if (m_amr.isNull()) {
182  MayDay::Abort("TracerParticleSolver::registerOperators - need to set AmrMesh!");
183  }
184  else {
185  m_amr->registerOperator(s_particle_mesh, m_realm, m_phase);
186  m_amr->registerOperator(s_eb_coar_ave, m_realm, m_phase);
187 
188  // For CIC halo deposition.
189  m_amr->registerMask(s_particle_halo, 1, m_realm);
190  }
191 }
192 
193 template <typename P>
194 inline void
196 {
197  CH_TIME("TracerParticleSolver::allocate()");
198  if (m_verbosity > 5) {
199  pout() << m_name + "::allocate()" << endl;
200  }
201 
202  // Allocate data for storing the velocity field on the mesh, and storage for the particles.
203  m_amr->allocate(m_particles, m_realm);
204  m_amr->allocate(m_velocityField, m_realm, m_phase, SpaceDim);
205 }
206 
207 template <typename P>
208 inline void
209 TracerParticleSolver<P>::setName(const std::string& a_name) noexcept
210 {
211  CH_TIME("TracerParticleSolver::setName(std::string)");
212  if (m_verbosity > 5) {
213  pout() << m_name + "::setName(std::string)" << endl;
214  }
215 
216  m_name = a_name;
217 }
218 
219 template <typename P>
220 inline void
221 TracerParticleSolver<P>::setVolumeScale(const bool a_scale) noexcept
222 {
223  CH_TIME("TracerParticleSolver::setVolumeScale(bool)");
224  if (m_verbosity > 5) {
225  pout() << m_name + "::setVolumeScale(bool)" << endl;
226  }
227 
228  m_volumeScale = a_scale;
229 }
230 
231 template <typename P>
232 inline void
233 TracerParticleSolver<P>::setRealm(const std::string& a_realm)
234 {
235  CH_TIME("TracerParticleSolver::setRealm(std::string)");
236  if (m_verbosity > 5) {
237  pout() << m_name + "::setRealm(std::string)" << endl;
238  }
239 
240  m_realm = a_realm;
241 }
242 
243 template <typename P>
244 inline void
245 TracerParticleSolver<P>::setPhase(const phase::which_phase& a_phase)
246 {
247  CH_TIME("TracerParticleSolver::setPhase(phase::which_phase)");
248  if (m_verbosity > 5) {
249  pout() << m_name + "::setPhase(phase::which_phase)" << endl;
250  }
251 
252  m_phase = a_phase;
253 }
254 
255 template <typename P>
256 void
257 TracerParticleSolver<P>::setTime(const int a_step, const Real a_time, const Real a_dt)
258 {
259  CH_TIME("TracerParticleSolver::setTime(int, Real, Real)");
260  if (m_verbosity > 5) {
261  pout() << m_name + "::setTime(int, Real, Real)" << endl;
262  }
263 
264  m_timeStep = a_step;
265  m_time = a_time;
266  m_dt = a_dt;
267 }
268 
269 template <typename P>
270 inline void
271 TracerParticleSolver<P>::setAmr(const RefCountedPtr<AmrMesh>& a_amrMesh)
272 {
273  CH_TIME("TracerParticleSolver::setAmr(RefCountedPtr<AmrMesh>)");
274  if (m_verbosity > 5) {
275  pout() << m_name + "::setAmr(RefCountedPtr<AmrMesh>)" << endl;
276  }
277 
278  m_amr = a_amrMesh;
279 }
280 
281 template <typename P>
282 inline void
283 TracerParticleSolver<P>::setComputationalGeometry(const RefCountedPtr<ComputationalGeometry>& a_compGeom)
284 {
285  CH_TIME("TracerParticleSolver::setComputationalGeometry(RefCountedPtr<ComputationalGeometry>)");
286  if (m_verbosity > 5) {
287  pout() << m_name + "::setComputationalGeometry(RefCountedPtr<ComputationalGeometry>)" << endl;
288  }
289 
290  m_computationalGeometry = a_compGeom;
291 }
292 
293 template <typename P>
294 inline void
296 {
297  CH_TIME("TracerParticleSolver::setVelocity(EBAMRCellData)");
298  if (m_verbosity > 5) {
299  pout() << m_name + "::setVelocity(EBAMRCellData)" << endl;
300  }
301 
302  DataOps::copy(m_velocityField, a_velocityField);
303 }
304 
305 template <typename P>
306 inline void
307 TracerParticleSolver<P>::preRegrid(const int a_lbase, const int a_oldFinestLevel)
308 {
309  CH_TIME("TracerParticleSolver::preRegrid(int, int)");
310  if (m_verbosity > 5) {
311  pout() << m_name + "::preRegrid(int, int)" << endl;
312  }
313 
314  CH_assert(a_lbase >= 0);
315 
316  // Put particles in pre-regrid mode.
317  m_particles.preRegrid(a_lbase);
318 }
319 
320 template <typename P>
321 inline void
322 TracerParticleSolver<P>::regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel)
323 {
324  CH_TIME("TracerParticleSolver::regrid(int, int, int)");
325  if (m_verbosity > 5) {
326  pout() << m_name + "::regrid(int, int, int)" << endl;
327  }
328 
329  CH_assert(a_lmin >= 0);
330  CH_assert(a_oldFinestLevel >= 0);
331  CH_assert(a_newFinestLevel >= 0);
332 
333  m_amr->remapToNewGrids(m_particles, a_lmin, a_newFinestLevel);
334  m_amr->allocate(m_velocityField, m_realm, m_phase, SpaceDim);
335 }
336 
337 template <typename P>
338 inline void
340 {
341  CH_TIME("TracerParticleSolver::remap()");
342  if (m_verbosity > 5) {
343  pout() << m_name + "::remap()" << endl;
344  }
345 
346  m_particles.remap();
347 }
348 
349 template <typename P>
350 inline void
352 {
353  CH_TIME("TracerParticleSolver::setDeposition");
354  if (m_verbosity > 5) {
355  pout() << m_name + "::setDeposition" << endl;
356  }
357 
358  m_deposition = a_deposition;
359 }
360 
361 template <typename P>
362 inline void
364 {
365  CH_TIME("TracerParticleSolver::deposit(EBAMRCellData)");
366  if (m_verbosity > 5) {
367  pout() << m_name + "::deposit(EBAMRCellData)" << endl;
368  }
369 
370  DataOps::setValue(a_phi, 0.0);
371  this->depositParticles<P, &P::weight>(a_phi, m_particles, m_deposition, m_coarseFineDeposition);
372 
373  if (m_volumeScale) {
374  DataOps::volumeScale(a_phi, m_amr->getDx());
375  }
376 }
377 
378 template <typename P>
379 void
381 {
382  CH_TIME("TracerParticleSolver::interpolateWeight(EBAMRCellData)");
383  if (m_verbosity > 5) {
384  pout() << m_name + "::interpolateWeight(EBAMRCellData)" << endl;
385  }
386 
387  m_amr->interpolateParticles<P, &P::weight>(m_particles, m_realm, m_phase, a_scalar, m_interpolation, false);
388 }
389 
390 template <typename P>
391 inline void
393 {
394  CH_TIME("TracerParticleSolver::interpolateVelocities()");
395  if (m_verbosity > 5) {
396  pout() << m_name + "::interpolateVelocities()" << endl;
397  }
398 
399  m_amr->interpolateParticles<P, &P::velocity>(m_particles, m_realm, m_phase, m_velocityField, m_interpolation, false);
400 }
401 
402 template <typename P>
403 inline void
405 {
406  CH_TIME("TracerParticleSolver::writePlotFile()");
407  if (m_verbosity > 5) {
408  pout() << m_name + "::writePlotFile()" << endl;
409  }
410 
411  // Number of output components and their names
412  const int numPlotVars = this->getNumberOfPlotVariables();
413  const Vector<std::string> plotVarNames = this->getPlotVariableNames();
414 
415  // Allocate storage
416  EBAMRCellData output;
417  m_amr->allocate(output, m_realm, m_phase, numPlotVars);
418  DataOps::setValue(output, 0.0);
419 
420  // Copy internal data to be plotted over to 'output'
421  int icomp = 0;
422  for (int lvl = 0; lvl <= m_amr->getFinestLevel(); lvl++) {
423  this->writePlotData(*output[lvl], icomp, m_realm, lvl);
424  }
425 
426  // Filename
427  char filename[100];
428  sprintf(filename, "%s.step%07d.%dd.hdf5", m_name.c_str(), m_timeStep, SpaceDim);
429  std::string fname(filename);
430 
431  // Alias, because Chombo's EBAMRIO wants raw pointers (but we stick to smart pointers, like God intended).
432  Vector<LevelData<EBCellFAB>*> outputPtr;
433  m_amr->alias(outputPtr, output);
434 
435 #ifdef CH_USE_HDF5
436  constexpr int numPlotGhost = 0;
437 
438  DischargeIO::writeEBHDF5(fname,
439  plotVarNames,
440  m_amr->getGrids(m_realm),
441  outputPtr,
442  m_amr->getDomains(),
443  m_amr->getDx(),
444  m_amr->getRefinementRatios(),
445  m_dt,
446  m_time,
447  m_amr->getProbLo(),
448  m_amr->getFinestLevel() + 1,
449  numPlotGhost);
450 #endif
451 }
452 
453 template <typename P>
454 inline int
456 {
457  CH_TIME("TracerParticleSolver::getNumberOfPlotVariables()");
458  if (m_verbosity > 5) {
459  pout() << m_name + "::getNumberOfPlotVariables()" << endl;
460  }
461 
462  int numPlotVars = 0;
463 
464  if (m_plotWeight) {
465  numPlotVars += 1;
466  }
467  if (m_plotVelocity) {
468  numPlotVars += SpaceDim;
469  }
470 
471  return numPlotVars;
472 }
473 
474 template <typename P>
475 inline Vector<std::string>
477 {
478  CH_TIME("TracerParticleSolver::getPlotVariableNames()");
479  if (m_verbosity > 5) {
480  pout() << m_name + "::getPlotVariableNames()" << endl;
481  }
482 
483  Vector<std::string> plotVarNames(0);
484 
485  if (m_plotWeight) {
486  plotVarNames.push_back(m_name + " density");
487  }
488  if (m_plotVelocity) {
489  plotVarNames.push_back("x-velocity " + m_name);
490  }
491  if (m_plotVelocity) {
492  plotVarNames.push_back("y-velocity " + m_name);
493  }
494 #if CH_SPACEDIM == 3
495  if (m_plotVelocity) {
496  plotVarNames.push_back("z-velocity " + m_name);
497  }
498 #endif
499 
500  return plotVarNames;
501 }
502 
503 template <typename P>
504 inline void
505 TracerParticleSolver<P>::writePlotData(LevelData<EBCellFAB>& a_output,
506  int& a_comp,
507  const std::string a_outputRealm,
508  const int a_level) const noexcept
509 {
510  CH_TIME("TracerParticleSolver::writePlotData");
511  if (m_verbosity > 5) {
512  pout() << m_name + "::writePlotData" << endl;
513  }
514 
515  // Write the particle scalars.
516  if (m_plotWeight) {
517  EBAMRCellData weight;
518  m_amr->allocate(weight, m_realm, m_phase, 1);
519 
520  this->deposit(weight);
521 
522  this->writeData(a_output, a_comp, weight, a_outputRealm, a_level, false, true);
523  }
524 
525  // Write the velocity field to the output data holder.
526  if (m_plotVelocity) {
527  this->writeData(a_output, a_comp, m_velocityField, a_outputRealm, a_level, true, true);
528  }
529 }
530 
531 template <typename P>
532 void
533 TracerParticleSolver<P>::writeData(LevelData<EBCellFAB>& a_output,
534  int& a_comp,
535  const EBAMRCellData& a_data,
536  const std::string a_outputRealm,
537  const int a_level,
538  const bool a_interpToCentroids,
539  const bool a_interpGhost) const noexcept
540 {
541  CH_TIMERS("TracerParticleSolver::writeData");
542  CH_TIMER("TracerParticleSolver::writeData::allocate", t1);
543  CH_TIMER("TracerParticleSolver::writeData::local_copy", t2);
544  CH_TIMER("TracerParticleSolver::writeData::interp_ghost", t3);
545  CH_TIMER("TracerParticleSolver::writeData::interp_centroid", t4);
546  CH_TIMER("TracerParticleSolver::writeData::final_copy", t5);
547  if (m_verbosity > 5) {
548  pout() << m_name + "::writeData" << endl;
549  }
550 
551  // Number of components we are working with.
552  const int numComp = a_data[a_level]->nComp();
553 
554  CH_START(t1);
555  LevelData<EBCellFAB> scratch;
556  m_amr->allocate(scratch, m_realm, m_phase, a_level, numComp);
557  CH_STOP(t1);
558 
559  CH_START(t2);
560  m_amr->copyData(scratch, *a_data[a_level], a_level, m_realm, m_realm);
561  CH_START(t2);
562 
563  // Interpolate ghost cells
564  CH_START(t3);
565  if (a_level > 0 && a_interpGhost) {
566  m_amr->interpGhost(scratch, *a_data[a_level - 1], a_level, m_realm, m_phase);
567  }
568  CH_STOP(t3);
569 
570  CH_START(t4);
571  if (a_interpToCentroids) {
572  m_amr->interpToCentroids(scratch, m_realm, m_phase, a_level);
573  }
574  CH_STOP(t4);
575 
576  DataOps::setCoveredValue(scratch, 0.0);
577 
578  CH_START(t5);
579  const Interval srcInterv(0, numComp - 1);
580  const Interval dstInterv(a_comp, a_comp + numComp - 1);
581  m_amr->copyData(a_output, scratch, a_level, a_outputRealm, m_realm, dstInterv, srcInterv);
582  CH_STOP(t5);
583 
584  a_comp += numComp;
585 }
586 
587 #ifdef CH_USE_HDF5
588 template <typename P>
589 inline void
590 TracerParticleSolver<P>::writeCheckpointLevel(HDF5Handle& a_handle, const int a_level) const
591 {
592  CH_TIME("TracerParticleSolver::writeCheckpointLevel(HDF5Handle, int)");
593  if (m_verbosity > 5) {
594  pout() << m_name + "::writeCheckpointLevel(HDF5Handle, int)" << endl;
595  }
596 
597  writeParticlesToHDF(a_handle, m_particles[a_level], m_name + "_particles");
598 }
599 #endif
600 
601 #ifdef CH_USE_HDF5
602 template <typename P>
603 inline void
604 TracerParticleSolver<P>::readCheckpointLevel(HDF5Handle& a_handle, const int a_level)
605 {
606  CH_TIME("TracerParticleSolver::readCheckpointLevel(HDF5Handle, int)");
607  if (m_verbosity > 5) {
608  pout() << m_name + "::readCheckpointLevel(HDF5Handle, int)" << endl;
609  }
610 
611  readParticlesFromHDF(a_handle, m_particles[a_level], m_name + "_particles");
612 }
613 #endif
614 
615 template <typename P>
616 Real
618 {
619  CH_TIME("TracerParticleSolver::computeDt()");
620  if (m_verbosity > 5) {
621  pout() << m_name + "::computeDt()" << endl;
622  }
623 
624  Real dt = std::numeric_limits<Real>::infinity();
625 
626  for (int lvl = 0; lvl <= m_amr->getFinestLevel(); lvl++) {
627  const DisjointBoxLayout& dbl = m_amr->getGrids(m_realm)[lvl];
628  const DataIterator& dit = dbl.dataIterator();
629  const Real dx = m_amr->getDx()[lvl];
630 
631  const int nbox = dit.size();
632 
633 #pragma omp parallel for schedule(runtime) reduction(min : dt)
634  for (int mybox = 0; mybox < nbox; mybox++) {
635  const DataIndex& din = dit[mybox];
636 
637  const List<P>& particles = m_particles[lvl][din].listItems();
638 
639  for (ListIterator<P> lit(particles); lit.ok(); ++lit) {
640  const RealVect& v = lit().velocity();
641 
642  for (int dir = 0; dir < SpaceDim; dir++) {
643  dt = std::min(dt, dx / std::abs(v[dir]));
644  }
645  }
646  }
647  }
648 
649  // Get the minimum of dt over all MPI ranks.
650  dt = ParallelOps::min(dt);
651 
652  return dt;
653 }
654 
655 template <typename P>
656 inline ParticleContainer<P>&
658 {
659  CH_TIME("TracerParticleSolver::getParticles()");
660  if (m_verbosity > 5) {
661  pout() << m_name + "::getParticles()" << endl;
662  }
663 
664  return m_particles;
665 }
666 
667 template <typename P>
668 inline const ParticleContainer<P>&
670 {
671  CH_TIME("TracerParticleSolver::getParticles()");
672  if (m_verbosity > 5) {
673  pout() << m_name + "::getParticles()" << endl;
674  }
675 
676  return m_particles;
677 }
678 
679 template <typename P>
680 inline const EBAMRCellData&
682 {
683  CH_TIME("TracerParticleSolver::getVelocityField()");
684  if (m_verbosity > 5) {
685  pout() << m_name + "::getVelocityField()" << endl;
686  }
687 
688  return m_velocityField;
689 }
690 
691 template <typename P>
692 template <typename T, const Real& (T::*particleScalarFunction)() const>
693 void
695  const ParticleContainer<T>& a_particles,
696  const DepositionType a_baseDeposition,
697  const CoarseFineDeposition a_coarseFineDeposition) const noexcept
698 {
699  CH_TIME("TracerParticleSolver::depositParticles()");
700  if (m_verbosity > 5) {
701  pout() << m_name + "::depositParticles()" << endl;
702  }
703 
704  CH_assert(a_phi[0]->nComp() == 1);
705 
706  // I HATE it when other people do this. Yet I keep doing it.
707  ParticleContainer<T>& mutableParticles = (ParticleContainer<T>&)a_particles;
708 
709  switch (a_coarseFineDeposition) {
710  case CoarseFineDeposition::Interp: {
711  m_amr->depositParticles<T, particleScalarFunction>(a_phi,
712  m_realm,
713  m_phase,
714  a_particles,
715  a_baseDeposition,
716  CoarseFineDeposition::Interp,
717  false);
718 
719  break;
720  }
721  case CoarseFineDeposition::Halo: {
722 
723  // Copy particles living on the mask.
724  const AMRMask& mask = m_amr->getMask(s_particle_halo, m_haloBuffer, m_realm);
725 
726  mutableParticles.copyMaskParticles(mask);
727 
728  m_amr->depositParticles<T, particleScalarFunction>(a_phi,
729  m_realm,
730  m_phase,
731  a_particles,
732  a_baseDeposition,
733  CoarseFineDeposition::Halo,
734  false);
735 
736  // Clear out the mask particles.
737  mutableParticles.clearMaskParticles();
738 
739  break;
740  }
741  case CoarseFineDeposition::HaloNGP: {
742  const AMRMask& mask = m_amr->getMask(s_particle_halo, m_haloBuffer, m_realm);
743 
744  // Transfer particles living on the mask.
745  mutableParticles.transferMaskParticles(mask);
746 
747  m_amr->depositParticles<T, particleScalarFunction>(a_phi,
748  m_realm,
749  m_phase,
750  a_particles,
751  a_baseDeposition,
752  CoarseFineDeposition::HaloNGP,
753  false);
754 
755  // Transfer them back.
756  mutableParticles.transferParticles(mutableParticles.getMaskParticles());
757 
758  break;
759  }
760  default: {
761  MayDay::Error("TracerParticleSolver::depositParticles -- logic bust due to unsupported coarse-fine deposition");
762  }
763  }
764 }
765 
766 #include <CD_NamespaceFooter.H>
767 
768 #endif
CoarseFineDeposition
Coarse-fine deposition types (see CD_EBAMRParticleMesh for how these are handled).
Definition: CD_CoarseFineDeposition.H:26
DepositionType
Deposition types.
Definition: CD_DepositionType.H:23
Silly, but useful functions that override standard Chombo HDF5 IO.
Agglomeration of basic MPI reductions.
Vector< RefCountedPtr< LevelData< BaseFab< bool > >> > AMRMask
Alias for cutting down on the typic of booleans defined over AMR grids.
Definition: CD_Realm.H:36
Declaration of a solver class that advances tracer particles.
static void volumeScale(EBAMRCellData &a_data, const Vector< Real > &a_dx)
Scale data by dx^SpaceDim.
Definition: CD_DataOps.cpp:2132
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
static void copy(MFAMRCellData &a_dst, const MFAMRCellData &a_src)
Copy data from one data holder to another.
Definition: CD_DataOps.cpp:1118
Templated class for holding particles on an AMR hierarchy with particle remapping.
Definition: CD_ParticleContainer.H:50
void clearMaskParticles() const
Clear the "mask" particles.
Definition: CD_ParticleContainerImplem.H:1688
void transferMaskParticles(const Vector< RefCountedPtr< LevelData< BaseFab< bool >>>> &a_mask)
Copy particles to the mask particle data holder.
Definition: CD_ParticleContainerImplem.H:1599
AMRParticles< P > & getMaskParticles()
Get the mask particles.
Definition: CD_ParticleContainerImplem.H:314
void copyMaskParticles(const Vector< RefCountedPtr< LevelData< BaseFab< bool >>>> &a_mask) const
Copy particles to mask particle data holder.
Definition: CD_ParticleContainerImplem.H:1533
void transferParticles(ParticleContainer< P > &a_otherContainer)
Move particles into this container.
Definition: CD_ParticleContainerImplem.H:914
static const std::string primal
Identifier for perimal realm.
Definition: CD_Realm.H:52
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition: CD_TracerParticleSolver.H:37
virtual void remap()
Remap particles.
Definition: CD_TracerParticleSolverImplem.H:339
virtual void setRealm(const std::string &a_realm)
Set the solver realm.
Definition: CD_TracerParticleSolverImplem.H:233
void parsePlotVariables()
Parse plot variables.
Definition: CD_TracerParticleSolverImplem.H:145
virtual void registerOperators() const
Register operators needed for AMR core functionality.
Definition: CD_TracerParticleSolverImplem.H:174
virtual void setName(const std::string &a_name) noexcept
Set the solver name.
Definition: CD_TracerParticleSolverImplem.H:209
TracerParticleSolver()
Default constructor.
Definition: CD_TracerParticleSolverImplem.H:25
virtual void setTime(const int a_step, const Real a_time, const Real a_dt)
Set the time for this solver.
Definition: CD_TracerParticleSolverImplem.H:257
virtual void deposit(EBAMRCellData &a_phi) const noexcept
Deposit particle weight on mesh.
Definition: CD_TracerParticleSolverImplem.H:363
void depositParticles(EBAMRCellData &a_phi, const ParticleContainer< T > &a_particles, const DepositionType a_baseDeposition, const CoarseFineDeposition a_coarseFineDeposition) const noexcept
Generic particle deposition method for putting a scalar field onto the mesh.
Definition: CD_TracerParticleSolverImplem.H:694
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_TracerParticleSolverImplem.H:533
virtual ~TracerParticleSolver()
Destructor.
Definition: CD_TracerParticleSolverImplem.H:56
virtual void preRegrid(const int a_lbase, const int a_oldFinestLevel)
Perform pre-regrid operations.
Definition: CD_TracerParticleSolverImplem.H:307
virtual ParticleContainer< P > & getParticles()
Get all particles.
Definition: CD_TracerParticleSolverImplem.H:657
void parseDeposition()
Parse deposition method.
Definition: CD_TracerParticleSolverImplem.H:91
void parseVerbosity()
Parse solver verbosity.
Definition: CD_TracerParticleSolverImplem.H:160
virtual void writePlotData(LevelData< EBCellFAB > &a_output, int &a_comp, const std::string a_outputRealm, const int a_level) const noexcept
Write plot data.
Definition: CD_TracerParticleSolverImplem.H:505
RefCountedPtr< AmrMesh > m_amr
Handle to AMR mesh.
Definition: CD_TracerParticleSolver.H:303
virtual Vector< std::string > getPlotVariableNames() const
Get plot variable names.
Definition: CD_TracerParticleSolverImplem.H:476
RefCountedPtr< ComputationalGeometry > m_computationalGeometry
Handle to computational geometry.
Definition: CD_TracerParticleSolver.H:308
virtual void parseRuntimeOptions()
Parse solver run-time options.
Definition: CD_TracerParticleSolverImplem.H:77
virtual void writePlotFile()
Write plot file.
Definition: CD_TracerParticleSolverImplem.H:404
virtual void setDeposition(const DepositionType a_deposition) noexcept
Set deposition method.
Definition: CD_TracerParticleSolverImplem.H:351
virtual void setPhase(const phase::which_phase &a_phase)
Set the solver phase.
Definition: CD_TracerParticleSolverImplem.H:245
virtual void allocate()
Allocate storage for this solver.
Definition: CD_TracerParticleSolverImplem.H:195
virtual void setComputationalGeometry(const RefCountedPtr< ComputationalGeometry > &a_compGeom)
Set the computational geometry.
Definition: CD_TracerParticleSolverImplem.H:283
virtual void interpolateVelocities()
Interpolate particles velocities.
Definition: CD_TracerParticleSolverImplem.H:392
const EBAMRCellData & getVelocityField() const
Return the velocity field.
Definition: CD_TracerParticleSolverImplem.H:681
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel)
Regrid this solver.
Definition: CD_TracerParticleSolverImplem.H:322
virtual void parseOptions()
Parse solver options.
Definition: CD_TracerParticleSolverImplem.H:63
virtual void setVelocity(const EBAMRCellData &a_velocityField)
Set the tracer particle velocity field.
Definition: CD_TracerParticleSolverImplem.H:295
virtual void interpolateWeight(const EBAMRCellData &a_scalar) noexcept
Interpolate a scalar field onto the particle weight.
Definition: CD_TracerParticleSolverImplem.H:380
virtual int getNumberOfPlotVariables() const
Get the number of plot variables.
Definition: CD_TracerParticleSolverImplem.H:455
virtual void setAmr(const RefCountedPtr< AmrMesh > &a_amrMesh)
Set AmrMesh.
Definition: CD_TracerParticleSolverImplem.H:271
virtual Real computeDt() const
Write checkpoint data into HDF5 file. @paramo[out] a_handle HDF5 file.
Definition: CD_TracerParticleSolverImplem.H:617
virtual void setVolumeScale(const bool a_scale) noexcept
Turn on/off volume scaling.
Definition: CD_TracerParticleSolverImplem.H:221
Real min(const Real &a_input) noexcept
Get the minimum of the input, reduced over MPI ranks (in the Chombo communicator)
Definition: CD_ParallelOpsImplem.H:58