12#ifndef DUMUX_MULTIDOMAIN_FV_GRIDGEOMETRY_HH
13#define DUMUX_MULTIDOMAIN_FV_GRIDGEOMETRY_HH
19#include <dune/common/hybridutilities.hh>
20#include <dune/common/indices.hh>
24namespace Multidomain::Detail {
28:
public std::false_type {};
30template<
class... Args>
32:
public std::true_type {};
44template<
class MDTraits>
47 static constexpr std::size_t numSubDomains = MDTraits::numSubDomains;
50 template<std::size_t i,
class Tuple,
size_t... Is>
51 void constructFromTupleOfArgs_(Tuple&& t, std::index_sequence<Is...>)
53 std::get<i>(gridGeometries_) = std::make_shared<Type<i>>(std::get<Is>(std::forward<Tuple>(t))...);
57 template<std::
size_t i,
class Arg>
58 void construct_(Arg&& arg)
60 using ArgT = std::decay_t<Arg>;
62 if constexpr (Multidomain::Detail::template isStdTuple<ArgT>)
63 constructFromTupleOfArgs_<i>(std::forward<Arg>(arg), std::make_index_sequence<std::tuple_size_v<ArgT>>{});
65 std::get<i>(gridGeometries_) = std::make_shared<Type<i>>(std::forward<Arg>(arg));
69 template<std::size_t i,
class Tuple,
size_t... Is>
70 void updateWithTupleOfArgs_(Tuple&& t, std::index_sequence<Is...>)
72 std::get<i>(gridGeometries_)->update(std::get<Is>(std::forward<Tuple>(t))...);
76 template<std::
size_t i,
class Arg>
77 void update_(Arg&& arg)
79 using ArgT = std::decay_t<Arg>;
81 if constexpr (Multidomain::Detail::template isStdTuple<ArgT>)
82 updateWithTupleOfArgs_<i>(std::forward<Arg>(arg), std::make_index_sequence<std::tuple_size_v<ArgT>>{});
84 std::get<i>(gridGeometries_)->update(std::forward<Arg>(arg));
89 template<std::
size_t i>
90 using Type =
typename MDTraits::template SubDomain<i>::GridGeometry;
93 template<std::
size_t i>
97 using TupleType =
typename MDTraits::template Tuple<PtrType>;
110 template<
typename... Args>
113 static_assert(numSubDomains ==
sizeof...(Args),
"Number of arguments has to match number of subdomains");
115 using namespace Dune::Hybrid;
116 forEach(std::make_index_sequence<numSubDomains>{}, [
this, t = std::forward_as_tuple(args...)](
auto&& id)
118 constexpr auto i = std::decay_t<
decltype(id)>::value;
119 this->construct_<i>(std::get<i>(t));
128 : gridGeometries_(std::move(ggTuple))
142 template<
typename... Args>
145 static_assert(numSubDomains ==
sizeof...(Args),
"Number of arguments has to match number of subdomains");
147 using namespace Dune::Hybrid;
148 forEach(std::make_index_sequence<numSubDomains>{}, [
this, t = std::forward_as_tuple(args...)](
auto&& id)
150 constexpr auto i = std::decay_t<
decltype(id)>::value;
151 this->update_<i>(std::get<i>(t));
156 template<std::
size_t i>
158 {
return *std::get<i>(gridGeometries_); }
161 template<std::
size_t i>
163 {
return *std::get<i>(gridGeometries_); }
166 template<std::
size_t i>
167 const PtrType<i>&
get(Dune::index_constant<i>
id = Dune::index_constant<i>{})
const
168 {
return std::get<i>(gridGeometries_); }
171 template<std::
size_t i>
173 {
return std::get<i>(gridGeometries_); }
179 {
return gridGeometries_; }
185 {
return gridGeometries_; }
A multidomain wrapper for multiple grid geometries.
Definition: multidomain/fvgridgeometry.hh:46
void update(Args &&... args)
Update all grid geometries (do this e.g. after grid adaption)
Definition: multidomain/fvgridgeometry.hh:143
typename MDTraits::template SubDomain< i >::GridGeometry Type
export base types of the stored type
Definition: multidomain/fvgridgeometry.hh:90
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvgridgeometry.hh:97
const PtrType< i > & get(Dune::index_constant< i > id=Dune::index_constant< i >{}) const
! access the grid geometry pointer for domain with index i
Definition: multidomain/fvgridgeometry.hh:167
TupleType & asTuple()
Access the underlying tuple representation.
Definition: multidomain/fvgridgeometry.hh:178
const TupleType & asTuple() const
Access the underlying tuple representation.
Definition: multidomain/fvgridgeometry.hh:184
const Type< i > & operator[](Dune::index_constant< i >) const
return the grid geometry for domain with index i
Definition: multidomain/fvgridgeometry.hh:157
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/fvgridgeometry.hh:94
PtrType< i > & get(Dune::index_constant< i > id=Dune::index_constant< i >{})
! access the the grid geometry pointer for domain with index i
Definition: multidomain/fvgridgeometry.hh:172
MultiDomainFVGridGeometry(Args &&... args)
Construct grid geometries for all subdomains.
Definition: multidomain/fvgridgeometry.hh:111
MultiDomainFVGridGeometry(TupleType ggTuple)
Construct wrapper from a tuple of grid geometries.
Definition: multidomain/fvgridgeometry.hh:127
constexpr bool isStdTuple
Definition: multidomain/fvgridgeometry.hh:35
Definition: multidomain/fvgridgeometry.hh:28