12 #ifndef CD_ItoLayoutImplem_H
13 #define CD_ItoLayoutImplem_H
21 #include <CD_NamespaceHeader.H>
26 this->define(a_species);
54 for (
auto solver_it = this->iterator(); solver_it.ok(); ++solver_it) {
55 solver_it()->setRealm(m_realm);
71 iter()->parseOptions();
80 iter()->parseRuntimeOptions();
97 m_solvers.push_back(a_solver);
105 iter()->interpolateVelocities();
114 iter()->preRegrid(a_lbase, a_finestLevel);
123 iter()->initialData();
132 iter()->regrid(a_lmin, a_oldFinestLevel, a_newFinestLevel);
141 iter()->registerOperators();
150 iter()->setAmr(a_amrMesh);
159 iter()->setComputationalGeometry(a_computationalGeometry);
168 iter()->setPhase(a_phase);
177 iter()->setVerbosity(a_verbosity);
186 iter()->setTime(a_step, a_time, a_dt);
195 iter()->organizeParticlesByCell(a_whichContainer);
204 iter()->organizeParticlesByPatch(a_whichContainer);
213 iter()->makeSuperparticles(a_whichContainer, a_ppc);
222 iter()->makeSuperparticles(a_whichContainer, a_ppc);
230 this->depositParticles(ItoSolver::WhichContainer::Bulk);
238 iter()->depositParticles(a_whichContainer);
246 this->remap(ItoSolver::WhichContainer::Bulk);
254 iter()->remap(a_whichContainer);
263 for (
auto iter = this->iterator(); iter.ok(); ++iter) {
264 ret += iter()->getNumParticles(a_whichContainer, a_localOnly);
277 const Real thisDt = iter()->computeDt();
291 const Real thisDt = iter()->computeAdvectiveDt();
305 const Real thisDt = iter()->computeHopDt(a_maxCellsToMove);
319 const Real thisDt = iter()->computeDiffusiveDt();
327 Vector<RefCountedPtr<T>>&
334 Vector<RefCountedPtr<ItoSpecies>>&
341 Vector<EBAMRCellData*>
344 Vector<EBAMRCellData*> ret(m_solvers.size(),
nullptr);
346 ret[iter.index()] = &(iter()->getVelocityFunction());
353 Vector<EBAMRCellData*>
356 Vector<EBAMRCellData*> ret(m_solvers.size(),
nullptr);
358 ret[iter.index()] = &(iter()->getPhi());
365 Vector<EBAMRCellData*>
368 Vector<EBAMRCellData*> ret(m_solvers.size(),
nullptr);
370 ret[iter.index()] = &(iter()->getDiffusionFunction());
377 Vector<EBAMRCellData*>
380 Vector<EBAMRCellData*> ret(m_solvers.size(),
nullptr);
382 ret[iter.index()] = &(iter()->getMobilityFunction());
389 Vector<ParticleContainer<ItoParticle>*>
392 Vector<ParticleContainer<ItoParticle>*> ret(m_solvers.size(),
nullptr);
394 ret[iter.index()] = &(iter()->getParticles(a_container));
407 template <
class T,
class S>
411 template <
class T,
class S>
415 template <
class T,
class S>
416 RefCountedPtr<ItoLayout<T>>
420 auto itoLayout = RefCountedPtr<ItoLayout<T>>(
new ItoLayout<T>(a_species));
423 for (
int i = 0; i < a_species.size(); i++) {
424 RefCountedPtr<T> solver = RefCountedPtr<T>(
static_cast<T*
>(
new S()));
425 solver->setSpecies(a_species[i]);
426 solver->setVerbosity(-1);
427 itoLayout->addSolver(solver);
433 #include <CD_NamespaceFooter.H>
Declaration of an iterator class for ItoLayout.
Declaration of a class that holds a set of ItoSolvers.
~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
virtual bool ok()
Ok or not.
Definition: CD_ItoIteratorImplem.H:71
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
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
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.
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
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
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
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
Real max(const Real &a_input) noexcept
Get the maximum of the input, reduced over MPI ranks (in the Chombo communicator)
Definition: CD_ParallelOpsImplem.H:176
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