version 3.8
linearsolvertraits.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-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_LINEAR_SOLVER_TRAITS_HH
13#define DUMUX_LINEAR_SOLVER_TRAITS_HH
14
15#include <bitset>
16
17#include <dune/istl/schwarz.hh>
18#include <dune/istl/novlpschwarz.hh>
19#include <dune/istl/owneroverlapcopy.hh>
20#include <dune/istl/paamg/pinfo.hh>
21#include <dune/istl/preconditioners.hh>
22#include <dune/grid/common/capabilities.hh>
23
26
27namespace Dumux {
28
30template<class GridGeometry, class DiscretizationMethod>
32
36template<class GridGeometry>
38
40template<class MType, class VType>
42{
43 using Matrix = MType;
44 using Vector = VType;
45 using LinearOperator = Dune::MatrixAdapter<MType, VType, VType>;
46 using ScalarProduct = Dune::SeqScalarProduct<VType>;
47
48 template<class SeqPreconditioner>
49 using Preconditioner = SeqPreconditioner;
50};
51
53{
54 template<class Matrix, class Vector>
56
57 static constexpr bool canCommunicate = false;
58};
59
60#if HAVE_MPI
61template <class MType, class VType>
63{
64public:
65 using Matrix = MType;
66 using Vector = VType;
67 using Comm = Dune::OwnerOverlapCopyCommunication<Dune::bigunsignedint<96>, int>;
68 using LinearOperator = Dune::NonoverlappingSchwarzOperator<MType, VType, VType, Comm>;
69 using ScalarProduct = Dune::NonoverlappingSchwarzScalarProduct<VType, Comm>;
70 static constexpr bool isNonOverlapping = true;
71
72 template<class SeqPreconditioner>
73 using Preconditioner = Dune::NonoverlappingBlockPreconditioner<Comm, SeqPreconditioner>;
74};
75
76template <class MType, class VType>
78{
79public:
80 using Matrix = MType;
81 using Vector = VType;
82 using Comm = Dune::OwnerOverlapCopyCommunication<Dune::bigunsignedint<96>, int>;
83 using LinearOperator = Dune::OverlappingSchwarzOperator<MType, VType, VType, Comm>;
84 using ScalarProduct = Dune::OverlappingSchwarzScalarProduct<VType, Comm>;
85 static constexpr bool isNonOverlapping = false;
86
87 template<class SeqPreconditioner>
88 using Preconditioner = Dune::BlockPreconditioner<VType, VType, Comm, SeqPreconditioner>;
89};
90#endif
91
92template<class GridGeometry>
94{
95 using GridView = typename GridGeometry::GridView;
96 using Grid = typename GridGeometry::GridView::Traits::Grid;
97
98 template<class Matrix, class Vector>
100
101#if HAVE_MPI
102 template<class Matrix, class Vector>
104
105 template<class Matrix, class Vector>
107#endif
108};
109
111template<class GridGeometry>
112struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::Box>
113: public LinearSolverTraitsBase<GridGeometry>
114{
115 using DofMapper = typename GridGeometry::VertexMapper;
116 using Grid = typename GridGeometry::GridView::Traits::Grid;
117 static constexpr int dofCodim = Grid::dimension;
118 static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>;
119
120 template<class GridView>
121 static bool isNonOverlapping(const GridView& gridView)
122 { return gridView.overlapSize(0) == 0; }
123};
124
125template<class GridGeometry>
126struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::PQ1Bubble>
127: public LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::Box>
128{
129 using Grid = typename GridGeometry::GridView::Traits::Grid;
130 using DofMapper = typename GridGeometry::DofMapper;
131
132 static constexpr int dofCodim = Grid::dimension;
133 static constexpr std::bitset<Grid::dimension+1> dofCodims{ (1UL << Grid::dimension) + 1UL };
134
135 static const DofMapper& dofMapper(const GridGeometry& gg)
136 { return { gg.dofMapper() }; }
137};
138
140template<class GridGeometry>
141struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCTpfa>
142: public LinearSolverTraitsBase<GridGeometry>
143{
144 using DofMapper = typename GridGeometry::ElementMapper;
145 using Grid = typename GridGeometry::GridView::Traits::Grid;
146 static constexpr int dofCodim = 0;
147 static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>;
148
149 template<class GridView>
150 static bool isNonOverlapping(const GridView& gridView)
151 { return false; }
152};
153
155template<class GridGeometry>
156struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::FCStaggered>
157: public LinearSolverTraitsBase<GridGeometry>
158{
159 class DofMapper
160 {
161 public:
162 DofMapper(const typename GridGeometry::GridView& gridView)
163 : gridView_(gridView) {}
164
165 template<class Entity>
166 auto index(const Entity& e) const
167 { return gridView_.indexSet().index(e); }
168
169 auto size() const
170 { return gridView_.size(1); }
171
172 private:
173 typename GridGeometry::GridView gridView_;
174 };
175
176 static DofMapper dofMapper(const GridGeometry& gg)
177 { return { gg.gridView() }; }
178
179 using Grid = typename GridGeometry::GridView::Traits::Grid;
180 static constexpr int dofCodim = 1;
181
182 // TODO: see above for description of this workaround, remove second line if fixed upstream
183 static constexpr bool canCommunicate =
184 Dune::Capabilities::canCommunicate<Grid, dofCodim>::v
186
187 template<class GridView>
188 static bool isNonOverlapping(const GridView& gridView)
189 {
190 assert(gridView.overlapSize(0) > 0);
191 return false;
192 }
193};
194
196template<class GridGeometry>
197struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::FCDiamond>
198: public LinearSolverTraitsBase<GridGeometry>
199{
200 using DofMapper = typename GridGeometry::DofMapper;
201 using Grid = typename GridGeometry::GridView::Traits::Grid;
202 static constexpr int dofCodim = 1;
203 static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>;
204
205 static const DofMapper& dofMapper(const GridGeometry& gg)
206 { return { gg.dofMapper() }; }
207
208 template<class GridView>
209 static bool isNonOverlapping(const GridView& gridView)
210 { return gridView.overlapSize(0) == 0; }
211};
212
214template<class GridGeometry>
215struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCMpfa>
216: public LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCTpfa> {};
217
219template<class GridGeometry>
220struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::Staggered>
221: public LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCTpfa> {};
222
223} // end namespace Dumux
224
225#endif
DofMapper(const typename GridGeometry::GridView &gridView)
Definition: linearsolvertraits.hh:162
auto index(const Entity &e) const
Definition: linearsolvertraits.hh:166
dune-grid capabilities compatibility layer
The available discretization methods in Dumux.
static constexpr bool canCommunicate
Definition: gridcapabilities.hh:51
CVFE< CVFEMethods::CR_RT > FCDiamond
Definition: method.hh:101
CVFE< CVFEMethods::PQ1 > Box
Definition: method.hh:94
CVFE< CVFEMethods::PQ1Bubble > PQ1Bubble
Definition: method.hh:108
Definition: adapt.hh:17
Definition: linearsolvertraits.hh:94
typename GridGeometry::GridView::Traits::Grid Grid
Definition: linearsolvertraits.hh:96
typename GridGeometry::GridView GridView
Definition: linearsolvertraits.hh:95
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:121
typename GridGeometry::VertexMapper DofMapper
Definition: linearsolvertraits.hh:115
typename GridGeometry::ElementMapper DofMapper
Definition: linearsolvertraits.hh:144
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:150
typename GridGeometry::DofMapper DofMapper
Definition: linearsolvertraits.hh:200
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:209
static const DofMapper & dofMapper(const GridGeometry &gg)
Definition: linearsolvertraits.hh:205
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:188
static DofMapper dofMapper(const GridGeometry &gg)
Definition: linearsolvertraits.hh:176
static const DofMapper & dofMapper(const GridGeometry &gg)
Definition: linearsolvertraits.hh:135
The implementation is specialized for the different discretizations.
Definition: linearsolvertraits.hh:31
Definition: linearsolvertraits.hh:63
Dune::NonoverlappingSchwarzOperator< MType, VType, VType, Comm > LinearOperator
Definition: linearsolvertraits.hh:68
MType Matrix
Definition: linearsolvertraits.hh:65
Dune::NonoverlappingBlockPreconditioner< Comm, SeqPreconditioner > Preconditioner
Definition: linearsolvertraits.hh:73
Dune::NonoverlappingSchwarzScalarProduct< VType, Comm > ScalarProduct
Definition: linearsolvertraits.hh:69
VType Vector
Definition: linearsolvertraits.hh:66
Dune::OwnerOverlapCopyCommunication< Dune::bigunsignedint< 96 >, int > Comm
Definition: linearsolvertraits.hh:67
static constexpr bool isNonOverlapping
Definition: linearsolvertraits.hh:70
Definition: linearsolvertraits.hh:78
static constexpr bool isNonOverlapping
Definition: linearsolvertraits.hh:85
Dune::OverlappingSchwarzOperator< MType, VType, VType, Comm > LinearOperator
Definition: linearsolvertraits.hh:83
MType Matrix
Definition: linearsolvertraits.hh:80
Dune::BlockPreconditioner< VType, VType, Comm, SeqPreconditioner > Preconditioner
Definition: linearsolvertraits.hh:88
VType Vector
Definition: linearsolvertraits.hh:81
Dune::OwnerOverlapCopyCommunication< Dune::bigunsignedint< 96 >, int > Comm
Definition: linearsolvertraits.hh:82
Dune::OverlappingSchwarzScalarProduct< VType, Comm > ScalarProduct
Definition: linearsolvertraits.hh:84
Definition: linearsolvertraits.hh:53
static constexpr bool canCommunicate
Definition: linearsolvertraits.hh:57
sequential solver traits
Definition: linearsolvertraits.hh:42
MType Matrix
Definition: linearsolvertraits.hh:43
VType Vector
Definition: linearsolvertraits.hh:44
Dune::MatrixAdapter< MType, VType, VType > LinearOperator
Definition: linearsolvertraits.hh:45
SeqPreconditioner Preconditioner
Definition: linearsolvertraits.hh:49
Dune::SeqScalarProduct< VType > ScalarProduct
Definition: linearsolvertraits.hh:46
Definition: gridcapabilities.hh:33