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));
101 template<std::
size_t i>
102 using Type =
typename MDTraits::template SubDomain<i>::GridGeometry;
105 template<std::
size_t i>
109 using TupleType =
typename MDTraits::template Tuple<PtrType>;
122 template<
typename... Args>
125 static_assert(numSubDomains ==
sizeof...(Args),
"Number of arguments has to match number of subdomains");
127 using namespace Dune::Hybrid;
128 forEach(std::make_index_sequence<numSubDomains>{}, [
this, t = std::forward_as_tuple(args...)](
auto&& id)
130 constexpr auto i = std::decay_t<
decltype(id)>::value;
131 this->construct_<i>(std::get<i>(t));
140 : gridGeometries_(std::move(ggTuple))
154 template<
typename... Args>
157 static_assert(numSubDomains ==
sizeof...(Args),
"Number of arguments has to match number of subdomains");
159 using namespace Dune::Hybrid;
160 forEach(std::make_index_sequence<numSubDomains>{}, [
this, t = std::forward_as_tuple(args...)](
auto&& id)
162 constexpr auto i = std::decay_t<
decltype(id)>::value;
163 this->update_<i>(std::get<i>(t));
168 template<std::
size_t i>
170 {
return *std::get<i>(gridGeometries_); }
173 template<std::
size_t i>
175 {
return *std::get<i>(gridGeometries_); }
178 template<std::
size_t i>
179 const PtrType<i>&
get(Dune::index_constant<i>
id = Dune::index_constant<i>{})
const
180 {
return std::get<i>(gridGeometries_); }
183 template<std::
size_t i>
185 {
return std::get<i>(gridGeometries_); }
191 {
return gridGeometries_; }
197 {
return gridGeometries_; }
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
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
void update(Args &&... args)
Update all grid geometries (do this e.g. after grid adaption)
Definition: multidomain/fvgridgeometry.hh:155
typename MDTraits::template SubDomain< i >::GridGeometry Type
export base types of the stored type
Definition: multidomain/fvgridgeometry.hh:102
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvgridgeometry.hh:109
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:179
TupleType & asTuple()
Access the underlying tuple representation.
Definition: multidomain/fvgridgeometry.hh:190
const TupleType & asTuple() const
Access the underlying tuple representation.
Definition: multidomain/fvgridgeometry.hh:196
const Type< i > & operator[](Dune::index_constant< i >) const
return the grid geometry for domain with index i
Definition: multidomain/fvgridgeometry.hh:169
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/fvgridgeometry.hh:106
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:184
MultiDomainFVGridGeometry(Args &&... args)
Construct grid geometries for all subdomains.
Definition: multidomain/fvgridgeometry.hh:123
MultiDomainFVGridGeometry(TupleType ggTuple)
Construct wrapper from a tuple of grid geometries.
Definition: multidomain/fvgridgeometry.hh:139