13#ifndef CD_MESHODESOLVERIMPLEM_H
14#define CD_MESHODESOLVERIMPLEM_H
25#include <CD_NamespaceHeader.H>
29 : m_verbosity(-1), m_name(
"MeshODESolver"), m_className(
"MeshODESolver"), m_realm(
Realm::Primal), m_phase(
phase::gas)
31 CH_TIME(
"MeshODESolver::MeshODESolver()");
39 CH_TIME(
"MeshODESolver::MeshODESolver(AMR)");
47 CH_TIME(
"MeshODESolver::~MeshODESolver");
54 CH_TIME(
"MeshODESolver::setAmr");
55 if (m_verbosity > 5) {
56 pout() << m_name +
"::setAmr" <<
endl;
66 CH_TIME(
"MeshODESolver::parseOptions");
71 pp.get(
"use_regrid_slopes", m_regridSlopes);
84 CH_TIME(
"MeshODESolver::parseRuntimeOptions()");
92 pp.get(
"use_regrid_slopes", m_regridSlopes);
101 CH_TIME(
"MeshODESolver::parsePlotVariables()");
110 const int num =
pp.countval(
"plt_vars");
116 for (
int i = 0;
i <
num;
i++) {
117 if (
str[
i] ==
"phi") {
120 else if (
str[
i] ==
"rhs") {
131 CH_TIME(
"MeshODESolver::getPhi()");
143 CH_TIME(
"MeshODESolver::getPhi()");
155 CH_TIME(
"MeshODESolver::getRHS()");
167 CH_TIME(
"MeshODESolver::getRHS()");
179 CH_TIME(
"MeshODESolver::setPhi(std::function, size_t)");
180 if (m_verbosity > 5) {
181 pout() << m_name +
"::setPhi(std::function, size_t)" <<
endl;
189 m_amr->getMultiCutVofIterator(m_realm, m_phase));
196 CH_TIME(
"MeshODESolver::setPhi(std::function)");
197 if (m_verbosity > 5) {
198 pout() << m_name +
"::setPhi(std::function)" <<
endl;
201 constexpr int comp = 0;
203 for (
int lvl = 0;
lvl <= m_amr->getFinestLevel();
lvl++) {
212#pragma omp parallel for schedule(runtime)
232 for (
size_t i = 0;
i <
N;
i++) {
249 for (
size_t i = 0;
i <
N;
i++) {
271 CH_TIME(
"MeshODESolver::setRHS(std::function, size_t)");
272 if (m_verbosity > 5) {
273 pout() << m_name +
"::setRHS(std::function, size_t)" <<
endl;
281 m_amr->getMultiCutVofIterator(m_realm, m_phase));
288 CH_TIME(
"MeshODESolver::computeRHS(std::function<std::array<Real, N>(...)>)");
289 if (m_verbosity > 5) {
290 pout() << m_name +
"::computeRHS(std::function<std::array<Real, N>(...)>)" <<
endl;
300 CH_TIME(
"MeshODESolver::computeRHS(EBAMRCellData, std::function<std::array<Real, N>(...)>)");
301 if (m_verbosity > 5) {
302 pout() << m_name +
"::computeRHS(EBAMRCellData, std::function<std::array<Real, N>(...)>)" <<
endl;
305 constexpr int comp = 0;
307 for (
int lvl = 0;
lvl <= m_amr->getFinestLevel();
lvl++) {
314#pragma omp parallel for schedule(runtime)
335 for (
size_t i = 0;
i <
N;
i++) {
344 for (
size_t i = 0;
i <
N;
i++) {
359 for (
size_t i = 0;
i <
N;
i++) {
368 for (
size_t i = 0;
i <
N;
i++) {
393 CH_TIME(
"MeshODESolver::allocate()");
406 CH_TIME(
"MeshODESolver::preRegrid(int, int)");
407 if (m_verbosity > 5) {
408 pout() << m_name +
"::preRegrid(int, int)" <<
endl;
411 m_amr->
allocate(m_cache, m_realm, m_phase,
N);
412 m_amr->copyData(m_cache, m_phi);
421 CH_TIME(
"MeshODESolver::regrid(int, int, int)");
422 if (m_verbosity > 5) {
423 pout() << m_name +
"::regrid(int, int, int)" <<
endl;
429 : EBCoarseToFineInterp::Type::ConservativePWC;
433 m_amr->conservativeAverage(m_phi, m_realm, m_phase);
434 m_amr->interpGhost(m_phi, m_realm, m_phase);
443 CH_TIME(
"MeshODESolver::getRealm()");
455 CH_TIME(
"MeshODESolver::getName()");
467 CH_TIME(
"MeshODESolver::setName()");
468 if (m_verbosity > 5) {
469 pout() << m_name +
"::setName()" <<
endl;
479 CH_TIME(
"MeshODESolver::registerOperators()");
495 CH_TIME(
"MeshODESolver::setRealm(std::string)");
496 if (m_verbosity > 5) {
497 pout() << m_name +
"::setRealm(std::string)" <<
endl;
507 CH_TIME(
"MeshODESolver::setPhase(phase)");
508 if (m_verbosity > 5) {
509 pout() << m_name +
"::setPhase(phase)" <<
endl;
519 CH_TIME(
"MeshODESolver::setVerbosity(int)");
520 if (m_verbosity > 5) {
521 pout() << m_name +
"::setVerbosity(int)" <<
endl;
531 CH_TIME(
"MeshODESolver::setTime(int, Real, Real)");
532 if (m_verbosity > 5) {
533 pout() << m_name +
"::setTime(int, Real, Real)" <<
endl;
545 CH_TIME(
"MeshODESolver::writePlotFile()");
575 DischargeIO::writeEBHDF5(
fname,
581 m_amr->getRefinementRatios(),
585 m_amr->getFinestLevel() + 1,
594 CH_TIME(
"MeshODESolver::getNumberOfPlotVariables()");
616 CH_TIME(
"MeshODESolver::getPlotVariableNames()");
624 for (
size_t i = 0;
i <
N;
i++) {
630 for (
size_t i = 0;
i <
N;
i++) {
643 const int a_level)
const noexcept
645 CH_TIME(
"MeshODESolver::writePlotData");
646 if (m_verbosity > 5) {
647 pout() << m_name +
"::writePlotData" <<
endl;
671 CH_TIMER(
"MeshODESolver::writeData::allocate",
t1);
672 CH_TIMER(
"MeshODESolver::writeData::local_copy",
t2);
673 CH_TIMER(
"MeshODESolver::writeData::interp_ghost",
t3);
674 CH_TIMER(
"MeshODESolver::writeData::interp_centroid",
t4);
675 CH_TIMER(
"MeshODESolver::writeData::final_copy",
t5);
676 if (m_verbosity > 5) {
677 pout() << m_name +
"::writeData" <<
endl;
723 CH_TIME(
"MeshODESolver::writeCheckpointLevel(HDF5Handle, int)");
724 if (m_verbosity > 5) {
725 pout() << m_name +
"::writeCheckpointLevel(HDF5Handle, int)" <<
endl;
738 CH_TIME(
"MeshODESolver::writeCheckpointLevel(HDF5Handle, int)");
739 if (m_verbosity > 5) {
740 pout() << m_name +
"::writeCheckpointLevel(HDF5Handle, int)" <<
endl;
746 m_amr->getGrids(m_realm)[
a_level],
752 m_amr->getGrids(m_realm)[
a_level],
758#include <CD_NamespaceFooter.H>
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:24
static void setCoveredValue(EBAMRCellData &a_lhs, const EBAMRCellData &a_coveredMask, const int a_comp, const Real a_value)
Set value in covered cells. Does specified component.
Definition CD_DataOps.cpp:2655
Type
Type of interpolation methods supported. PWC = Piecewise constant, ignoring the embedded boundary....
Definition CD_EBCoarseToFineInterp.H:43
Class for solving dy/dt = f on an AMR hierarchy.
Definition CD_MeshODESolver.H:29
virtual std::string getRealm() const noexcept
Get the realm where this solver is registered.
Definition CD_MeshODESolverImplem.H:441
virtual void setRHS(const std::function< Real(const RealVect &a_pos)> &a_srcFunc, size_t a_comp) noexcept
Set right-hand side for specified component.
Definition CD_MeshODESolverImplem.H:269
virtual Vector< std::string > getPlotVariableNames() const noexcept
Get output plot names.
Definition CD_MeshODESolverImplem.H:614
virtual void writePlotFile() const noexcept
Write plot file.
Definition CD_MeshODESolverImplem.H:543
std::function< std::array< Real, N >(const std::array< Real, N > &, const Real)> RHSFunction
Alias for right-hand side.
Definition CD_MeshODESolver.H:34
virtual void writePlotData(LevelData< EBCellFAB > &a_output, int &a_icomp, const std::string &a_outputRealm, int a_level) const noexcept
Write plot data to output holder.
Definition CD_MeshODESolverImplem.H:640
virtual void setName(const std::string &a_name) noexcept
Set solver name.
Definition CD_MeshODESolverImplem.H:465
virtual void writeData(LevelData< EBCellFAB > &a_output, int &a_comp, const EBAMRCellData &a_data, std::string a_outputRealm, int a_level, bool a_interpToCentroids, bool a_interpGhost) const noexcept
Write data to output. Convenience function.
Definition CD_MeshODESolverImplem.H:661
virtual void parseRuntimeOptions() noexcept
Parse run-time configurable class options.
Definition CD_MeshODESolverImplem.H:82
MeshODESolver()
Default constructor. Must subsequently set everything through public member functions.
Definition CD_MeshODESolverImplem.H:28
virtual void setPhi(const std::function< Real(const RealVect &a_pos)> &a_phiFunc, size_t a_comp) noexcept
Set phi for a specific component.
Definition CD_MeshODESolverImplem.H:177
virtual void registerOperators() const noexcept
Register operators for AMR operations.
Definition CD_MeshODESolverImplem.H:477
EBAMRCellData & getPhi() noexcept
Get the solution vector (left-hand side of equation).
Definition CD_MeshODESolverImplem.H:129
virtual ~MeshODESolver()
Destructor.
Definition CD_MeshODESolverImplem.H:45
virtual void setRealm(const std::string &a_realm) noexcept
Set the realm for this solver.
Definition CD_MeshODESolverImplem.H:493
virtual int getNumberOfPlotVariables() const noexcept
Get number of output fields.
Definition CD_MeshODESolverImplem.H:592
virtual void preRegrid(int a_lbase, int a_oldFinestLevel) noexcept
Perform pre-regrid operations.
Definition CD_MeshODESolverImplem.H:404
virtual void parseOptions() noexcept
Parse class options.
Definition CD_MeshODESolverImplem.H:64
virtual void parsePlotVariables() noexcept
Parse plot variables.
Definition CD_MeshODESolverImplem.H:99
EBAMRCellData & getRHS() noexcept
Get the right-hand side vector.
Definition CD_MeshODESolverImplem.H:153
virtual void setAmr(const RefCountedPtr< AmrMesh > &a_amrMesh) noexcept
Set AmrMesh.
Definition CD_MeshODESolverImplem.H:52
virtual void setVerbosity(int a_verbosity) noexcept
Set verbosity.
Definition CD_MeshODESolverImplem.H:517
virtual void setPhase(phase::which_phase a_phase) noexcept
Set phase.
Definition CD_MeshODESolverImplem.H:505
virtual void allocate() noexcept
Allocate internal storage.
Definition CD_MeshODESolverImplem.H:391
virtual void regrid(int a_lmin, int a_oldFinestLevel, int a_newFinestLevel) noexcept
Regrid this solver.
Definition CD_MeshODESolverImplem.H:419
virtual std::string getName() const noexcept
Get solver name.
Definition CD_MeshODESolverImplem.H:453
virtual void setTime(int a_step, Real a_time, Real a_dt) noexcept
Set the time for this solver.
Definition CD_MeshODESolverImplem.H:529
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:286
Class for holding multifluid Realms, which are the Realms that we actually use.
Definition CD_Realm.H:34
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
void parsePlotVariables()
Parse plot variables.
Definition CD_TracerParticleSolverImplem.H:148
phase::which_phase m_phase
Phase where this solver lives.
Definition CD_TracerParticleSolver.H:367
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:26
std::string m_realm
Realm where this solver lives.
Definition CD_TracerParticleSolver.H:352
int m_verbosity
Verbosity level.
Definition CD_TracerParticleSolver.H:387
RefCountedPtr< AmrMesh > m_amr
Handle to AMR mesh.
Definition CD_TracerParticleSolver.H:327
virtual Vector< std::string > getPlotVariableNames() const
Get plot variable names.
Definition CD_TracerParticleSolverImplem.H:482
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:511
Real m_dt
Time step.
Definition CD_TracerParticleSolver.H:372
virtual void allocate()
Allocate storage for this solver.
Definition CD_TracerParticleSolverImplem.H:195
std::string m_name
Solver name.
Definition CD_TracerParticleSolver.H:357
int m_timeStep
Time step.
Definition CD_TracerParticleSolver.H:382
std::string m_className
Class name.
Definition CD_TracerParticleSolver.H:362
Real m_time
Time.
Definition CD_TracerParticleSolver.H:377
virtual int getNumberOfPlotVariables() const
Get the number of plot variables.
Definition CD_TracerParticleSolverImplem.H:461
ALWAYS_INLINE void loop(const Box &a_computeBox, Functor &&kernel)
Launch a C++ kernel over a regular grid with compile-time per-dimension strides.
Definition CD_BoxLoopsImplem.H:39
RealVect position(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:21
Phase names namespace.
Definition CD_MultiFluidIndexSpace.H:28
which_phase
Enumeration of supported phases.
Definition CD_MultiFluidIndexSpace.H:38