chombo-discharge
CD_ItoLayout.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_ItoLayout_H
13 #define CD_ItoLayout_H
14 
15 // Our includes
16 #include <CD_ItoSolver.H>
17 #include <CD_NamespaceHeader.H>
18 
19 template <class T>
20 class ItoIterator;
21 
28 template <class T>
29 class ItoLayout
30 {
31 public:
35  ItoLayout() = delete;
36 
41  ItoLayout(const Vector<RefCountedPtr<ItoSpecies>>& a_species);
42 
46  virtual ~ItoLayout();
47 
51  virtual phase::which_phase
52  getPhase() const;
53 
57  virtual ItoIterator<T>
58  iterator();
59 
63  virtual const std::string
64  getRealm() const;
65 
70  virtual void
71  setRealm(const std::string a_realm);
72 
77  virtual void
78  define(const Vector<RefCountedPtr<ItoSpecies>>& a_species);
79 
83  virtual void
84  parseOptions();
85 
89  virtual void
91 
96  virtual void
97  allocate();
98 
103  virtual void
104  addSolver(RefCountedPtr<T>& a_solver);
105 
112  virtual void
113  preRegrid(const int a_lbase, const int a_finestLevel);
114 
119  virtual void
120  initialData();
121 
126  virtual void
128 
134  virtual void
135  depositParticles(const ItoSolver::WhichContainer a_whichContainer);
136 
140  virtual void
141  remap();
142 
147  virtual void
148  remap(const ItoSolver::WhichContainer a_whichContainer);
149 
154  virtual void
156 
163  virtual void
164  regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel);
165 
169  virtual void
171 
176  virtual void
177  setAmr(const RefCountedPtr<AmrMesh>& a_amr);
178 
183  virtual void
184  setComputationalGeometry(const RefCountedPtr<ComputationalGeometry>& a_computationalGeometry);
185 
190  virtual void
191  setPhase(phase::which_phase a_phase);
192 
197  virtual void
198  setVerbosity(const int a_verbosity);
199 
207  virtual void
208  setTime(const int a_step, const Real a_time, const Real a_dt);
209 
214  virtual void
215  organizeParticlesByCell(const ItoSolver::WhichContainer a_whichContainer);
216 
221  virtual void
222  organizeParticlesByPatch(const ItoSolver::WhichContainer a_whichContainer);
223 
229  virtual void
230  makeSuperparticles(const ItoSolver::WhichContainer a_whichContainer, const int a_ppc);
236  virtual void
237  makeSuperparticles(const ItoSolver::WhichContainer a_whichContainer, const Vector<int> a_ppc);
238 
243  virtual Real
244  computeDt();
245 
251  virtual Real
253 
260  virtual Real
261  computeHopDt(const Real a_maxCellsToMove);
262 
267  virtual Real
269 
276  virtual size_t
277  getNumParticles(const ItoSolver::WhichContainer a_ptype, const bool a_localOnly);
278 
283  virtual Vector<RefCountedPtr<T>>&
284  getSolvers();
285 
290  virtual Vector<RefCountedPtr<ItoSpecies>>&
291  getSpecies();
292 
297  virtual Vector<EBAMRCellData*>
299 
304  virtual Vector<EBAMRCellData*>
305  getDensities();
306 
311  virtual Vector<EBAMRCellData*>
313 
318  virtual Vector<EBAMRCellData*>
320 
325  virtual Vector<ParticleContainer<ItoParticle>*>
326  getParticles(const ItoSolver::WhichContainer a_whichContainer);
327 
328 protected:
332  std::string m_realm;
333 
337  Vector<RefCountedPtr<T>> m_solvers;
338 
342  Vector<RefCountedPtr<ItoSpecies>> m_species;
343 
348 
352  phase::which_phase m_phase;
353 
358 };
359 
366 template <class T, class S>
368 {
369 public:
373  ItoFactory();
374 
378  ~ItoFactory();
379 
385  RefCountedPtr<ItoLayout<T>>
386  newLayout(const Vector<RefCountedPtr<ItoSpecies>>& a_species) const;
387 };
388 
389 #include <CD_NamespaceFooter.H>
390 
391 #include <CD_ItoLayoutImplem.H>
392 
393 #endif
Implementation of CD_ItoLayout.H.
Declaration of solver class for Ito diffusion.
Factory class for making ItoLayout.
Definition: CD_ItoLayout.H:368
~ItoFactory()
Destructor (does nothing).
Definition: CD_ItoLayoutImplem.H:412
ItoFactory()
Constructor.
Definition: CD_ItoLayoutImplem.H:408
RefCountedPtr< ItoLayout< T > > newLayout(const Vector< RefCountedPtr< ItoSpecies >> &a_species) const
Factory method which creates a new layout from a set of species. This can do automated casting betwee...
Definition: CD_ItoLayoutImplem.H:417
"Iterator" class for going through solvers in an ItoLayout.
Definition: CD_ItoIterator.H:24
Class for holding a set of ItoSolvers.
Definition: CD_ItoLayout.H:30
virtual Real computeAdvectiveDt()
Compute the classical advection time step for all solvers. This returns dt = dx/max(v) where max(v) t...
Definition: CD_ItoLayoutImplem.H:286
virtual void allocate()
Allocate internals for all solvers.
Definition: CD_ItoLayoutImplem.H:86
virtual void parseRuntimeOptions()
Utility function – parse runtime options for all solvers.
Definition: CD_ItoLayoutImplem.H:77
virtual Vector< EBAMRCellData * > getDiffusionFunctions()
Get all diffusion coefficients.
Definition: CD_ItoLayoutImplem.H:366
virtual Real computeDt()
Compute smallest possible time step.
Definition: CD_ItoLayoutImplem.H:272
virtual void addSolver(RefCountedPtr< T > &a_solver)
Add solver to the list of solvers.
Definition: CD_ItoLayoutImplem.H:95
virtual Vector< EBAMRCellData * > getMobilityFunctions()
Get all mobility mesh functions.
Definition: CD_ItoLayoutImplem.H:378
virtual void makeSuperparticles(const ItoSolver::WhichContainer a_whichContainer, const int a_ppc)
Rearrange the input container particle into new superparticles – this is done for all solvers.
Definition: CD_ItoLayoutImplem.H:210
virtual void setRealm(const std::string a_realm)
Set the realm where the solvers are defined.
Definition: CD_ItoLayoutImplem.H:50
virtual ItoIterator< T > iterator()
Return a fresh iterator. The iterator is a simple random access object that can iterate through the s...
Definition: CD_ItoLayoutImplem.H:36
virtual void setVerbosity(const int a_verbosity)
Set verbosity for each solver.
Definition: CD_ItoLayoutImplem.H:174
phase::which_phase m_phase
Phase where solvers live.
Definition: CD_ItoLayout.H:352
virtual void initialData()
Fill all solvers with initial data.
Definition: CD_ItoLayoutImplem.H:120
virtual void organizeParticlesByCell(const ItoSolver::WhichContainer a_whichContainer)
Sort ItoSolver particles by cell – this is done for all solvers.
Definition: CD_ItoLayoutImplem.H:192
virtual void interpolateVelocities()
Interpolate velocities.
Definition: CD_ItoLayoutImplem.H:102
virtual Real computeDiffusiveDt()
Compute the classical diffusive time step dt = dx*dx/(2*D) where D is the diffusion coefficient (not ...
Definition: CD_ItoLayoutImplem.H:314
virtual void regrid(const int a_lmin, const int a_oldFinestLevel, const int a_newFinestLevel)
Regrid method – calls the regrid method for each solver.
Definition: CD_ItoLayoutImplem.H:129
virtual Vector< RefCountedPtr< ItoSpecies > > & getSpecies()
Get species.
Definition: CD_ItoLayoutImplem.H:335
virtual void parseOptions()
Utility function – parse options for all solvers.
Definition: CD_ItoLayoutImplem.H:68
Vector< RefCountedPtr< ItoSpecies > > m_species
ItoSolver species.
Definition: CD_ItoLayout.H:342
virtual Real computeHopDt(const Real a_maxCellsToMove)
Compute the largest dt which restricts all particles to move less than a_maxCellsToMove.
Definition: CD_ItoLayoutImplem.H:300
virtual void organizeParticlesByPatch(const ItoSolver::WhichContainer a_whichContainer)
Sort ItoSolver particles by patch – this is done for all solvers.
Definition: CD_ItoLayoutImplem.H:201
ItoLayout()=delete
Disallowed weak construction.
Vector< RefCountedPtr< T > > m_solvers
ItoSolver solvers.
Definition: CD_ItoLayout.H:337
virtual Vector< EBAMRCellData * > getVelocityFunctions()
Get all velocity functions.
Definition: CD_ItoLayoutImplem.H:342
virtual Vector< ParticleContainer< ItoParticle > * > getParticles(const ItoSolver::WhichContainer a_whichContainer)
Get particle containers of a particular container type.
Definition: CD_ItoLayoutImplem.H:390
virtual phase::which_phase getPhase() const
Return phase where the solvers are defined.
Definition: CD_ItoLayoutImplem.H:402
std::string m_realm
Realm where all the solvers are registered.
Definition: CD_ItoLayout.H:332
virtual void setTime(const int a_step, const Real a_time, const Real a_dt)
Set time for each solver.
Definition: CD_ItoLayoutImplem.H:183
int m_verbosity
Verbosity level.
Definition: CD_ItoLayout.H:347
virtual ~ItoLayout()
Destructor (does nothing).
Definition: CD_ItoLayoutImplem.H:31
virtual void setComputationalGeometry(const RefCountedPtr< ComputationalGeometry > &a_computationalGeometry)
Set the computational geometry. This sets the computational geometry for each solver.
Definition: CD_ItoLayoutImplem.H:156
virtual void remap()
Remap function – calls remap(ItoSolver::WhichContainer::bulk) for each solver.
Definition: CD_ItoLayoutImplem.H:244
virtual void depositParticles()
All solvers deposit their particles.
Definition: CD_ItoLayoutImplem.H:228
bool m_isDefined
Layout is defined or not.
Definition: CD_ItoLayout.H:357
virtual const std::string getRealm() const
Get the realm name where the solvers are defined.
Definition: CD_ItoLayoutImplem.H:43
virtual void preRegrid(const int a_lbase, const int a_finestLevel)
Utility function which caches states before regrid step.
Definition: CD_ItoLayoutImplem.H:111
virtual void define(const Vector< RefCountedPtr< ItoSpecies >> &a_species)
Define function.
Definition: CD_ItoLayoutImplem.H:61
virtual Vector< RefCountedPtr< T > > & getSolvers()
Get solvers all solvers.
Definition: CD_ItoLayoutImplem.H:328
virtual size_t getNumParticles(const ItoSolver::WhichContainer a_ptype, const bool a_localOnly)
Get total number of particles.
Definition: CD_ItoLayoutImplem.H:260
virtual void setAmr(const RefCountedPtr< AmrMesh > &a_amr)
Set AmrMesh object for each solver.
Definition: CD_ItoLayoutImplem.H:147
virtual void registerOperators()
Register operators. Calls registerOperators for each solver.
Definition: CD_ItoLayoutImplem.H:138
virtual Vector< EBAMRCellData * > getDensities()
Get all densities.
Definition: CD_ItoLayoutImplem.H:354
virtual void setPhase(phase::which_phase a_phase)
Set phase for each solver.
Definition: CD_ItoLayoutImplem.H:165
WhichContainer
Enum class for distinguishing various types of particle containers.
Definition: CD_ItoSolver.H:49