21 #ifndef FUB_AMREX_INTEGRATOR_CONTEXT_HPP
22 #define FUB_AMREX_INTEGRATOR_CONTEXT_HPP
29 #include <AMReX_FluxRegister.H>
30 #include <AMReX_MultiFab.H>
41 class IntegratorContext;
80 [[nodiscard]]
int Rank() const noexcept;
104 [[nodiscard]] ::amrex::MultiFab&
GetData(
int level);
105 [[nodiscard]] const ::amrex::MultiFab&
GetData(
int level) const;
110 [[nodiscard]] const ::amrex::MultiFab&
GetScratch(
int level) const;
115 [[nodiscard]] const ::amrex::MultiFab&
GetFluxes(
int level,
124 [[nodiscard]] std::ptrdiff_t
GetCycles(
int level = 0) const;
130 [[nodiscard]] const std::shared_ptr<CounterRegistry>&
187 std::pair<
int,
int> subcycle);
256 ::amrex::MultiFab scratch;
261 std::array<::amrex::MultiFab, AMREX_SPACEDIM> fluxes;
266 ::amrex::FluxRegister coarse_fine;
270 std::ptrdiff_t cycles{};
This is a polymorphic value type that wraps any BoundaryCondition object.
Definition: AnyBoundaryCondition.hpp:55
Definition: AMReX/Geometry.hpp:30
This class modifies and initializes a PatchLevel in a PatchHierarchy.
Definition: AMReX/GriddingAlgorithm.hpp:60
This class is used by the HypebrolicSplitLevelIntegrator and delegates AMR related tasks to the AMReX...
Definition: AMReX/IntegratorContext.hpp:49
IntegratorContext(std::shared_ptr< GriddingAlgorithm > gridding, HyperbolicMethod method, int cell_gcw, int face_gcw)
Constructs a context object from given a gridding algorithm and a numerical method.
std::ptrdiff_t GetCycles(int level=0) const
Returns the current number of cycles for data at the specified refinement level and direction.
HyperbolicMethod method_
Definition: AMReX/IntegratorContext.hpp:277
MPI_Comm GetMpiCommunicator() const noexcept
Returns the MPI communicator which is associated with this context.
void CopyScratchToData(int level_num)
Updates time point and cycle counter for the patch hierarchy.
void SetTimePoint(Duration t, int level)
Sets the time point for a specific level number and direction.
void ApplyBoundaryCondition(int level, Direction dir)
Applies the boundary condition for the scratch space on level level in direcition dir.
const std::shared_ptr< GriddingAlgorithm > & GetGriddingAlgorithm() const noexcept
Returns a shared pointer to the underlying GriddingAlgorithm which owns the simulation.
::amrex::MultiFab & GetScratch(int level)
Returns the MultiFab associated with level data with ghost cells on the specifed level number and dir...
void PostAdvanceHierarchy()
Updates time point and cycle counter for the patch hierarchy.
void CompleteFromCons(int level, Duration dt)
Reconstruct complete state variables from conservative ones.
int cell_ghost_cell_width_
Definition: AMReX/IntegratorContext.hpp:273
const std::shared_ptr< CounterRegistry > & GetCounterRegistry() const noexcept
Returns a shared pointer to the counter registry.
int face_ghost_cell_width_
Definition: AMReX/IntegratorContext.hpp:274
::amrex::MultiFab & GetFluxes(int level, Direction dir)
Returns the MultiFab associated with flux data on the specifed level number and direction.
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.
void SetCycles(std::ptrdiff_t cycle, int level)
Sets the cycle count for a specific level number and direction.
IntegratorContext(IntegratorContext &&) noexcept=default
Constructs a context object from given a gridding algorithm and a numerical method.
IntegratorContext & operator=(const IntegratorContext &)
Deeply copies a context and all its distributed data for all MPI ranks.
void CoarsenConservatively(int fine, int coarse)
Coarsen scratch data from a fine level number to a coarse level number.
void AccumulateCoarseFineFluxes(int level, double time_scale, Direction dir)
Accumulate fluxes on the coarse fine interfaces for a specified fine level number.
Duration GetTimePoint(int level=0) const
Returns the current time level for data at the specified refinement level and direction.
void CopyDataToScratch(int level_num)
Updates time point and cycle counter for the patch hierarchy.
int PreAdvanceLevel(int level_num, Duration dt, std::pair< int, int > subcycle)
On each first subcycle this will regrid the data if neccessary.
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...
std::vector< LevelData > data_
Definition: AMReX/IntegratorContext.hpp:276
void ApplyFluxCorrection(int fine, int coarse, Duration dt)
Replace the coarse fluxes by accumulated fine fluxes on the coarse fine interfaces.
const PatchHierarchy & GetPatchHierarchy() const noexcept
Returns a reference to const PatchHierarchy which is a member of the GriddingAlgorithm.
void ResetCoarseFineFluxes(int fine, int coarse)
Resets all accumulates fluxes to zero.
void UpdateConservatively(int level, Duration dt, Direction dir)
Apply a conservative time update for each conservative variable on the specified level number and dir...
::amrex::MultiFab & GetData(int level)
Returns the MultiFab associated with level data on the specifed level number.
IntegratorContext(std::shared_ptr< GriddingAlgorithm > gridding, HyperbolicMethod method)
Constructs a context object from given a gridding algorithm and a numerical method.
IntegratorContext(const IntegratorContext &)
Deeply copies a context and all its distributed data for all MPI ranks.
int Rank() const noexcept
Returns a shared pointer to the underlying GriddingAlgorithm which owns the simulation.
void FillGhostLayerSingleLevel(int level, AnyBoundaryCondition &bc)
Fills the ghost layer of the scratch data and does nothing in the coarse fine layer.
virtual void ResetHierarchyConfiguration(std::shared_ptr< GriddingAlgorithm > gridding)
Replaces the underlying gridding algorithm with the specified one.
bool LevelExists(int level) const noexcept
Returns true if the data exists for the specified level number.
const ::amrex::Geometry & GetGeometry(int level) const
Returns the geometry object for the specified refinement level.
bool count_per_level
Definition: AMReX/IntegratorContext.hpp:243
int GetRatioToCoarserLevel(int level, Direction dir) const noexcept
Returns the refinement ratio in the specified direction.
void FillGhostLayerTwoLevels(int level, AnyBoundaryCondition &fbc, int coarse, AnyBoundaryCondition &cbc)
Fills the ghost layer of the scratch data and interpolates in the coarse fine layer.
void ComputeNumericFluxes(int level, Duration dt, Direction dir)
Fill the flux MultiFab with numeric fluxes based on current states in scratch.
std::shared_ptr< GriddingAlgorithm > gridding_
Definition: AMReX/IntegratorContext.hpp:275
The PatchHierarchy holds simulation data on multiple refinement levels.
Definition: AMReX/PatchHierarchy.hpp:156
The amrex namespace.
Definition: AverageState.hpp:33
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
This class holds auxiliary data on each refinement level.
Definition: AMReX/IntegratorContext.hpp:247
LevelData(const LevelData &other)=delete
LevelData & operator=(const LevelData &other)=delete
LevelData(LevelData &&) noexcept=default