21 #ifndef FUB_HYPERBOLIC_SPLIT_LEVEL_INTEGRATOR_HPP
22 #define FUB_HYPERBOLIC_SPLIT_LEVEL_INTEGRATOR_HPP
51 template <
typename LevelIntegrator>
57 static constexpr
int Rank = LevelIntegrator::Rank;
60 :
Base(std::move(integrator)) {}
86 std::pair<int, int> subcycle);
93 template <
typename LevelIntegrator>
95 int fine_level,
int coarse_level)
const {
97 for (
int level = fine_level; level > coarse_level; --level) {
98 refine_ratio *= Base::GetRatioToCoarserLevel(level).max();
103 template <
typename LevelIntegrator>
105 Duration min_dt(std::numeric_limits<double>::max());
106 for (
int level_num = 0; Base::LevelExists(level_num); ++level_num) {
107 int ratio = GetTotalRefineRatio(level_num);
108 min_dt = std::min(min_dt, ratio * Base::ComputeStableDt(level_num));
110 MPI_Comm comm = Base::GetMpiCommunicator();
111 const double local_dt = min_dt.count();
112 double global_min_dt{0};
113 MPI_Allreduce(&local_dt, &global_min_dt, 1, MPI_DOUBLE, MPI_MIN, comm);
117 template <
typename LevelIntegrator>
120 int this_level,
Duration dt, std::pair<int, int> subcycle) {
127 int ratio = GetTotalRefineRatio(error.
level);
135 const int next_level = this_level + 1;
136 if (Base::LevelExists(next_level)) {
137 Base::ResetCoarseFineFluxes(next_level, this_level);
138 const int refine_ratio = Base::GetRatioToCoarserLevel(next_level).max();
139 for (
int r = 0; r < refine_ratio; ++r) {
141 AdvanceLevel(next_level, dt / refine_ratio, {r, refine_ratio});
143 return scale_dt_on_error(result);
149 Base::AdvanceLevelNonRecursively(this_level, dt, subcycle);
151 return scale_dt_on_error(result);
153 if (Base::LevelExists(next_level)) {
154 Base::ApplyFluxCorrection(next_level, this_level, dt);
158 if (Base::LevelExists(next_level)) {
159 Base::CoarsenConservatively(next_level, this_level);
167 Base::CopyScratchToData(this_level);
175 return scale_dt_on_error(result);
180 template <
typename LevelIntegrator>
183 return AdvanceLevel(0, dt, {0, 1});
Definition: SolverFacade.hpp:29
This Level Integrator applies a very general AMR integration scheme in context of dimensional splitti...
Definition: SubcycleFineFirstSolver.hpp:52
int GetTotalRefineRatio(int fine_level, int coarse_level=0) const
Returns the total refinement ratio between specified coarse to fine level number.
Definition: SubcycleFineFirstSolver.hpp:94
SubcycleFineFirstSolver(const LevelIntegrator &integrator)
Definition: SubcycleFineFirstSolver.hpp:62
SubcycleFineFirstSolver(LevelIntegrator &&integrator)
Definition: SubcycleFineFirstSolver.hpp:59
Result< void, TimeStepTooLarge > AdvanceHierarchy(Duration dt)
Definition: SubcycleFineFirstSolver.hpp:182
Result< void, TimeStepTooLarge > AdvanceLevel(int level_number, Duration dt, std::pair< int, int > subcycle)
Advance a specified patch level and all finer levels by time dt.
Definition: SubcycleFineFirstSolver.hpp:119
Duration ComputeStableDt()
Returns a stable time step size for the coarsest refinement level.
Definition: SubcycleFineFirstSolver.hpp:104
static constexpr int Rank
Definition: SubcycleFineFirstSolver.hpp:57
void CompleteFromCons(Equation &&equation, Complete< std::decay_t< Equation >> &complete, const Conservative< std::decay_t< Equation >> &cons)
Definition: CompleteFromCons.hpp:42
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
std::chrono::duration< double > Duration
Definition: Duration.hpp:31
boost::outcome_v2::result< T, E > Result
Definition: outcome.hpp:32