22 #ifndef FUB_SAMRAI_PATCH_HIERARCHY_HPP
23 #define FUB_SAMRAI_PATCH_HIERARCHY_HPP
28 #include "fub/counter/CounterRegistry.hpp"
31 #include <SAMRAI/geom/CartesianGridGeometry.h>
32 #include <SAMRAI/geom/CartesianPatchGeometry.h>
33 #include <SAMRAI/hier/PatchHierarchy.h>
37 SAMRAI::hier::ComponentSelector
51 template <
typename I, std::
size_t Rank>
52 std::enable_if_t<std::is_integral_v<I>,
53 std::shared_ptr<SAMRAI::geom::CartesianGridGeometry>>
56 const double* x_lo = coordinates.
lower.data();
57 const double* x_up = coordinates.
upper.data();
60 const SAMRAI::tbox::Dimension dim(Rank);
62 idx_up, SAMRAI::hier::BlockId(0));
63 SAMRAI::hier::BoxContainer domain{domain_box};
64 return std::make_shared<SAMRAI::geom::CartesianGridGeometry>(
73 template <
typename Equation>
75 std::shared_ptr<SAMRAI::geom::CartesianGridGeometry> geom,
79 std::shared_ptr<SAMRAI::geom::CartesianGridGeometry> geom,
88 std::swap(*
this, tmp);
100 [[nodiscard]] const std::shared_ptr<SAMRAI::hier::
PatchHierarchy>&
103 [[nodiscard]] const SAMRAI::geom::CartesianGridGeometry&
108 [[nodiscard]] std::shared_ptr<SAMRAI::hier::PatchLevel>
111 [[nodiscard]] const std::shared_ptr<CounterRegistry>&
114 [[nodiscard]] std::ptrdiff_t
GetCycles(
int level = 0) const;
132 std::shared_ptr<SAMRAI::geom::CartesianGridGeometry> geom,
135 std::move(hier_opts)) {}
137 template <
typename... Is>
138 std::array<double,
sizeof...(Is)>
140 const double* dx = geom.getDx();
141 const double* xlo = geom.getXLower();
142 std::array<std::common_type_t<Is...>,
sizeof...(Is)>
index{
143 std::common_type_t<Is...>(is)...};
144 std::array<double,
sizeof...(Is)> x;
145 for (std::size_t d = 0; d <
sizeof...(Is); ++d) {
146 x[d] = xlo[d] + 0.5 * dx[d] +
index[d] * dx[d];
Definition: SAMRAI/PatchHierarchy.hpp:69
std::shared_ptr< SAMRAI::hier::PatchHierarchy > hierarchy_
Definition: SAMRAI/PatchHierarchy.hpp:121
PatchHierarchy & operator=(PatchHierarchy &&ph)=default
const SAMRAI::geom::CartesianGridGeometry & GetGeometry(int level) const noexcept
PatchHierarchy(PatchHierarchy &&ph)=default
const std::shared_ptr< SAMRAI::hier::PatchHierarchy > & GetNative() const noexcept
int GetNumberOfLevels() const noexcept
std::shared_ptr< SAMRAI::hier::PatchLevel > GetPatchLevel(int level) const
PatchHierarchy & operator=(const PatchHierarchy &ph)
Definition: SAMRAI/PatchHierarchy.hpp:86
Duration GetTimePoint(int level=0) const
const PatchHierarchyOptions & GetOptions() const noexcept
Return some additional patch hierarchy options.
span< const int > GetDataIds() const noexcept
std::vector< Duration > time_points_
Definition: SAMRAI/PatchHierarchy.hpp:125
std::vector< std::ptrdiff_t > cycles_
Definition: SAMRAI/PatchHierarchy.hpp:124
const DataDescription & GetDataDescription() const noexcept
void SetCycles(std::ptrdiff_t cycles, int level)
DataDescription data_desc_
Definition: SAMRAI/PatchHierarchy.hpp:122
std::shared_ptr< CounterRegistry > counter_registry_
Definition: SAMRAI/PatchHierarchy.hpp:126
int GetMaxNumberOfLevels() const noexcept
std::ptrdiff_t GetCycles(int level=0) const
PatchHierarchy(const Equation &eq, std::shared_ptr< SAMRAI::geom::CartesianGridGeometry > geom, PatchHierarchyOptions hier_opts)
Constructs a PatchHierarchy object which is capable of holding data described by the secified data de...
Definition: SAMRAI/PatchHierarchy.hpp:130
PatchHierarchy(const PatchHierarchy &ph)
const std::shared_ptr< CounterRegistry > & GetCounterRegistry() const noexcept
PatchHierarchyOptions options_
Definition: SAMRAI/PatchHierarchy.hpp:123
void SetTimePoint(Duration time_point, int level)
PatchHierarchy(DataDescription dd, std::shared_ptr< SAMRAI::geom::CartesianGridGeometry > geom, PatchHierarchyOptions hier_opts)
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
Definition: CartesianPatchHierarchy.hpp:41
SAMRAI::hier::ComponentSelector SelectComponents(const SAMRAI::hier::PatchDescriptor &desc)
std::enable_if_t< std::is_integral_v< I >, std::shared_ptr< SAMRAI::geom::CartesianGridGeometry > > MakeCartesianGridGeometry(const std::array< I, Rank > &n_cells, const CoordinateRange< Rank > &coordinates)
Definition: SAMRAI/PatchHierarchy.hpp:54
DataDescription RegisterVariables(const Equation &equation, std::string prefix=std::string())
This function registers all neccessary variables and contexts with SAMRAI.
Definition: RegisterVariables.hpp:102
std::array< double, sizeof...(Is)> GetCellCenter(const SAMRAI::geom::CartesianGridGeometry &geom, Is... is)
Definition: SAMRAI/PatchHierarchy.hpp:139
std::string MakeUniqueName()
Definition: uuid.hpp:31
std::chrono::duration< double > Duration
Definition: Duration.hpp:31
std::array< std::ptrdiff_t, static_cast< std::size_t >(Rank)> Index
Definition: PatchDataView.hpp:34
IndexBox< Rank > Box(const BasicView< State, Layout, Rank > &view)
Definition: State.hpp:486
std::ptrdiff_t index
Definition: type_traits.hpp:179
Definition: SAMRAI/PatchHierarchy.hpp:46
std::array< double, Rank > lower
Definition: SAMRAI/PatchHierarchy.hpp:47
std::array< double, Rank > upper
Definition: SAMRAI/PatchHierarchy.hpp:48
Definition: RegisterVariables.hpp:35
Definition: SAMRAI/PatchHierarchy.hpp:41
SAMRAI::hier::IntVector refine_ratio
Definition: SAMRAI/PatchHierarchy.hpp:42
int max_number_of_levels
Definition: SAMRAI/PatchHierarchy.hpp:43