24#ifndef DUMUX_MULTIDOMAIN_FV_GRIDGEOMETRY_HH
25#define DUMUX_MULTIDOMAIN_FV_GRIDGEOMETRY_HH
31#include <dune/common/hybridutilities.hh>
32#include <dune/common/indices.hh>
36namespace Multidomain::Detail {
40:
public std::false_type {};
42template<
class... Args>
44:
public std::true_type {};
56template<
class MDTraits>
59 static constexpr std::size_t numSubDomains = MDTraits::numSubDomains;
62 template<std::size_t i,
class Tuple,
size_t... Is>
63 void constructFromTupleOfArgs_(Tuple&& t, std::index_sequence<Is...>)
65 std::get<i>(gridGeometries_) = std::make_shared<Type<i>>(std::get<Is>(std::forward<Tuple>(t))...);
69 template<std::
size_t i,
class Arg>
70 void construct_(Arg&& arg)
72 using ArgT = std::decay_t<Arg>;
74 if constexpr (Multidomain::Detail::template isStdTuple<ArgT>)
75 constructFromTupleOfArgs_<i>(std::forward<Arg>(arg), std::make_index_sequence<std::tuple_size_v<ArgT>>{});
77 std::get<i>(gridGeometries_) = std::make_shared<Type<i>>(std::forward<Arg>(arg));
81 template<std::size_t i,
class Tuple,
size_t... Is>
82 void updateWithTupleOfArgs_(Tuple&& t, std::index_sequence<Is...>)
84 std::get<i>(gridGeometries_)->update(std::get<Is>(std::forward<Tuple>(t))...);
88 template<std::
size_t i,
class Arg>
89 void update_(Arg&& arg)
91 using ArgT = std::decay_t<Arg>;
93 if constexpr (Multidomain::Detail::template isStdTuple<ArgT>)
94 updateWithTupleOfArgs_<i>(std::forward<Arg>(arg), std::make_index_sequence<std::tuple_size_v<ArgT>>{});
96 std::get<i>(gridGeometries_)->update(std::forward<Arg>(arg));
100 template<std::
size_t i>
101 using GV =
typename MDTraits::template SubDomain<i>::GridGeometry::GridView;
102 using GVTuple =
typename MDTraits::template Tuple<GV>;
106 template<std::
size_t i>
107 using Type =
typename MDTraits::template SubDomain<i>::GridGeometry;
110 template<std::
size_t i>
114 using TupleType =
typename MDTraits::template Tuple<PtrType>;
119 [[deprecated(
"Will be removed after release 3.5. Use variadic constructor!")]]
133 template<
typename... Args>
136 static_assert(numSubDomains ==
sizeof...(Args),
"Number of arguments has to match number of subdomains");
138 using namespace Dune::Hybrid;
139 forEach(std::make_index_sequence<numSubDomains>{}, [
this, t = std::forward_as_tuple(args...)](
auto&& id)
141 constexpr auto i = std::decay_t<
decltype(id)>::value;
142 this->construct_<i>(std::get<i>(t));
151 : gridGeometries_(std::move(ggTuple))
157 [[deprecated(
"Will be removed after release 3.5. Use variadic constructor!")]]
160 using namespace Dune::Hybrid;
161 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
163 constexpr auto i = std::decay_t<
decltype(id)>::value;
164 this->construct_<i>(std::get<i>(gvTuple));
179 template<
typename... Args>
182 static_assert(numSubDomains ==
sizeof...(Args),
"Number of arguments has to match number of subdomains");
184 using namespace Dune::Hybrid;
185 forEach(std::make_index_sequence<numSubDomains>{}, [
this, t = std::forward_as_tuple(args...)](
auto&& id)
187 constexpr auto i = std::decay_t<
decltype(id)>::value;
188 this->update_<i>(std::get<i>(t));
195 [[deprecated(
"Will be removed after release 3.5. Use variadic update!")]]
198 using namespace Dune::Hybrid;
199 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
201 elementAt(gridGeometries_,
id)->update();
206 template<std::
size_t i>
208 {
return *std::get<i>(gridGeometries_); }
211 template<std::
size_t i>
213 {
return *std::get<i>(gridGeometries_); }
216 template<std::
size_t i>
217 const PtrType<i>&
get(Dune::index_constant<i>
id = Dune::index_constant<i>{})
const
218 {
return std::get<i>(gridGeometries_); }
221 template<std::
size_t i>
223 {
return std::get<i>(gridGeometries_); }
226 template<std::
size_t i>
227 [[deprecated(
"Will be removed after release 3.5. Use one of the constructors instead.")]]
228 void set(
PtrType<i> p, Dune::index_constant<i>
id = Dune::index_constant<i>{})
229 { std::get<i>(gridGeometries_) = p; }
235 [[deprecated(
"Use asTuple. Will be removed after release 3.5")]]
237 {
return gridGeometries_; }
243 {
return gridGeometries_; }
249 {
return gridGeometries_; }
constexpr bool isStdTuple
Definition: multidomain/fvgridgeometry.hh:47
Definition: multidomain/fvgridgeometry.hh:40
A multidomain wrapper for multiple grid geometries.
Definition: multidomain/fvgridgeometry.hh:58
TupleType getTuple()
return the grid variables tuple we are wrapping
Definition: multidomain/fvgridgeometry.hh:236
void update(Args &&... args)
Update all grid geometries (do this e.g. after grid adaption)
Definition: multidomain/fvgridgeometry.hh:180
MultiDomainFVGridGeometry(GVTuple gvTuple)
Construct wrapper from a tuple of grid views.
Definition: multidomain/fvgridgeometry.hh:158
void set(PtrType< i > p, Dune::index_constant< i > id=Dune::index_constant< i >{})
set the pointer for sub domain i
Definition: multidomain/fvgridgeometry.hh:228
typename MDTraits::template SubDomain< i >::GridGeometry Type
export base types of the stored type
Definition: multidomain/fvgridgeometry.hh:107
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvgridgeometry.hh:114
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:217
TupleType & asTuple()
Access the underlying tuple representation.
Definition: multidomain/fvgridgeometry.hh:242
MultiDomainFVGridGeometry()=default
The default constructor.
void update()
Update all grid geometries (do this again after grid adaption)
Definition: multidomain/fvgridgeometry.hh:196
const TupleType & asTuple() const
Access the underlying tuple representation.
Definition: multidomain/fvgridgeometry.hh:248
const Type< i > & operator[](Dune::index_constant< i >) const
return the grid geometry for domain with index i
Definition: multidomain/fvgridgeometry.hh:207
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/fvgridgeometry.hh:111
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:222
MultiDomainFVGridGeometry(Args &&... args)
Construct grid geometries for all subdomains.
Definition: multidomain/fvgridgeometry.hh:134
MultiDomainFVGridGeometry(TupleType ggTuple)
Construct wrapper from a tuple of grid geometries.
Definition: multidomain/fvgridgeometry.hh:150