21 #ifndef FUB_SAMRAI_FLUX_METHOD_HPP
22 #define FUB_SAMRAI_FLUX_METHOD_HPP
35 template <
typename Tag,
typename BaseMethod>
39 std::decay_t<decltype(std::declval<const BaseMethod&>().GetEquation())>;
46 using BaseMethod::GetEquation;
48 using BaseMethod::GetStencilWidth;
63 span<SAMRAI::pdat::CellData<double>
const*> cells,
70 template <
typename Tag,
typename BaseMethod>
74 const SAMRAI::hier::PatchLevel& patch_level = context.
GetPatchLevel(level);
76 const SAMRAI::geom::CartesianGridGeometry& geom = context.
GetGeometry(level);
77 const int dir_value =
static_cast<int>(dir);
78 const double dx = geom.getDx()[dir_value];
79 std::vector<const SAMRAI::pdat::CellData<double>*> patch_data(
81 return std::accumulate(patch_level.begin(), patch_level.end(),
82 Duration(std::numeric_limits<double>::max()),
86 min_dt, ComputeStableDt(patch_data, dx, dir));
90 template <
typename Tag,
typename BaseMethod>
92 span<SAMRAI::pdat::CellData<double>
const*> data,
double dx,
94 constexpr
int Rank = Equation::Rank();
96 MakeView<const Complete>(data, BaseMethod::GetEquation(),
97 AsIndexBox<Rank>(data[0]->getGhostBox()));
98 return Duration(BaseMethod::ComputeStableDt(Tag(), states, dx, dir));
101 template <
typename Tag,
typename BaseMethod>
105 const SAMRAI::geom::CartesianGridGeometry& geom = context.
GetGeometry(level);
106 const int dir_value =
static_cast<int>(dir);
107 const double dx = geom.getDx()[dir_value];
108 const SAMRAI::hier::PatchLevel& patch_level = context.
GetPatchLevel(level);
110 std::vector<const SAMRAI::pdat::CellData<double>*> scratch_data(
113 std::vector<SAMRAI::pdat::SideData<double>*> flux_data(flux_ids.
size());
114 for (std::shared_ptr<SAMRAI::hier::Patch> patch : patch_level) {
117 ComputeNumericFluxes(flux_data, scratch_data, dx, dt, dir);
121 template <
typename Tag,
typename BaseMethod>
123 span<SAMRAI::pdat::SideData<double>*> fluxes,
124 span<SAMRAI::pdat::CellData<double>
const*> cells,
double dx,
Duration dt,
126 constexpr
int Rank = Equation::Rank();
127 auto cell_box = AsIndexBox<Rank>(cells[0]->getGhostBox());
128 const int gcw = GetStencilWidth();
129 auto face_box =
Shrink(cell_box, dir, {gcw, gcw});
130 auto flux_view = MakeView<Conservative>(fluxes, GetEquation(), dir, face_box);
131 auto scratch_view = MakeView<const Complete>(cells, GetEquation(), cell_box);
132 BaseMethod::ComputeNumericFluxes(flux_view, scratch_view, dt, dx, dir);
This is a wrapper class which dispatches a given base method object and dispatches SAMRAI typed patch...
Definition: SAMRAI/FluxMethodAdapter.hpp:36
std::decay_t< decltype(std::declval< const BaseMethod & >().GetEquation())> Equation
Definition: SAMRAI/FluxMethodAdapter.hpp:39
void ComputeNumericFluxes(IntegratorContext &context, int level, Duration dt, Direction dir)
Definition: SAMRAI/FluxMethodAdapter.hpp:102
Duration ComputeStableDt(IntegratorContext &context, int level, Direction dir)
Extracts the state variables patch data views including its ghost cells and compute a stable time ste...
Definition: SAMRAI/FluxMethodAdapter.hpp:72
FluxMethodAdapter(Tag, BaseMethod &&base)
Definition: SAMRAI/FluxMethodAdapter.hpp:44
FluxMethodAdapter(Tag, const BaseMethod &base)
Definition: SAMRAI/FluxMethodAdapter.hpp:43
This class is used by the HypebrolicSplitLevelIntegrator and delegates AMR related tasks to the AMReX...
Definition: SAMRAI/IntegratorContext.hpp:52
span< const int > GetScratchIds() const
Returns the MultiFab associated with level data on the specifed level number.
const SAMRAI::geom::CartesianGridGeometry & GetGeometry(int level) const
Returns the geometry object for the specified refinement level.
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.
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
constexpr index_type size() const noexcept
Returns the number of elements in the span.
Definition: span.hpp:392
Definition: CartesianPatchHierarchy.hpp:41
std::enable_if_t< std::is_pointer_v< PatchData >, void > GetPatchData(span< PatchData > patch_datas, SAMRAI::hier::Patch &patch, span< const int > data_ids)
Definition: ViewPatch.hpp:100
auto Shrink(const layout_left::mapping< Extent > &layout, Direction dir, std::ptrdiff_t n=1)
Definition: Equation.hpp:78
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