3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * 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 *****************************************************************************/
24#ifndef DUMUX_LINEAR_SOLVER_TRAITS_HH
25#define DUMUX_LINEAR_SOLVER_TRAITS_HH
26
27#include <bitset>
28
29#include <dune/istl/schwarz.hh>
30#include <dune/istl/novlpschwarz.hh>
31#include <dune/istl/owneroverlapcopy.hh>
32#include <dune/istl/paamg/pinfo.hh>
33#include <dune/istl/preconditioners.hh>
34#include <dune/grid/common/capabilities.hh>
35
38
39namespace Dumux {
40
42template<class GridGeometry, class DiscretizationMethod>
44
48template<class GridGeometry>
50
52template<class MType, class VType>
54{
55 using Matrix = MType;
56 using Vector = VType;
57 using LinearOperator = Dune::MatrixAdapter<MType, VType, VType>;
58 using ScalarProduct = Dune::SeqScalarProduct<VType>;
59
60 template<class SeqPreconditioner>
61 using Preconditioner = SeqPreconditioner;
62};
63
64#if HAVE_MPI
65template <class MType, class VType>
67{
68public:
69 using Matrix = MType;
70 using Vector = VType;
71 using Comm = Dune::OwnerOverlapCopyCommunication<Dune::bigunsignedint<96>, int>;
72 using LinearOperator = Dune::NonoverlappingSchwarzOperator<MType, VType, VType, Comm>;
73 using ScalarProduct = Dune::NonoverlappingSchwarzScalarProduct<VType, Comm>;
74 static constexpr bool isNonOverlapping = true;
75
76 template<class SeqPreconditioner>
77 using Preconditioner = Dune::NonoverlappingBlockPreconditioner<Comm, SeqPreconditioner>;
78};
79
80template <class MType, class VType>
82{
83public:
84 using Matrix = MType;
85 using Vector = VType;
86 using Comm = Dune::OwnerOverlapCopyCommunication<Dune::bigunsignedint<96>, int>;
87 using LinearOperator = Dune::OverlappingSchwarzOperator<MType, VType, VType, Comm>;
88 using ScalarProduct = Dune::OverlappingSchwarzScalarProduct<VType, Comm>;
89 static constexpr bool isNonOverlapping = false;
90
91 template<class SeqPreconditioner>
92 using Preconditioner = Dune::BlockPreconditioner<VType, VType, Comm, SeqPreconditioner>;
93};
94#endif
95
96template<class GridGeometry>
98{
99 using GridView = typename GridGeometry::GridView;
100 using Grid = typename GridGeometry::GridView::Traits::Grid;
101
102 template<class Matrix, class Vector>
104
105#if HAVE_MPI
106 template<class Matrix, class Vector>
108
109 template<class Matrix, class Vector>
111#endif
112};
113
115template<class GridGeometry>
116struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::Box>
117: public LinearSolverTraitsBase<GridGeometry>
118{
119 using DofMapper = typename GridGeometry::VertexMapper;
120 using Grid = typename GridGeometry::GridView::Traits::Grid;
121 static constexpr int dofCodim = Grid::dimension;
122 static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>;
123
124 template<class GridView>
125 static bool isNonOverlapping(const GridView& gridView)
126 { return gridView.overlapSize(0) == 0; }
127};
128
129template<class GridGeometry>
130struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::PQ1Bubble>
131: public LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::Box>
132{
133 using Grid = typename GridGeometry::GridView::Traits::Grid;
134 using DofMapper = typename GridGeometry::DofMapper;
135
136 static constexpr int dofCodim = Grid::dimension;
137 static constexpr std::bitset<Grid::dimension+1> dofCodims{ (1UL << Grid::dimension) + 1UL };
138
139 static const DofMapper& dofMapper(const GridGeometry& gg)
140 { return { gg.dofMapper() }; }
141};
142
144template<class GridGeometry>
145struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCTpfa>
146: public LinearSolverTraitsBase<GridGeometry>
147{
148 using DofMapper = typename GridGeometry::ElementMapper;
149 using Grid = typename GridGeometry::GridView::Traits::Grid;
150 static constexpr int dofCodim = 0;
151 static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>;
152
153 template<class GridView>
154 static bool isNonOverlapping(const GridView& gridView)
155 { return false; }
156};
157
159template<class GridGeometry>
160struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::FCStaggered>
161: public LinearSolverTraitsBase<GridGeometry>
162{
163 class DofMapper
164 {
165 public:
166 DofMapper(const typename GridGeometry::GridView& gridView)
167 : gridView_(gridView) {}
168
169 template<class Entity>
170 auto index(const Entity& e) const
171 { return gridView_.indexSet().index(e); }
172
173 auto size() const
174 { return gridView_.size(1); }
175
176 private:
177 typename GridGeometry::GridView gridView_;
178 };
179
180 static DofMapper dofMapper(const GridGeometry& gg)
181 { return { gg.gridView() }; }
182
183 using Grid = typename GridGeometry::GridView::Traits::Grid;
184 static constexpr int dofCodim = 1;
185
186 // TODO: see above for description of this workaround, remove second line if fixed upstream
187 static constexpr bool canCommunicate =
188 Dune::Capabilities::canCommunicate<Grid, dofCodim>::v
190
191 template<class GridView>
192 static bool isNonOverlapping(const GridView& gridView)
193 {
194 assert(gridView.overlapSize(0) > 0);
195 return false;
196 }
197};
198
200template<class GridGeometry>
201struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::FCDiamond>
202: public LinearSolverTraitsBase<GridGeometry>
203{
204 using DofMapper = typename GridGeometry::DofMapper;
205 using Grid = typename GridGeometry::GridView::Traits::Grid;
206 static constexpr int dofCodim = 1;
207 static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>;
208
209 static const DofMapper& dofMapper(const GridGeometry& gg)
210 { return { gg.dofMapper() }; }
211
212 template<class GridView>
213 static bool isNonOverlapping(const GridView& gridView)
214 { return gridView.overlapSize(0) == 0; }
215};
216
218template<class GridGeometry>
219struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCMpfa>
220: public LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCTpfa> {};
221
223template<class GridGeometry>
224struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::Staggered>
225: public LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCTpfa> {};
226
227} // end namespace Dumux
228
229#endif
dune-grid capabilities compatibility layer
The available discretization methods in Dumux.
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
static constexpr bool canCommunicate
Definition: gridcapabilities.hh:63
CVFE< CVFEMethods::CR_RT > FCDiamond
Definition: method.hh:90
CVFE< CVFEMethods::PQ1 > Box
Definition: method.hh:83
CVFE< CVFEMethods::PQ1Bubble > PQ1Bubble
Definition: method.hh:97
Definition: gridcapabilities.hh:45
The implementation is specialized for the different discretizations.
Definition: linearsolvertraits.hh:43
sequential solver traits
Definition: linearsolvertraits.hh:54
MType Matrix
Definition: linearsolvertraits.hh:55
VType Vector
Definition: linearsolvertraits.hh:56
Dune::MatrixAdapter< MType, VType, VType > LinearOperator
Definition: linearsolvertraits.hh:57
SeqPreconditioner Preconditioner
Definition: linearsolvertraits.hh:61
Dune::SeqScalarProduct< VType > ScalarProduct
Definition: linearsolvertraits.hh:58
Definition: linearsolvertraits.hh:67
Dune::NonoverlappingSchwarzOperator< MType, VType, VType, Comm > LinearOperator
Definition: linearsolvertraits.hh:72
MType Matrix
Definition: linearsolvertraits.hh:69
Dune::NonoverlappingBlockPreconditioner< Comm, SeqPreconditioner > Preconditioner
Definition: linearsolvertraits.hh:77
Dune::NonoverlappingSchwarzScalarProduct< VType, Comm > ScalarProduct
Definition: linearsolvertraits.hh:73
VType Vector
Definition: linearsolvertraits.hh:70
Dune::OwnerOverlapCopyCommunication< Dune::bigunsignedint< 96 >, int > Comm
Definition: linearsolvertraits.hh:71
static constexpr bool isNonOverlapping
Definition: linearsolvertraits.hh:74
Definition: linearsolvertraits.hh:82
static constexpr bool isNonOverlapping
Definition: linearsolvertraits.hh:89
Dune::OverlappingSchwarzOperator< MType, VType, VType, Comm > LinearOperator
Definition: linearsolvertraits.hh:87
MType Matrix
Definition: linearsolvertraits.hh:84
Dune::BlockPreconditioner< VType, VType, Comm, SeqPreconditioner > Preconditioner
Definition: linearsolvertraits.hh:92
VType Vector
Definition: linearsolvertraits.hh:85
Dune::OwnerOverlapCopyCommunication< Dune::bigunsignedint< 96 >, int > Comm
Definition: linearsolvertraits.hh:86
Dune::OverlappingSchwarzScalarProduct< VType, Comm > ScalarProduct
Definition: linearsolvertraits.hh:88
Definition: linearsolvertraits.hh:98
typename GridGeometry::GridView::Traits::Grid Grid
Definition: linearsolvertraits.hh:100
typename GridGeometry::GridView GridView
Definition: linearsolvertraits.hh:99
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:125
typename GridGeometry::VertexMapper DofMapper
Definition: linearsolvertraits.hh:119
static const DofMapper & dofMapper(const GridGeometry &gg)
Definition: linearsolvertraits.hh:139
typename GridGeometry::ElementMapper DofMapper
Definition: linearsolvertraits.hh:148
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:154
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:192
static DofMapper dofMapper(const GridGeometry &gg)
Definition: linearsolvertraits.hh:180
DofMapper(const typename GridGeometry::GridView &gridView)
Definition: linearsolvertraits.hh:166
auto index(const Entity &e) const
Definition: linearsolvertraits.hh:170
typename GridGeometry::DofMapper DofMapper
Definition: linearsolvertraits.hh:204
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:213
static const DofMapper & dofMapper(const GridGeometry &gg)
Definition: linearsolvertraits.hh:209