3.5-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 <dune/istl/schwarz.hh>
28#include <dune/istl/novlpschwarz.hh>
29#include <dune/istl/owneroverlapcopy.hh>
30#include <dune/istl/paamg/pinfo.hh>
31#include <dune/istl/preconditioners.hh>
32#include <dune/grid/common/capabilities.hh>
33
36
37namespace Dumux {
38
40template<class GridGeometry, class DiscretizationMethod>
42
47template<class GridGeometry>
49
51template<class MType, class VType>
53{
54 using Matrix = MType;
55 using Vector = VType;
56 using LinearOperator = Dune::MatrixAdapter<MType, VType, VType>;
57 using ScalarProduct = Dune::SeqScalarProduct<VType>;
58
59 template<class SeqPreconditioner>
60 using Preconditioner = SeqPreconditioner;
61};
62
63#if HAVE_MPI
64template <class MType, class VType>
66{
67public:
68 using Matrix = MType;
69 using Vector = VType;
70 using Comm = Dune::OwnerOverlapCopyCommunication<Dune::bigunsignedint<96>, int>;
71 using LinearOperator = Dune::NonoverlappingSchwarzOperator<MType, VType, VType, Comm>;
72 using ScalarProduct = Dune::NonoverlappingSchwarzScalarProduct<VType, Comm>;
73 static constexpr bool isNonOverlapping = true;
74
75 template<class SeqPreconditioner>
76 using Preconditioner = Dune::NonoverlappingBlockPreconditioner<Comm, SeqPreconditioner>;
77};
78
79template <class MType, class VType>
81{
82public:
83 using Matrix = MType;
84 using Vector = VType;
85 using Comm = Dune::OwnerOverlapCopyCommunication<Dune::bigunsignedint<96>, int>;
86 using LinearOperator = Dune::OverlappingSchwarzOperator<MType, VType, VType, Comm>;
87 using ScalarProduct = Dune::OverlappingSchwarzScalarProduct<VType, Comm>;
88 static constexpr bool isNonOverlapping = false;
89
90 template<class SeqPreconditioner>
91 using Preconditioner = Dune::BlockPreconditioner<VType, VType, Comm, SeqPreconditioner>;
92};
93#endif
94
95template<class GridGeometry>
97{
98 using GridView = typename GridGeometry::GridView;
99 using Grid = typename GridGeometry::GridView::Traits::Grid;
100
101 template<class Matrix, class Vector>
103
104#if HAVE_MPI
105 template<class Matrix, class Vector>
107
108 template<class Matrix, class Vector>
110#endif
111};
112
114template<class GridGeometry>
115struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::Box>
116: public LinearSolverTraitsBase<GridGeometry>
117{
118 using DofMapper = typename GridGeometry::VertexMapper;
119 using Grid = typename GridGeometry::GridView::Traits::Grid;
120 static constexpr int dofCodim = Grid::dimension;
121 static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>;
122
123 template<class GridView>
124 static bool isNonOverlapping(const GridView& gridView)
125 { return gridView.overlapSize(0) == 0; }
126};
127
129template<class GridGeometry>
130struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCTpfa>
131: public LinearSolverTraitsBase<GridGeometry>
132{
133 using DofMapper = typename GridGeometry::ElementMapper;
134 using Grid = typename GridGeometry::GridView::Traits::Grid;
135 static constexpr int dofCodim = 0;
136 static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>;
137
138 template<class GridView>
139 static bool isNonOverlapping(const GridView& gridView)
140 { return false; }
141};
142
144template<class GridGeometry>
145struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::FCStaggered>
146: public LinearSolverTraitsBase<GridGeometry>
147{
148 class DofMapper
149 {
150 public:
151 DofMapper(const typename GridGeometry::GridView& gridView)
152 : gridView_(gridView) {}
153
154 auto index(const typename GridGeometry::GridView::Intersection& intersection) const
155 { return gridView_.indexSet().index(intersection); }
156
157 template<class Entity>
158 auto index(const Entity& e) const
159 { return gridView_.indexSet().index(e); }
160
161 auto size() const
162 { return gridView_.size(1); }
163
164 private:
165 typename GridGeometry::GridView gridView_;
166 };
167
168 using Grid = typename GridGeometry::GridView::Traits::Grid;
169 static constexpr int dofCodim = 1;
170
171 // TODO: see above for description of this workaround, remove second line if fixed upstream
172 static constexpr bool canCommunicate =
173 Dune::Capabilities::canCommunicate<Grid, dofCodim>::v
175
176 template<class GridView>
177 static bool isNonOverlapping(const GridView& gridView)
178 {
179 assert(gridView.overlapSize(0) > 0);
180 return false;
181 }
182};
183
185template<class GridGeometry>
186struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCMpfa>
187: public LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCTpfa> {};
188
190template<class GridGeometry>
191struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::Staggered>
192: public LinearSolverTraitsImpl<GridGeometry, DiscretizationMethods::CCTpfa> {};
193
194} // end namespace Dumux
195
196#endif
dune-grid capabilities compatibility layer
The available discretization methods in Dumux.
Definition: adapt.hh:29
static constexpr bool canCommunicate
Definition: gridcapabilities.hh:63
Definition: gridcapabilities.hh:45
The implementation is specialized for the different discretizations.
Definition: linearsolvertraits.hh:41
sequential solver traits
Definition: linearsolvertraits.hh:53
MType Matrix
Definition: linearsolvertraits.hh:54
VType Vector
Definition: linearsolvertraits.hh:55
Dune::MatrixAdapter< MType, VType, VType > LinearOperator
Definition: linearsolvertraits.hh:56
SeqPreconditioner Preconditioner
Definition: linearsolvertraits.hh:60
Dune::SeqScalarProduct< VType > ScalarProduct
Definition: linearsolvertraits.hh:57
Definition: linearsolvertraits.hh:66
Dune::NonoverlappingSchwarzOperator< MType, VType, VType, Comm > LinearOperator
Definition: linearsolvertraits.hh:71
MType Matrix
Definition: linearsolvertraits.hh:68
Dune::NonoverlappingBlockPreconditioner< Comm, SeqPreconditioner > Preconditioner
Definition: linearsolvertraits.hh:76
Dune::NonoverlappingSchwarzScalarProduct< VType, Comm > ScalarProduct
Definition: linearsolvertraits.hh:72
VType Vector
Definition: linearsolvertraits.hh:69
Dune::OwnerOverlapCopyCommunication< Dune::bigunsignedint< 96 >, int > Comm
Definition: linearsolvertraits.hh:70
static constexpr bool isNonOverlapping
Definition: linearsolvertraits.hh:73
Definition: linearsolvertraits.hh:81
static constexpr bool isNonOverlapping
Definition: linearsolvertraits.hh:88
Dune::OverlappingSchwarzOperator< MType, VType, VType, Comm > LinearOperator
Definition: linearsolvertraits.hh:86
MType Matrix
Definition: linearsolvertraits.hh:83
Dune::BlockPreconditioner< VType, VType, Comm, SeqPreconditioner > Preconditioner
Definition: linearsolvertraits.hh:91
VType Vector
Definition: linearsolvertraits.hh:84
Dune::OwnerOverlapCopyCommunication< Dune::bigunsignedint< 96 >, int > Comm
Definition: linearsolvertraits.hh:85
Dune::OverlappingSchwarzScalarProduct< VType, Comm > ScalarProduct
Definition: linearsolvertraits.hh:87
Definition: linearsolvertraits.hh:97
typename GridGeometry::GridView::Traits::Grid Grid
Definition: linearsolvertraits.hh:99
typename GridGeometry::GridView GridView
Definition: linearsolvertraits.hh:98
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:124
typename GridGeometry::VertexMapper DofMapper
Definition: linearsolvertraits.hh:118
typename GridGeometry::ElementMapper DofMapper
Definition: linearsolvertraits.hh:133
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:139
static bool isNonOverlapping(const GridView &gridView)
Definition: linearsolvertraits.hh:177
DofMapper(const typename GridGeometry::GridView &gridView)
Definition: linearsolvertraits.hh:151
auto index(const typename GridGeometry::GridView::Intersection &intersection) const
Definition: linearsolvertraits.hh:154
auto index(const Entity &e) const
Definition: linearsolvertraits.hh:158