All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
parallelistlbackend.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  This file is part of the Open Porous Media project (OPM).
5 
6  OPM 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 2 of the License, or
9  (at your option) any later version.
10 
11  OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
27 #ifndef EWOMS_PARALLEL_ISTL_BACKEND_HH
28 #define EWOMS_PARALLEL_ISTL_BACKEND_HH
29 
30 #include "parallelbasebackend.hh"
31 #include "istlsolverwrappers.hh"
32 
33 namespace Ewoms {
34 namespace Properties {
35 NEW_TYPE_TAG(ParallelIstlLinearSolver, INHERITS_FROM(ParallelBaseLinearSolver));
36 
37 NEW_PROP_TAG(LinearSolverWrapper);
38 
40 NEW_PROP_TAG(GMResRestart);
41 } // namespace Properties
42 } // namespace Ewoms
43 
44 namespace Ewoms {
45 namespace Linear {
79 template <class TypeTag>
81 {
83 
84  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
85  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
86  typedef typename GET_PROP_TYPE(TypeTag, LinearSolverWrapper) LinearSolverWrapper;
87 
89  typedef typename ParentType::OverlappingVector OverlappingVector;
92 
93  typedef typename LinearSolverWrapper::RawSolver RawLinearSolver;
94 
95  typedef typename GET_PROP_TYPE(TypeTag, JacobianMatrix) Matrix;
96  typedef typename GET_PROP_TYPE(TypeTag, GlobalEqVector) Vector;
97 
98 public:
99  ParallelIstlSolverBackend(const Simulator& simulator)
100  : ParentType(simulator)
101  { }
102 
106  static void registerParameters()
107  {
109 
110  LinearSolverWrapper::registerParameters();
111  }
112 
113 protected:
114  friend ParentType;
115 
116  std::shared_ptr<RawLinearSolver> prepareSolver_(ParallelOperator& parOperator,
117  ParallelScalarProduct& parScalarProduct,
118  ParallelPreconditioner& parPreCond)
119  {
120  return solverWrapper_.get(parOperator,
121  parScalarProduct,
122  parPreCond);
123  }
124 
125  void cleanupSolver_()
126  {
127  solverWrapper_.cleanup();
128  }
129 
130  bool runSolver_(std::shared_ptr<RawLinearSolver> solver)
131  {
132  Dune::InverseOperatorResult result;
133  solver->apply(*this->overlappingx_, *this->overlappingb_, result);
134  return result.converged;
135  }
136 
137  LinearSolverWrapper solverWrapper_;
138 };
139 
140 }} // namespace Linear, Ewoms
141 
142 namespace Ewoms {
143 namespace Properties {
144 SET_TYPE_PROP(ParallelIstlLinearSolver,
145  LinearSolverBackend,
147 
148 SET_TYPE_PROP(ParallelIstlLinearSolver,
149  LinearSolverWrapper,
150  Ewoms::Linear::SolverWrapperBiCGStab<TypeTag>);
151 
152 SET_TYPE_PROP(ParallelIstlLinearSolver,
153  PreconditionerWrapper,
154  Ewoms::Linear::PreconditionerWrapperILU0<TypeTag>);
155 
157 SET_INT_PROP(ParallelIstlLinearSolver, GMResRestart, 10);
158 }} // namespace Properties, Ewoms
159 
160 #endif
An overlap aware ISTL scalar product.
Definition: overlappingscalarproduct.hh:41
Provides all unmodified linear solvers from dune-istl.
Definition: parallelistlbackend.hh:80
An overlap aware linear operator usable by ISTL.
Definition: overlappingoperator.hh:39
#define NEW_TYPE_TAG(...)
Define a new type tag.
Definition: propertysystem.hh:169
Provides the common code which is required by most linear solvers.
Definition: parallelbasebackend.hh:142
#define INHERITS_FROM(...)
Syntactic sugar for NEW_TYPE_TAG.
Definition: propertysystem.hh:230
#define SET_INT_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant integer value.
Definition: propertysystem.hh:345
static void registerParameters()
Register all run-time parameters for the linear solver.
Definition: parallelbasebackend.hh:187
static void registerParameters()
Register all run-time parameters for the linear solver.
Definition: parallelistlbackend.hh:106
An overlap aware preconditioner for any ISTL linear solver.
Definition: overlappingpreconditioner.hh:44
Provides wrapper classes for the iterative linear solvers available in dune-istl. ...
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377
Provides the common code which is required by most linear solvers.