21 #ifndef FUB_AMREX_FLUX_METHOD_HPP
22 #define FUB_AMREX_FLUX_METHOD_HPP
31 #include <AMReX_MultiFab.H>
37 using Equation = std::decay_t<decltype(std::declval<FM&>().GetEquation())>;
38 static const int Rank = Equation::Rank();
54 template <
typename FM>
58 template <
typename Tag,
typename FM>
61 template <
typename Tag,
typename FM>
65 template <
typename T,
typename... Args>
67 decltype(std::declval<T>().ComputeStableDt(std::declval<Args>()...));
69 template <
typename Tag,
typename FM>
74 return flux_method_->ComputeStableDt(context, level, dir);
76 const ::amrex::Geometry& geom = context.
GetGeometry(level);
77 const double dx = geom.CellSize(
int(dir));
78 double min_dt = std::numeric_limits<double>::max();
79 const ::amrex::MultiFab& scratch = context.
GetScratch(level);
81 if constexpr (std::is_base_of<execution::OpenMpTag, Tag>::value) {
82 #if defined(_OPENMP) && defined(AMREX_USE_OMP)
83 #pragma omp parallel reduction(min : min_dt)
85 for (::amrex::MFIter mfi(scratch,
86 ::amrex::IntVect(AMREX_D_DECL(1024000, 8, 8)));
87 mfi.isValid(); ++mfi) {
89 auto&& equation = flux_method_->GetEquation();
91 MakeView<const Complete<Equation>>(scratch[mfi], equation,
94 flux_method_->ComputeStableDt(Tag(), states, dx, dir));
95 min_dt = std::min(min_dt, dt.count());
97 double local_count = min_dt;
100 for (::amrex::MFIter mfi(scratch); mfi.isValid(); ++mfi) {
102 auto&& equation = flux_method_->GetEquation();
104 MakeView<const Complete<Equation>>(scratch[mfi], equation,
107 flux_method_->ComputeStableDt(Tag(), states, dx, dir));
108 min_dt = std::min(min_dt, dt.count());
110 double local_count = min_dt;
116 template <
typename T,
typename... Args>
118 decltype(std::declval<T>().ComputeNumericFluxes(std::declval<Args>()...));
120 template <
typename Tag,
typename FM>
125 flux_method_->ComputeNumericFluxes(context, level, dt, dir);
127 const ::amrex::Geometry& geom = context.
GetGeometry(level);
128 ::amrex::MultiFab& fluxes = context.
GetFluxes(level, dir);
129 const ::amrex::MultiFab& scratch = context.
GetScratch(level);
130 const int dir_v = int(dir);
131 const double dx = geom.CellSize(dir_v);
133 const int stencil = GetStencilWidth();
134 ForEachFab(Tag(), fluxes, [&](::amrex::MFIter& mfi) {
139 cell_validbox, face_tilebox, stencil, dir);
140 auto&& equation = flux_method_->GetEquation();
142 MakeView<const Complete<Equation>>(scratch[mfi], equation, cell_box);
144 MakeView<Conservative<Equation>>(fluxes[mfi], equation, face_box);
146 flux_method_->ComputeNumericFluxes(Tag(), flux, states, dt, dx, dir);
152 template <
typename Tag,
typename FM>
154 return flux_method_->GetStencilWidth();
#define FUB_ASSERT(x)
Definition: assert.hpp:39
This class is used by the HypebrolicSplitLevelIntegrator and delegates AMR related tasks to the AMReX...
Definition: AMReX/IntegratorContext.hpp:49
::amrex::MultiFab & GetScratch(int level)
Returns the MultiFab associated with level data with ghost cells on the specifed level number and dir...
::amrex::MultiFab & GetFluxes(int level, Direction dir)
Returns the MultiFab associated with flux data on the specifed level number and direction.
const ::amrex::Geometry & GetGeometry(int level) const
Returns the geometry object for the specified refinement level.
void ForEachFab(Tag, const ::amrex::FabArrayBase &fabarray, F function)
Iterate through all local FArrayBox objects in a MultiFab.
Definition: ForEachFab.hpp:34
The amrex namespace.
Definition: AverageState.hpp:33
FluxMethodAdapter(const FM &fm) -> FluxMethodAdapter< execution::OpenMpSimdTag, FM >
std::array<::amrex::Box, 2 > GetCellsAndFacesInStencilRange(const ::amrex::Box &cell_tilebox, const ::amrex::Box &face_validbox, int stencil_width, Direction dir)
decltype(std::declval< T >().ComputeStableDt(std::declval< Args >()...)) ComputeStableDt_t
Definition: AMReX/FluxMethodAdapter.hpp:67
decltype(std::declval< T >().ComputeNumericFluxes(std::declval< Args >()...)) ComputeNumericFluxes_t
Definition: AMReX/FluxMethodAdapter.hpp:118
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
IndexBox< Rank > Box(const BasicView< State, Layout, Rank > &view)
Definition: State.hpp:486
typename detail::LocalType< Tag, T >::type Local
Definition: Execution.hpp:56
Definition: State.hpp:403
Definition: AMReX/FluxMethodAdapter.hpp:36
Local< Tag, FM > flux_method_
Definition: AMReX/FluxMethodAdapter.hpp:51
int GetStencilWidth() const
Definition: AMReX/FluxMethodAdapter.hpp:153
Duration ComputeStableDt(IntegratorContext &context, int level, Direction dir)
Definition: AMReX/FluxMethodAdapter.hpp:70
FluxMethodAdapter(const FM &fm)
Definition: AMReX/FluxMethodAdapter.hpp:40
void ComputeNumericFluxes(IntegratorContext &context, int level, Duration dt, Direction dir)
Definition: AMReX/FluxMethodAdapter.hpp:121
static const int Rank
Definition: AMReX/FluxMethodAdapter.hpp:38
std::decay_t< decltype(std::declval< FM & >().GetEquation())> Equation
Definition: AMReX/FluxMethodAdapter.hpp:37
Definition: Execution.hpp:39
This is std::true_type if Op<Args...> is a valid SFINAE expression.
Definition: type_traits.hpp:92