3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
amgtraits.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_AMG_TRAITS_HH
25#define DUMUX_AMG_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
35
36// TODO: The following is a temporary solution to make the parallel AMG work
37// for UGGrid. Once it is resolved upstream
38// (https://gitlab.dune-project.org/core/dune-grid/issues/78),
39// it should be guarded by a DUNE_VERSION macro and removed later.
40
41#if HAVE_UG
42#include <dune/grid/uggrid.hh>
43#endif // HAVE_UG
44
45namespace Dumux {
46namespace Temp {
47namespace Capabilities {
48
49template<class Grid, int codim>
51{
52 static const bool v = false;
53};
54
55#if HAVE_UG
56template<int dim, int codim>
57struct canCommunicate<Dune::UGGrid<dim>, codim>
58{
59 static const bool v = true;
60};
61#endif // HAVE_UG
62
63} // namespace Capabilities
64} // namespace Temp
65} // namespace Dumux
66// end workaround
67
68namespace Dumux {
69
71template<class MType, class VType, class GridGeometry, DiscretizationMethod discMethod> struct AmgTraitsImpl;
72
74template<class MType, class VType, class GridGeometry>
76
78template <class MType, class VType, bool isParallel>
80{
81public:
82 using Comm = Dune::Amg::SequentialInformation;
83 using LinearOperator = Dune::MatrixAdapter<MType,VType,VType>;
84 using ScalarProduct = Dune::SeqScalarProduct<VType>;
85 using Smoother = Dune::SeqSSOR<MType,VType, VType>;
86};
87
88#if HAVE_MPI
89template <class MType, class VType>
90class NonoverlappingSolverTraits<MType, VType, true>
91{
92public:
93 using Comm = Dune::OwnerOverlapCopyCommunication<Dune::bigunsignedint<96>,int>;
94 using LinearOperator = Dune::NonoverlappingSchwarzOperator<MType,VType, VType,Comm>;
95 using ScalarProduct = Dune::NonoverlappingSchwarzScalarProduct<VType,Comm>;
96 using Smoother = Dune::NonoverlappingBlockPreconditioner<Comm,Dune::SeqSSOR<MType,VType, VType> >;
97};
98#endif
99
101template<class Matrix, class Vector, class GridGeometry>
102struct AmgTraitsImpl<Matrix, Vector, GridGeometry, DiscretizationMethod::box>
103{
104 using Grid = typename GridGeometry::GridView::Traits::Grid;
105 enum {
106 dofCodim = Grid::dimension,
107 isNonOverlapping = true,
108 // TODO: see above for description of this workaround, remove second line if fixed upstream
109 isParallel = Dune::Capabilities::canCommunicate<Grid, dofCodim>::v
111 };
112 using MType = Matrix;
113 using VType = Dune::BlockVector<Dune::FieldVector<typename Vector::block_type::value_type, Vector::block_type::dimension>>;
115 using Comm = typename SolverTraits::Comm;
119
120 using DofMapper = typename GridGeometry::VertexMapper;
121};
122
124template <class MType, class VType, bool isParallel>
126{
127public:
128 using Comm = Dune::Amg::SequentialInformation;
129 using LinearOperator = Dune::MatrixAdapter<MType,VType,VType>;
130 using ScalarProduct = Dune::SeqScalarProduct<VType>;
131 using Smoother = Dune::SeqSSOR<MType,VType, VType>;
132};
133
134#if HAVE_MPI
135template <class MType, class VType>
136class OverlappingSolverTraits<MType, VType, true>
137{
138public:
139 using Comm = Dune::OwnerOverlapCopyCommunication<Dune::bigunsignedint<96>,int>;
140 using LinearOperator = Dune::OverlappingSchwarzOperator<MType,VType, VType,Comm>;
141 using ScalarProduct = Dune::OverlappingSchwarzScalarProduct<VType,Comm>;
142 using Smoother = Dune::BlockPreconditioner<VType,VType,Comm,Dune::SeqSSOR<MType,VType, VType> >;
143};
144#endif
145
147template<class Matrix, class Vector, class GridGeometry>
148struct AmgTraitsImpl<Matrix, Vector, GridGeometry, DiscretizationMethod::cctpfa>
149{
150 using Grid = typename GridGeometry::GridView::Traits::Grid;
151 enum {
152 dofCodim = 0,
153 isNonOverlapping = false,
154 // TODO: see above for description of this workaround, remove second line if fixed upstream
155 isParallel = Dune::Capabilities::canCommunicate<Grid, dofCodim>::v
157 };
158 using MType = Matrix;
159 using VType = Dune::BlockVector<Dune::FieldVector<typename Vector::block_type::value_type, Vector::block_type::dimension>>;
161 using Comm = typename SolverTraits::Comm;
165
166 using DofMapper = typename GridGeometry::ElementMapper;
167};
168
169template<class Matrix, class Vector, class GridGeometry>
170struct AmgTraitsImpl<Matrix, Vector, GridGeometry, DiscretizationMethod::ccmpfa>
171: public AmgTraitsImpl<Matrix, Vector, GridGeometry, DiscretizationMethod::cctpfa> {};
172
173} // end namespace Dumux
174
175#endif // DUMUX_AMG_TRAITS_HH
The available discretization methods in Dumux.
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Definition: common/properties/model.hh:34
static const bool v
Definition: amgtraits.hh:52
The implementation is specialized for the different discretizations.
Definition: amgtraits.hh:71
NonoverlappingSolverTraits used by discretization with non-overlapping parallel model.
Definition: amgtraits.hh:80
Dune::SeqScalarProduct< VType > ScalarProduct
Definition: amgtraits.hh:84
Dune::SeqSSOR< MType, VType, VType > Smoother
Definition: amgtraits.hh:85
Dune::MatrixAdapter< MType, VType, VType > LinearOperator
Definition: amgtraits.hh:83
Dune::Amg::SequentialInformation Comm
Definition: amgtraits.hh:82
Dune::NonoverlappingBlockPreconditioner< Comm, Dune::SeqSSOR< MType, VType, VType > > Smoother
Definition: amgtraits.hh:96
Dune::OwnerOverlapCopyCommunication< Dune::bigunsignedint< 96 >, int > Comm
Definition: amgtraits.hh:93
Dune::NonoverlappingSchwarzScalarProduct< VType, Comm > ScalarProduct
Definition: amgtraits.hh:95
Dune::NonoverlappingSchwarzOperator< MType, VType, VType, Comm > LinearOperator
Definition: amgtraits.hh:94
typename GridGeometry::GridView::Traits::Grid Grid
Definition: amgtraits.hh:104
Dune::BlockVector< Dune::FieldVector< typename Vector::block_type::value_type, Vector::block_type::dimension > > VType
Definition: amgtraits.hh:113
typename SolverTraits::LinearOperator LinearOperator
Definition: amgtraits.hh:116
typename SolverTraits::Smoother Smoother
Definition: amgtraits.hh:118
typename SolverTraits::ScalarProduct ScalarProduct
Definition: amgtraits.hh:117
typename GridGeometry::VertexMapper DofMapper
Definition: amgtraits.hh:120
typename SolverTraits::Comm Comm
Definition: amgtraits.hh:115
OverlappingSolverTraits used by discretization with overlapping parallel model.
Definition: amgtraits.hh:126
Dune::SeqScalarProduct< VType > ScalarProduct
Definition: amgtraits.hh:130
Dune::MatrixAdapter< MType, VType, VType > LinearOperator
Definition: amgtraits.hh:129
Dune::SeqSSOR< MType, VType, VType > Smoother
Definition: amgtraits.hh:131
Dune::Amg::SequentialInformation Comm
Definition: amgtraits.hh:128
Dune::OverlappingSchwarzScalarProduct< VType, Comm > ScalarProduct
Definition: amgtraits.hh:141
Dune::BlockPreconditioner< VType, VType, Comm, Dune::SeqSSOR< MType, VType, VType > > Smoother
Definition: amgtraits.hh:142
Dune::OwnerOverlapCopyCommunication< Dune::bigunsignedint< 96 >, int > Comm
Definition: amgtraits.hh:139
Dune::OverlappingSchwarzOperator< MType, VType, VType, Comm > LinearOperator
Definition: amgtraits.hh:140
typename SolverTraits::LinearOperator LinearOperator
Definition: amgtraits.hh:162
typename GridGeometry::GridView::Traits::Grid Grid
Definition: amgtraits.hh:150
typename SolverTraits::ScalarProduct ScalarProduct
Definition: amgtraits.hh:163
Dune::BlockVector< Dune::FieldVector< typename Vector::block_type::value_type, Vector::block_type::dimension > > VType
Definition: amgtraits.hh:159
typename GridGeometry::ElementMapper DofMapper
Definition: amgtraits.hh:166
typename SolverTraits::Comm Comm
Definition: amgtraits.hh:161
typename SolverTraits::Smoother Smoother
Definition: amgtraits.hh:164