version 3.11-dev
Loading...
Searching...
No Matches
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// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12
13#ifndef DUMUX_MULTIDOMAIN_TRAITS_HH
14#define DUMUX_MULTIDOMAIN_TRAITS_HH
15
16#include <type_traits>
17#include <tuple>
18#include <utility>
19#include <memory>
20
21#include <dune/common/fmatrix.hh>
22#include <dune/common/indices.hh>
23
24#include <dune/istl/bcrsmatrix.hh>
25#include <dune/istl/multitypeblockvector.hh>
26#include <dune/istl/multitypeblockmatrix.hh>
27
31
33
34namespace Dumux {
35
36namespace Detail {
37
39template<class Scalar, class... JacobianBlocks>
41{
42 static_assert(std::conjunction_v<isBCRSMatrix<JacobianBlocks>...>, "Jacobian blocks have to be BCRSMatrices!");
43
44 // all blocks are complex-valued if any subdomain has complex-valued unknowns
45 using Field = std::common_type_t<Scalar, typename JacobianBlocks::field_type...>;
46
47 template<std::size_t id>
48 using JacobianDiagBlock = typename std::tuple_element_t<id, std::tuple<JacobianBlocks...>>;
49
50 template<std::size_t id>
51 static constexpr decltype(auto) numEq()
52 { return JacobianDiagBlock<id>::block_type::rows; }
53
54 template <std::size_t id, class I> struct makeRow;
55
56 template <std::size_t id, std::size_t... Is>
57 struct makeRow<id, std::index_sequence<Is...>>
58 {
60 };
61
62 template <class I> struct makeMatrix;
63
64 template <std::size_t... Is>
65 struct makeMatrix<std::index_sequence<Is...>>
66 {
67 using type = Dune::MultiTypeBlockMatrix<typename makeRow<Is, std::index_sequence<Is...>>::type...>;
68 };
69
70 using Indices = std::index_sequence_for<JacobianBlocks...>;
71public:
72 using type = typename makeMatrix<Indices>::type;
73};
74
76template<template<std::size_t> class T, class Indices>
78{
79 template<std::size_t i>
80 using PtrType = std::shared_ptr<T<i>>;
81
83};
84
86template<template<std::size_t> class T, class Indices>
88{
89 template<std::size_t i>
90 using PtrType = std::shared_ptr<const T<i>>;
91
93};
94
96template<template<std::size_t> class SubDomainDiagBlocks, class Indices, class Scalar>
98{
99 template<typename... MatrixBlocks>
100 using M = typename createMultiTypeBlockMatrixType<Scalar, MatrixBlocks...>::type::type;
101
103};
104
105} // end namespace Detail
106
107/*
108 * \ingroup MultiDomain
109 * \brief A traits class every multidomain model has to provide
110 * \tparam SubDomainTypeTags the TypeTags of the sub domain problems
111 * \note should export the types
112 * \code
113 * //! the type tag of the sub domain problem with id
114 * template<std::size_t id>
115 * using SubDomainTypeTag = ...
116 *
117 * //! the index to access sub domain matrices and vectors
118 * //! to use with multitype matrices and vectors
119 * template<std::size_t id>
120 * using DomainIdx = ...
121 *
122 * //! the scalar type
123 * using Scalar = ...
124 *
125 * //! the solution vector type
126 * using SolutionVector = ...
127 *
128 * //! the residual vector type
129 * using ResidualVector = ...
130 *
131 * //! the jacobian type
132 * using JacobianMatrix = ...
133 * \endcode
134 */
135template<typename... SubDomainTypeTags>
137{
139 static constexpr std::size_t numSubDomains = sizeof...(SubDomainTypeTags);
140
152 template<std::size_t id>
153 using SubDomainTypeTag = typename std::tuple_element_t<id, std::tuple<SubDomainTypeTags...>>;
154
155private:
156
158 using Indices = std::make_index_sequence<numSubDomains>;
159
161 template<std::size_t id>
162 using SubDomainScalar = GetPropType<SubDomainTypeTag<id>, Properties::Scalar>;
163
165 template<std::size_t id>
166 using SubDomainJacobianMatrix = GetPropType<SubDomainTypeTag<id>, Properties::JacobianMatrix>;
167
169 template<std::size_t id>
170 using SubDomainSolutionVector = GetPropType<SubDomainTypeTag<id>, Properties::SolutionVector>;
171
173 template<std::size_t id>
174 using SubDomainResidualVector = typename Detail::NativeDuneVectorType<SubDomainSolutionVector<id>>::type;
175
176public:
177
178 /*
179 * \brief sub domain types
180 */
181 //\{
182
183 template<std::size_t id>
185 {
186 using Index = Dune::index_constant<id>;
188 using Grid = GetPropType<SubDomainTypeTag<id>, Properties::Grid>;
189 using GridGeometry = GetPropType<SubDomainTypeTag<id>, Properties::GridGeometry>;
190 using Problem = GetPropType<SubDomainTypeTag<id>, Properties::Problem>;
191 using GridVariables = GetPropType<SubDomainTypeTag<id>, Properties::GridVariables>;
192 using LocalResidual = GetPropType<SubDomainTypeTag<id>, Properties::LocalResidual>;
193 using IOFields = GetPropType<SubDomainTypeTag<id>, Properties::IOFields>;
194 using SolutionVector = GetPropType<SubDomainTypeTag<id>, Properties::SolutionVector>;
196 };
197
198 //\}
199
200 /*
201 * \brief multi domain types
202 */
203 //\{
204
207
210
213
216
217 //\}
218
219 /*
220 * \brief helper aliases to construct derived tuple types
221 */
222 //\{
223
225 template<template<std::size_t> class T>
227
229 template<template<std::size_t> class T>
231
233 template<template<std::size_t> class T>
235
236 //\}
237};
238
239} //end namespace Dumux
240
241#endif
a helper class to create a multitype matrix given the diagonal matrix blocks
Definition multidomain/traits.hh:41
typename makeMatrix< Indices >::type type
Definition multidomain/traits.hh:72
Definition common/pdesolver.hh:26
Definition variablesbackend.hh:34
Defines all properties used in Dumux.
Helper to extract native Dune vector types from particular Dumux types.
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition propertysystem.hh:296
Type traits to be used with matrix types.
Definition cvfelocalresidual.hh:25
typename ScalarType< X >::Type Scalar
Definition odesolver.hh:52
Definition adapt.hh:17
helper alias to create the JacobianMatrix type
Definition multidomain/traits.hh:98
typename createMultiTypeBlockMatrixType< Scalar, MatrixBlocks... >::type::type M
Definition multidomain/traits.hh:100
typename makeFromIndexedType< M, SubDomainDiagBlocks, Indices >::type type
Definition multidomain/traits.hh:102
helper alias to create a tuple of shared_ptr<const ...> from an indexed type
Definition multidomain/traits.hh:88
typename makeFromIndexedType< std::tuple, PtrType, Indices >::type type
Definition multidomain/traits.hh:92
std::shared_ptr< const T< i > > PtrType
Definition multidomain/traits.hh:90
helper alias to create a tuple of shared_ptr<...> from an indexed type
Definition multidomain/traits.hh:78
std::shared_ptr< T< i > > PtrType
Definition multidomain/traits.hh:80
typename makeFromIndexedType< std::tuple, PtrType, Indices >::type type
Definition multidomain/traits.hh:82
Definition dunevectors.hh:56
typename NativeDuneVectorTypeImpl< V, Dune::Std::is_detected< Detail::DuneVectors::StateDetector, V >{} >::type type
Definition dunevectors.hh:57
Definition multidomain/traits.hh:185
GetPropType< SubDomainTypeTag< id >, Properties::GridGeometry > GridGeometry
Definition multidomain/traits.hh:189
typename Detail::NativeDuneVectorType< SolutionVector >::type ResidualVector
Definition multidomain/traits.hh:195
SubDomainTypeTag< id > TypeTag
Definition multidomain/traits.hh:187
Dune::index_constant< id > Index
Definition multidomain/traits.hh:186
GetPropType< SubDomainTypeTag< id >, Properties::IOFields > IOFields
Definition multidomain/traits.hh:193
GetPropType< SubDomainTypeTag< id >, Properties::Problem > Problem
Definition multidomain/traits.hh:190
GetPropType< SubDomainTypeTag< id >, Properties::GridVariables > GridVariables
Definition multidomain/traits.hh:191
GetPropType< SubDomainTypeTag< id >, Properties::Grid > Grid
Definition multidomain/traits.hh:188
GetPropType< SubDomainTypeTag< id >, Properties::SolutionVector > SolutionVector
Definition multidomain/traits.hh:194
GetPropType< SubDomainTypeTag< id >, Properties::LocalResidual > LocalResidual
Definition multidomain/traits.hh:192
Definition multidomain/traits.hh:137
typename makeFromIndexedType< std::common_type_t, SubDomainScalar, Indices >::type Scalar
Definition multidomain/traits.hh:206
typename makeFromIndexedType< Dune::MultiTypeBlockVector, SubDomainSolutionVector, Indices >::type SolutionVector
Definition multidomain/traits.hh:209
typename Detail::MultiDomainTupleSharedPtr< T, Indices >::type TupleOfSharedPtr
Definition multidomain/traits.hh:230
typename makeFromIndexedType< Dune::MultiTypeBlockVector, SubDomainResidualVector, Indices >::type ResidualVector
Definition multidomain/traits.hh:212
typename makeFromIndexedType< std::tuple, T, Indices >::type Tuple
Definition multidomain/traits.hh:226
typename Detail::MultiDomainMatrixType< SubDomainJacobianMatrix, Indices, Scalar >::type JacobianMatrix
Definition multidomain/traits.hh:215
typename std::tuple_element_t< id, std::tuple< SubDomainTypeTags... > > SubDomainTypeTag
Definition multidomain/traits.hh:153
typename Detail::MultiDomainTupleSharedPtrConst< T, Indices >::type TupleOfSharedPtrConst
Definition multidomain/traits.hh:234
Definition utility.hh:28
Utilities for template meta programming.