elasticity_preconditioners.hpp
Go to the documentation of this file.
1//==============================================================================
11//==============================================================================
12#ifndef ELASTICITY_PRECONDITIONERS_HPP_
13#define ELASTICITY_PRECONDITIONERS_HPP_
14
15#include <opm/common/utility/platform_dependent/disable_warnings.h>
16
17#include <dune/common/fmatrix.hh>
18#include <dune/istl/bcrsmatrix.hh>
19#include <dune/istl/matrixmatrix.hh>
20#include <dune/istl/ilu.hh>
21#include <dune/istl/solvers.hh>
22#include <dune/istl/preconditioners.hh>
23#include <dune/istl/superlu.hh>
24#include <dune/istl/umfpack.hh>
25#include <dune/istl/paamg/amg.hh>
26#include <dune/istl/paamg/fastamg.hh>
27#include <dune/istl/paamg/twolevelmethod.hh>
28#include <dune/istl/overlappingschwarz.hh>
29
30#include <opm/common/utility/platform_dependent/reenable_warnings.h>
31
32#include <opm/grid/CpGrid.hpp>
35
36
37namespace Opm {
38namespace Elasticity {
39
40#if defined(HAVE_SUITESPARSE_UMFPACK)
41typedef Dune::UMFPack<Matrix> LUSolver;
42#elif defined(HAVE_SUPERLU)
43typedef Dune::SuperLU<Matrix> LUSolver;
44#else
45static_assert(false, "Enable either SuperLU or UMFPACK");
46#endif
47
49typedef Dune::MatrixAdapter<Matrix,Vector,Vector> Operator;
50
52typedef Dune::SeqSSOR<Matrix, Vector, Vector> SSORSmoother;
53
55typedef Dune::SeqJac<Matrix, Vector, Vector> JACSmoother;
56
58typedef Dune::SeqILU<Matrix, Vector, Vector> ILUSmoother;
59
61typedef Dune::SeqOverlappingSchwarz<Matrix,Vector,
62 Dune::SymmetricMultiplicativeSchwarzMode, LUSolver> SchwarzSmoother;
63
65struct Schwarz {
66 typedef Dune::SeqOverlappingSchwarz<Matrix, Vector,
67 Dune::SymmetricMultiplicativeSchwarzMode,
68 LUSolver> type;
78 static std::shared_ptr<type>
79 setup(int /* pre */, int /* post */, int /* target */, int /* zcells */,
80 std::shared_ptr<Operator>& op, const Dune::CpGrid& gv,
81 ASMHandler<Dune::CpGrid>& A, bool& copy)
82 {
83 return std::shared_ptr<type>(setup2(op, gv, A, copy));
84 }
85
91 static type* setup2(std::shared_ptr<Operator>& op, const Dune::CpGrid& gv,
92 ASMHandler<Dune::CpGrid>& A, bool& copy);
93};
94
96template<class Smoother>
97struct AMG1 {
99 typedef Dune::Amg::FirstDiagonal CouplingMetric;
100
102 typedef Dune::Amg::SymmetricCriterion<Matrix, CouplingMetric> CritBase;
103
105 typedef Dune::Amg::CoarsenCriterion<CritBase> Criterion;
106
107 typedef Dune::Amg::AMG<Operator, Vector, Smoother> type;
108
117 static std::shared_ptr<type>
118 setup(int pre, int post, int target, int zcells,
119 std::shared_ptr<Operator>& op, const Dune::CpGrid& /* gv */,
120 ASMHandler<Dune::CpGrid>& /* A */, bool& copy)
121 {
122 Criterion crit;
124 args.relaxationFactor = 1.0;
125 crit.setCoarsenTarget(target);
126 crit.setGamma(1);
127 crit.setNoPreSmoothSteps(pre);
128 crit.setNoPostSmoothSteps(post);
129 crit.setDefaultValuesIsotropic(3, zcells);
130
131 std::cout << "\t collapsing 2x2x" << zcells << " cells per level" << std::endl;
132 copy = true;
133 return std::shared_ptr<type>(new type(*op, crit, args));
134 }
135};
136
138struct FastAMG {
139 typedef Dune::Amg::FastAMG<Operator, Vector> type;
140
150 static std::shared_ptr<type>
151 setup(int pre, int post, int target, int zcells,
152 std::shared_ptr<Operator>& op, const Dune::CpGrid& gv,
153 ASMHandler<Dune::CpGrid>& A, bool& copy);
154};
155
156
158 template<class Smoother>
159struct AMG2Level {
161 typedef Dune::Amg::AggregationLevelTransferPolicy<Operator,
163
164 typedef Dune::Amg::LevelTransferPolicy<Operator, Operator> LevelTransferPolicy;
165
166 typedef Dune::Amg::OneStepAMGCoarseSolverPolicy<Operator, Smoother,
168
169 typedef typename Dune::Amg::SmootherTraits<Smoother>::Arguments SmootherArgs;
170
171 typedef Dune::Amg::TwoLevelMethod<Operator, CoarsePolicy, Schwarz::type> type;
172
182 static std::shared_ptr<type>
183 setup(int pre, int post, int target, int zcells,
184 std::shared_ptr<Operator>& op, const Dune::CpGrid& gv,
185 ASMHandler<Dune::CpGrid>& A, bool& copy)
186 {
187 typename AMG1<Smoother>::Criterion crit;
188 SmootherArgs args;
189 args.relaxationFactor = 1.0;
190 crit.setCoarsenTarget(target);
191 crit.setGamma(1);
192 crit.setNoPreSmoothSteps(pre);
193 crit.setNoPostSmoothSteps(post);
194 crit.setDefaultValuesIsotropic(3, zcells);
195 CoarsePolicy coarsePolicy(args, crit);
196 TransferPolicy policy(crit);
197 std::shared_ptr<Schwarz::type> fsp(Schwarz::setup2(op, gv, A, copy));
198 copy = true;
199 return std::shared_ptr<type>(new type(*op, fsp, policy, coarsePolicy, pre, post));
200 }
201};
202
203}
204}
205
206#endif
Class handling finite element assembly.
Class handling finite element assembly.
Definition: asmhandler.hpp:35
Helper class with some matrix operations.
Dune::MatrixAdapter< Matrix, Vector, Vector > Operator
A linear operator.
Definition: elasticity_preconditioners.hpp:49
Dune::SeqJac< Matrix, Vector, Vector > JACSmoother
GJ AMG smoother.
Definition: elasticity_preconditioners.hpp:55
Dune::BCRSMatrix< Dune::FieldMatrix< double, 1, 1 > > Matrix
A sparse matrix holding our operator.
Definition: matrixops.hpp:27
Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector
A vector holding our RHS.
Definition: matrixops.hpp:33
Dune::SeqOverlappingSchwarz< Matrix, Vector, Dune::SymmetricMultiplicativeSchwarzMode, LUSolver > SchwarzSmoother
Schwarz + ILU0 AMG smoother.
Definition: elasticity_preconditioners.hpp:62
Smoother
Smoother used in the AMG.
Definition: elasticity_upscale.hpp:75
Dune::SeqSSOR< Matrix, Vector, Vector > SSORSmoother
SSOR AMG smoother.
Definition: elasticity_preconditioners.hpp:52
Dune::SeqILU< Matrix, Vector, Vector > ILUSmoother
ILU0 AMG smoother.
Definition: elasticity_preconditioners.hpp:58
Definition: ImplicitAssembly.hpp:43
An AMG.
Definition: elasticity_preconditioners.hpp:97
Dune::Amg::CoarsenCriterion< CritBase > Criterion
The coarsening criterion used in the AMG.
Definition: elasticity_preconditioners.hpp:105
Dune::Amg::FirstDiagonal CouplingMetric
The coupling metric used in the AMG.
Definition: elasticity_preconditioners.hpp:99
static std::shared_ptr< type > setup(int pre, int post, int target, int zcells, std::shared_ptr< Operator > &op, const Dune::CpGrid &, ASMHandler< Dune::CpGrid > &, bool &copy)
Setup preconditioner.
Definition: elasticity_preconditioners.hpp:118
Dune::Amg::AMG< Operator, Vector, Smoother > type
Definition: elasticity_preconditioners.hpp:107
Dune::Amg::SymmetricCriterion< Matrix, CouplingMetric > CritBase
The coupling criterion used in the AMG.
Definition: elasticity_preconditioners.hpp:102
A two-level method with a coarse AMG solver.
Definition: elasticity_preconditioners.hpp:159
Dune::Amg::SmootherTraits< Smoother >::Arguments SmootherArgs
Definition: elasticity_preconditioners.hpp:169
Dune::Amg::OneStepAMGCoarseSolverPolicy< Operator, Smoother, typename AMG1< Smoother >::Criterion > CoarsePolicy
Definition: elasticity_preconditioners.hpp:167
Dune::Amg::LevelTransferPolicy< Operator, Operator > LevelTransferPolicy
Definition: elasticity_preconditioners.hpp:164
Dune::Amg::AggregationLevelTransferPolicy< Operator, typename AMG1< Smoother >::Criterion > TransferPolicy
AMG transfer policy.
Definition: elasticity_preconditioners.hpp:162
static std::shared_ptr< type > setup(int pre, int post, int target, int zcells, std::shared_ptr< Operator > &op, const Dune::CpGrid &gv, ASMHandler< Dune::CpGrid > &A, bool &copy)
Setup preconditioner.
Definition: elasticity_preconditioners.hpp:183
Dune::Amg::TwoLevelMethod< Operator, CoarsePolicy, Schwarz::type > type
Definition: elasticity_preconditioners.hpp:171
A FastAMG.
Definition: elasticity_preconditioners.hpp:138
static std::shared_ptr< type > setup(int pre, int post, int target, int zcells, std::shared_ptr< Operator > &op, const Dune::CpGrid &gv, ASMHandler< Dune::CpGrid > &A, bool &copy)
Setup preconditioner.
Dune::Amg::FastAMG< Operator, Vector > type
Definition: elasticity_preconditioners.hpp:139
Overlapping Schwarz preconditioner.
Definition: elasticity_preconditioners.hpp:65
static std::shared_ptr< type > setup(int, int, int, int, std::shared_ptr< Operator > &op, const Dune::CpGrid &gv, ASMHandler< Dune::CpGrid > &A, bool &copy)
Setup preconditioner.
Definition: elasticity_preconditioners.hpp:79
static type * setup2(std::shared_ptr< Operator > &op, const Dune::CpGrid &gv, ASMHandler< Dune::CpGrid > &A, bool &copy)
Setup preconditioner.
Dune::SeqOverlappingSchwarz< Matrix, Vector, Dune::SymmetricMultiplicativeSchwarzMode, LUSolver > type
Definition: elasticity_preconditioners.hpp:68