3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
multidomain/traits.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_MULTIDOMAIN_TRAITS_HH
26#define DUMUX_MULTIDOMAIN_TRAITS_HH
27
28#include <type_traits>
29#include <tuple>
30#include <utility>
31#include <memory>
32
33#include <dune/common/fmatrix.hh>
34#include <dune/common/indices.hh>
35
36#include <dune/istl/bcrsmatrix.hh>
37#include <dune/istl/multitypeblockvector.hh>
38#include <dune/istl/multitypeblockmatrix.hh>
39
43
44namespace Dumux {
45
46namespace Detail {
47
49template<class Scalar, class... JacobianBlocks>
51{
52 static_assert(std::conjunction_v<isBCRSMatrix<JacobianBlocks>...>, "Jacobian blocks have to be BCRSMatrices!");
53
54 template<std::size_t id>
55 using JacobianDiagBlock = typename std::tuple_element_t<id, std::tuple<JacobianBlocks...>>;
56
57 template<std::size_t id>
58 static constexpr decltype(auto) numEq()
59 { return JacobianDiagBlock<id>::block_type::rows; }
60
61 template <std::size_t id, class I> struct makeRow;
62
63 template <std::size_t id, std::size_t... Is>
64 struct makeRow<id, std::index_sequence<Is...>>
65 {
67 };
68
69 template <class I> struct makeMatrix;
70
71 template <std::size_t... Is>
72 struct makeMatrix<std::index_sequence<Is...>>
73 {
74 using type = Dune::MultiTypeBlockMatrix<typename makeRow<Is, std::index_sequence<Is...>>::type...>;
75 };
76
77 using Indices = std::index_sequence_for<JacobianBlocks...>;
78public:
79 using type = typename makeMatrix<Indices>::type;
80};
81
83template<template<std::size_t> class T, class Indices>
85{
86 template<std::size_t i>
87 using PtrType = std::shared_ptr<T<i>>;
88
90};
91
93template<template<std::size_t> class T, class Indices>
95{
96 template<std::size_t i>
97 using PtrType = std::shared_ptr<const T<i>>;
98
100};
101
103template<template<std::size_t> class SubDomainDiagBlocks, class Indices, class Scalar>
105{
106 template<typename... MatrixBlocks>
107 using M = typename createMultiTypeBlockMatrixType<Scalar, MatrixBlocks...>::type::type;
108
110};
111
112} // end namespace Detail
113
114/*
115 * \ingroup MultiDomain
116 * \brief A traits class every multidomain model has to provide
117 * \tparam SubDomainTypeTags the TypeTags of the sub domain problems
118 * \note should export the types
119 * \code
120 * //! the type tag of the sub domain problem with id
121 * template<std::size_t id>
122 * using SubDomainTypeTag = ...
123 *
124 * //! the index to access sub domain matrices and vectors
125 * //! to use with multitype matrices and vectors
126 * template<std::size_t id>
127 * using DomainIdx = ...
128 *
129 * //! the scalar type
130 * using Scalar = ...
131 *
132 * //! the solution vector type
133 * using SolutionVector = ...
134 *
135 * //! the jacobian type
136 * using JacobianMatrix = ...
137 * \endcode
138 */
139template<typename... SubDomainTypeTags>
141{
143 static constexpr std::size_t numSubDomains = sizeof...(SubDomainTypeTags);
144
145private:
146
148 template<std::size_t id>
149 using SubDomainTypeTag = typename std::tuple_element_t<id, std::tuple<SubDomainTypeTags...>>;
150
152 using Indices = std::make_index_sequence<numSubDomains>;
153
155 template<std::size_t id>
157
159 template<std::size_t id>
160 using SubDomainJacobianMatrix = GetPropType<SubDomainTypeTag<id>, Properties::JacobianMatrix>;
161
163 template<std::size_t id>
164 using SubDomainSolutionVector = GetPropType<SubDomainTypeTag<id>, Properties::SolutionVector>;
165
166public:
167
168 /*
169 * \brief sub domain types
170 */
171 //\{
172
173 template<std::size_t id>
175 {
176 using Index = Dune::index_constant<id>;
177 using TypeTag = SubDomainTypeTag<id>;
184 };
185
186 //\}
187
188 /*
189 * \brief multi domain types
190 */
191 //\{
192
195
198
201
202 //\}
203
204 /*
205 * \brief helper aliases to contruct derived tuple types
206 */
207 //\{
208
210 template<template<std::size_t> class T>
212
214 template<template<std::size_t> class T>
216
218 template<template<std::size_t> class T>
220
221 //\}
222};
223
224} //end namespace Dumux
225
226#endif
Type traits to be used with matrix types.
Utilities for template meta programming.
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
Definition: common/pdesolver.hh:38
Property to specify the type of scalar values.
Definition: common/properties.hh:43
The DUNE grid type.
Definition: common/properties.hh:47
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:57
A class helping models to define input and output fields.
Definition: common/properties.hh:63
Type of the global jacobian matrix.
Definition: common/properties.hh:67
Vector containing all primary variable vector of the grid.
Definition: common/properties.hh:69
Definition: common/properties.hh:98
The grid variables object managing variable data on the grid (volvars/fluxvars cache)
Definition: common/properties.hh:119
Definition: utility.hh:40
Definition: variablesbackend.hh:43
a helper class to create a multitype matrix given the diagonal matrix blocks
Definition: multidomain/traits.hh:51
typename makeMatrix< Indices >::type type
Definition: multidomain/traits.hh:79
helper alias to create a tuple of shared_ptr<...> from an indexed type
Definition: multidomain/traits.hh:85
typename makeFromIndexedType< std::tuple, PtrType, Indices >::type type
Definition: multidomain/traits.hh:89
std::shared_ptr< T< i > > PtrType
Definition: multidomain/traits.hh:87
helper alias to create a tuple of shared_ptr<const ...> from an indexed type
Definition: multidomain/traits.hh:95
typename makeFromIndexedType< std::tuple, PtrType, Indices >::type type
Definition: multidomain/traits.hh:99
std::shared_ptr< const T< i > > PtrType
Definition: multidomain/traits.hh:97
helper alias to create the JacobianMatrix type
Definition: multidomain/traits.hh:105
typename createMultiTypeBlockMatrixType< Scalar, MatrixBlocks... >::type::type M
Definition: multidomain/traits.hh:107
typename makeFromIndexedType< M, SubDomainDiagBlocks, Indices >::type type
Definition: multidomain/traits.hh:109
Definition: multidomain/traits.hh:141
static constexpr std::size_t numSubDomains
the number of subdomains
Definition: multidomain/traits.hh:143
typename makeFromIndexedType< std::common_type_t, SubDomainScalar, Indices >::type Scalar
the scalar type
Definition: multidomain/traits.hh:194
typename makeFromIndexedType< Dune::MultiTypeBlockVector, SubDomainSolutionVector, Indices >::type SolutionVector
the solution vector type
Definition: multidomain/traits.hh:197
typename Detail::MultiDomainTupleSharedPtr< T, Indices >::type TupleOfSharedPtr
helper alias to create tuple<std::shared_ptr<...>> from indexed type
Definition: multidomain/traits.hh:215
typename makeFromIndexedType< std::tuple, T, Indices >::type Tuple
helper alias to create tuple<...> from indexed type
Definition: multidomain/traits.hh:211
typename Detail::MultiDomainMatrixType< SubDomainJacobianMatrix, Indices, Scalar >::type JacobianMatrix
the jacobian type
Definition: multidomain/traits.hh:200
typename Detail::MultiDomainTupleSharedPtrConst< T, Indices >::type TupleOfSharedPtrConst
helper alias to create tuple<std::shared_ptr<const ...>> from indexed type
Definition: multidomain/traits.hh:219
Definition: multidomain/traits.hh:175
GetPropType< SubDomainTypeTag< id >, Properties::GridGeometry > GridGeometry
Definition: multidomain/traits.hh:179
SubDomainTypeTag< id > TypeTag
Definition: multidomain/traits.hh:177
Dune::index_constant< id > Index
Definition: multidomain/traits.hh:176
GetPropType< SubDomainTypeTag< id >, Properties::IOFields > IOFields
Definition: multidomain/traits.hh:182
GetPropType< SubDomainTypeTag< id >, Properties::Problem > Problem
Definition: multidomain/traits.hh:180
GetPropType< SubDomainTypeTag< id >, Properties::GridVariables > GridVariables
Definition: multidomain/traits.hh:181
GetPropType< SubDomainTypeTag< id >, Properties::Grid > Grid
Definition: multidomain/traits.hh:178
GetPropType< SubDomainTypeTag< id >, Properties::SolutionVector > SolutionVector
Definition: multidomain/traits.hh:183
Declares all properties used in Dumux.