chombo-discharge
CD_TracerParticleSolver.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_TracerParticleSolver_H
13 #define CD_TracerParticleSolver_H
14 
15 // Our includes
16 #include <CD_AmrMesh.H>
18 #include <CD_TracerParticle.H>
19 #include <CD_ParticleContainer.H>
20 #include <CD_NamespaceHeader.H>
21 
35 template <typename P>
37 {
38 public:
43 
48  TracerParticleSolver(const TracerParticleSolver& a_other) = delete;
49 
54  TracerParticleSolver(const TracerParticleSolver&& a_other) = delete;
55 
61  TracerParticleSolver(const RefCountedPtr<AmrMesh>& a_amr, const RefCountedPtr<ComputationalGeometry> a_compGeom);
62 
68  operator=(const TracerParticleSolver& a_other) = delete;
69 
75  operator=(const TracerParticleSolver&& a_other) = delete;
76 
80  virtual ~TracerParticleSolver();
81 
85  virtual void
86  allocate();
87 
91  virtual void
92  registerOperators() const;
93 
98  virtual void
99  setAmr(const RefCountedPtr<AmrMesh>& a_amrMesh);
100 
105  virtual void
106  setComputationalGeometry(const RefCountedPtr<ComputationalGeometry>& a_compGeom);
107 
112  virtual void
113  setName(const std::string& a_name) noexcept;
114 
119  virtual void
120  setVolumeScale(const bool a_scale) noexcept;
121 
126  virtual void
127  setRealm(const std::string& a_realm);
128 
133  virtual void
134  setPhase(const phase::which_phase& a_phase);
135 
143  virtual void
144  setTime(const int a_step, const Real a_time, const Real a_dt);
145 
150  virtual void
151  setVelocity(const EBAMRCellData& a_velocityField);
152 
159  virtual void
160  preRegrid(const int a_lbase, const int a_oldFinestLevel);
161 
169  virtual void
170  regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel);
171 
175  virtual void
176  remap();
177 
182  virtual void
183  setDeposition(const DepositionType a_deposition) noexcept;
184 
189  virtual void
190  deposit(EBAMRCellData& a_phi) const noexcept;
191 
195  virtual void
196  interpolateWeight(const EBAMRCellData& a_scalar) noexcept;
197 
201  virtual void
203 
207  virtual void
208  parseOptions();
209 
213  virtual void
215 
221  virtual void
222  writePlotFile();
223 
228  virtual int
229  getNumberOfPlotVariables() const;
230 
235  virtual Vector<std::string>
236  getPlotVariableNames() const;
237 
246  virtual void
247  writePlotData(LevelData<EBCellFAB>& a_output,
248  int& a_comp,
249  const std::string a_outputRealm,
250  const int a_level) const noexcept;
251 
257 #ifdef CH_USE_HDF5
258  virtual void
259  writeCheckpointLevel(HDF5Handle& a_handle, const int a_level) const;
260 #endif
261 
267 #ifdef CH_USE_HDF5
268  virtual void
269  readCheckpointLevel(HDF5Handle& a_handle, const int a_level);
270 #endif
271 
275  virtual Real
276  computeDt() const;
277 
282  virtual ParticleContainer<P>&
283  getParticles();
284 
289  virtual const ParticleContainer<P>&
290  getParticles() const;
291 
296  const EBAMRCellData&
297  getVelocityField() const;
298 
299 protected:
303  RefCountedPtr<AmrMesh> m_amr;
304 
308  RefCountedPtr<ComputationalGeometry> m_computationalGeometry;
309 
314 
319 
324 
328  std::string m_realm;
329 
333  std::string m_name;
334 
338  std::string m_className;
339 
343  phase::which_phase m_phase;
344 
348  Real m_dt;
349 
353  Real m_time;
354 
359 
364 
370 
375 
380 
385 
390 
395 
399  void
400  parseDeposition();
401 
405  void
407 
411  void
412  parseVerbosity();
413 
421  template <typename T, const Real& (T::*particleScalarFunction)() const>
422  void
424  const ParticleContainer<T>& a_particles,
425  const DepositionType a_baseDeposition,
426  const CoarseFineDeposition a_coarseFineDeposition) const noexcept;
427 
438  virtual void
439  writeData(LevelData<EBCellFAB>& a_output,
440  int& a_comp,
441  const EBAMRCellData& a_data,
442  const std::string a_outputRealm,
443  const int a_level,
444  const bool a_interpToCentroids,
445  const bool a_interpGhost) const noexcept;
446 };
447 
448 #include <CD_NamespaceFooter.H>
449 
451 
452 #endif
Declaration of core class for handling AMR-related operations (with embedded boundaries)
CoarseFineDeposition
Coarse-fine deposition types (see CD_EBAMRParticleMesh for how these are handled).
Definition: CD_CoarseFineDeposition.H:26
Declaration of base class for defining geometries.
DepositionType
Deposition types.
Definition: CD_DepositionType.H:23
Declaration of a class for holding particles on an AMR hierarchy.
Implementation of CD_TracerParticleSolver.H.
Declaration of a tracer particle class.
Templated class for holding particles on an AMR hierarchy with particle remapping.
Definition: CD_ParticleContainer.H:50
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition: CD_TracerParticleSolver.H:37
int m_haloBuffer
Halo buffer for particle deposition.
Definition: CD_TracerParticleSolver.H:369
TracerParticleSolver & operator=(const TracerParticleSolver &a_other)=delete
Disallowed assignment operator.
ParticleContainer< P > m_particles
Computational particles.
Definition: CD_TracerParticleSolver.H:394
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
phase::which_phase m_phase
Phase where this solver lives.
Definition: CD_TracerParticleSolver.H:343
virtual void setName(const std::string &a_name) noexcept
Set the solver name.
Definition: CD_TracerParticleSolverImplem.H:209
TracerParticleSolver & operator=(const TracerParticleSolver &&a_other)=delete
Disallowed move assignment operator.
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
CoarseFineDeposition m_coarseFineDeposition
Coarse-fine deposition strategy.
Definition: CD_TracerParticleSolver.H:323
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
bool m_volumeScale
Do volumetric scaling when depositing (or not).
Definition: CD_TracerParticleSolver.H:384
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
std::string m_realm
Realm where this solver lives.
Definition: CD_TracerParticleSolver.H:328
virtual void preRegrid(const int a_lbase, const int a_oldFinestLevel)
Perform pre-regrid operations.
Definition: CD_TracerParticleSolverImplem.H:307
DepositionType m_interpolation
Deposition type when interpolating to particles.
Definition: CD_TracerParticleSolver.H:318
bool m_plotWeight
Hook for adding weight to plot file.
Definition: CD_TracerParticleSolver.H:374
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
int m_verbosity
Verbosity level.
Definition: CD_TracerParticleSolver.H:363
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
DepositionType m_deposition
Deposition type when depositing particles to grid.
Definition: CD_TracerParticleSolver.H:313
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
Real m_dt
Time step.
Definition: CD_TracerParticleSolver.H:348
TracerParticleSolver(const TracerParticleSolver &a_other)=delete
Disallowed constructor.
virtual void allocate()
Allocate storage for this solver.
Definition: CD_TracerParticleSolverImplem.H:195
std::string m_name
Solver name.
Definition: CD_TracerParticleSolver.H:333
bool m_plotVelocity
Hook for adding velocity field to plot file.
Definition: CD_TracerParticleSolver.H:379
int m_timeStep
Time step.
Definition: CD_TracerParticleSolver.H:358
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
std::string m_className
Class name.
Definition: CD_TracerParticleSolver.H:338
virtual void parseOptions()
Parse solver options.
Definition: CD_TracerParticleSolverImplem.H:63
TracerParticleSolver(const TracerParticleSolver &&a_other)=delete
Disallowed move constructor.
virtual void setVelocity(const EBAMRCellData &a_velocityField)
Set the tracer particle velocity field.
Definition: CD_TracerParticleSolverImplem.H:295
Real m_time
Time.
Definition: CD_TracerParticleSolver.H:353
virtual void interpolateWeight(const EBAMRCellData &a_scalar) noexcept
Interpolate a scalar field onto the particle weight.
Definition: CD_TracerParticleSolverImplem.H:380
EBAMRCellData m_velocityField
Mesh-based velocity field. Must be set through setVelocity.
Definition: CD_TracerParticleSolver.H:389
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