22 #ifndef FUB_SAMRAI_INTEGRATOR_CONTEXT_HPP
23 #define FUB_SAMRAI_INTEGRATOR_CONTEXT_HPP
29 #include "fub/counter/CounterRegistry.hpp"
34 #include <SAMRAI/xfer/CoarsenAlgorithm.h>
35 #include <SAMRAI/xfer/RefineAlgorithm.h>
44 class IntegratorContext;
62 int flux_ghost_cell_width);
64 template <
typename Method>
125 [[nodiscard]] const SAMRAI::hier::PatchLevel&
GetPatchLevel(
int level) const;
137 [[nodiscard]] std::ptrdiff_t
GetCycles(
int level = 0) const;
140 [[nodiscard]] const SAMRAI::geom::CartesianGridGeometry&
236 [[nodiscard]] const std::shared_ptr<CounterRegistry>&
263 std::vector<std::shared_ptr<SAMRAI::xfer::RefinePatchStrategy>>
boundaries_;
This is a polymorphic value type that wraps any BoundaryCondition object.
Definition: AnyBoundaryCondition.hpp:55
Definition: SAMRAI/GriddingAlgorithm.hpp:53
This class is used by the HypebrolicSplitLevelIntegrator and delegates AMR related tasks to the AMReX...
Definition: SAMRAI/IntegratorContext.hpp:52
std::shared_ptr< CoarsenAlgorithm > coarsen_fluxes_
Definition: SAMRAI/IntegratorContext.hpp:255
void SetCycles(std::ptrdiff_t cycle, int level)
Sets the cycle count for a specific level number and direction.
SAMRAI::xfer::CoarsenSchedule CoarsenSchedule
Definition: SAMRAI/IntegratorContext.hpp:252
span< const int > GetScratchIds() const
Returns the MultiFab associated with level data on the specifed level number.
IntegratorContext & operator=(const IntegratorContext &)=default
Deeply copies a context and all its distributed data for all MPI ranks.
std::ptrdiff_t GetCycles(int level=0) const
Returns the current number of cycles for data at the specified refinement level and direction.
void CoarsenConservatively(int fine, int coarse)
Coarsen scratch data from a fine level number to a coarse level number.
void ResetHierarchyConfiguration(std::shared_ptr< GriddingAlgorithm > gridding)
Replaces the underlying gridding algorithm with the specified one.
const PatchHierarchy & GetPatchHierarchy() const noexcept
Returns a reference to const PatchHierarchy which is a member of the GriddingAlgorithm.
const SAMRAI::geom::CartesianGridGeometry & GetGeometry(int level) const
Returns the geometry object for the specified refinement level.
std::shared_ptr< CoarsenAlgorithm > coarsen_scratch_
Definition: SAMRAI/IntegratorContext.hpp:256
IntegratorContext(std::shared_ptr< GriddingAlgorithm > gridding, HyperbolicMethod method, AuxialiaryDataDescription aux_desc)
Constructs a context object from given a gridding algorithm and a numerical method.
SAMRAI::xfer::RefineSchedule RefineSchedule
Definition: SAMRAI/IntegratorContext.hpp:250
IntegratorContext(const IntegratorContext &)=default
Deeply copies a context and all its distributed data for all MPI ranks.
void ResetCoarseFineFluxes(int fine, int coarse)
Resets all accumulates fluxes to zero.
Result< void, TimeStepTooLarge > PostAdvanceLevel(int level_num, Duration dt, std::pair< int, int > subcycle)
Increases the internal time stamps and cycle counters for the specified level number and direction.
int ghost_cell_width_
Definition: SAMRAI/IntegratorContext.hpp:240
std::vector< std::shared_ptr< CoarsenSchedule > > coarsen_fluxes_schedule_
Definition: SAMRAI/IntegratorContext.hpp:261
static AuxialiaryDataDescription RegisterVariables(const DataDescription &desc, int scratch_ghost_cell_width, int flux_ghost_cell_width)
SAMRAI::hier::PatchLevel & GetPatchLevel(int level)
Returns the MultiFab associated with level data on the specifed level number.
span< const int > GetFluxIds() const
Returns the MultiFab associated with level data on the specifed level number.
std::vector< std::shared_ptr< CoarsenSchedule > > coarsen_scratch_schedule_
Definition: SAMRAI/IntegratorContext.hpp:260
SAMRAI::xfer::RefineAlgorithm RefineAlgorithm
Definition: SAMRAI/IntegratorContext.hpp:249
void AccumulateCoarseFineFluxes(int level, double time_scale, Direction dir)
Accumulate fluxes on the coarse fine interfaces for a specified fine level number.
std::vector< std::shared_ptr< RefineSchedule > > fill_scratch_two_level_schedule_
Definition: SAMRAI/IntegratorContext.hpp:258
bool LevelExists(int level) const noexcept
Returns true if the data exists for the specified level number.
void ApplyFluxCorrection(int fine, int coarse, Duration dt)
Replace the coarse fluxes by accumulated fine fluxes on the coarse fine interfaces.
Duration GetTimePoint(int level=0) const
Returns the current time level for data at the specified refinement level and direction.
SAMRAI::xfer::CoarsenAlgorithm CoarsenAlgorithm
Definition: SAMRAI/IntegratorContext.hpp:251
std::vector< Duration > time_points_
Definition: SAMRAI/IntegratorContext.hpp:245
void SetTimePoint(Duration t, int level)
Sets the time point for a specific level number and direction.
Duration ComputeStableDt(int level, Direction dir)
Returns a estimate for a stable time step size which can be taken for specified level number in direc...
IntegratorContext(IntegratorContext &&) noexcept=default
Constructs a context object from given a gridding algorithm and a numerical method.
void FillGhostLayerTwoLevels(int level, int coarse)
Fills the ghost layer of the scratch data and interpolates in the coarse fine layer.
const AnyBoundaryCondition & GetBoundaryCondition() const
Returns the current boundary condition for the specified level.
std::vector< std::shared_ptr< RefineSchedule > > fill_scratch_one_level_schedule_
Definition: SAMRAI/IntegratorContext.hpp:259
HyperbolicMethod method_
Definition: SAMRAI/IntegratorContext.hpp:242
span< const int > GetDataIds() const
Returns the MultiFab associated with level data on the specifed level number.
void ComputeNumericFluxes(int level, Duration dt, Direction dir)
Fill the flux MultiFab with numeric fluxes based on current states in scratch.
static AuxialiaryDataDescription RegisterVariables(const DataDescription &desc, const Method &method)
Definition: SAMRAI/IntegratorContext.hpp:66
std::shared_ptr< RefineAlgorithm > fill_scratch_
Definition: SAMRAI/IntegratorContext.hpp:254
int PreAdvanceLevel(int level_num, Duration dt, std::pair< int, int > subcycle)
On each first subcycle this will regrid the data if neccessary.
int GetRatioToCoarserLevel(int level, Direction dir) const noexcept
Returns the refinement ratio in the specified direction.
const std::shared_ptr< GriddingAlgorithm > & GetGriddingAlgorithm() const noexcept
Returns a shared pointer to the underlying GriddingAlgorithm which owns the simulation.
void UpdateConservatively(int level, Duration dt, Direction dir)
Apply a conservative time update for each conservative variable on the specified level number and dir...
std::vector< std::ptrdiff_t > cycles_
Definition: SAMRAI/IntegratorContext.hpp:247
std::shared_ptr< GriddingAlgorithm > gridding_
Definition: SAMRAI/IntegratorContext.hpp:241
MPI_Comm GetMpiCommunicator() const noexcept
Returns the MPI communicator which is associated with this context.
void FillGhostLayerSingleLevel(int level)
Fills the ghost layer of the scratch data and does nothing in the coarse fine layer.
std::vector< std::shared_ptr< SAMRAI::xfer::RefinePatchStrategy > > boundaries_
Definition: SAMRAI/IntegratorContext.hpp:263
AuxialiaryDataDescription aux_desc_
Definition: SAMRAI/IntegratorContext.hpp:243
void ApplyBoundaryCondition(int level, Direction dir)
On each first subcycle this will regrid the data if neccessary.
const std::shared_ptr< CounterRegistry > & GetCounterRegistry() const noexcept
void CopyDataToScratch(int level)
std::vector< Duration > regrid_time_points_
Definition: SAMRAI/IntegratorContext.hpp:246
void CopyScratchToData(int level)
void CompleteFromCons(int level, Duration dt)
Reconstruct complete state variables from conservative ones.
Definition: SAMRAI/PatchHierarchy.hpp:69
A span is a view over a contiguous sequence of objects, the storage of which is owned by some other o...
Definition: span.hpp:81
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
std::chrono::duration< double > Duration
Definition: Duration.hpp:31
Direction
This is a type safe type to denote a dimensional split direction.
Definition: Direction.hpp:30
boost::outcome_v2::result< T, E > Result
Definition: outcome.hpp:32
Definition: HyperbolicMethod.hpp:150
Definition: RegisterVariables.hpp:35
Definition: SAMRAI/IntegratorContext.hpp:54
std::vector< int > scratch_ids
Definition: SAMRAI/IntegratorContext.hpp:55
std::vector< int > coarse_fine_ids
Definition: SAMRAI/IntegratorContext.hpp:57
std::vector< int > flux_ids
Definition: SAMRAI/IntegratorContext.hpp:56