opm-simulators
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 "linalgproperties.hh"
31 #include "parallelbasebackend.hh"
32 #include "istlsolverwrappers.hh"
34 
35 #include <dune/common/version.hh>
36 
37 namespace Opm::Properties::TTag {
38 
39 // Create new type tag
40 struct ParallelIstlLinearSolver { using InheritsFrom = std::tuple<ParallelBaseLinearSolver>; };
41 
42 } // namespace Opm::Properties::TTag
43 
44 namespace Opm::Linear {
80 template <class TypeTag>
82 {
84 
89 
91  using OverlappingVector = typename ParentType::OverlappingVector;
94 
95  using MatrixBlock = typename SparseMatrixAdapter::MatrixBlock;
96  using RawLinearSolver = typename LinearSolverWrapper::RawSolver;
97 
98  static_assert(std::is_same<SparseMatrixAdapter, IstlSparseMatrixAdapter<MatrixBlock> >::value,
99  "The ParallelIstlSolverBackend linear solver backend requires the IstlSparseMatrixAdapter");
100 
101 public:
102  explicit ParallelIstlSolverBackend(const Simulator& simulator)
103  : ParentType(simulator)
104  { }
105 
109  static void registerParameters()
110  {
112 
113  LinearSolverWrapper::registerParameters();
114  }
115 
116 protected:
117  friend ParentType;
118 
119  std::shared_ptr<RawLinearSolver> prepareSolver_(ParallelOperator& parOperator,
120  ParallelScalarProduct& parScalarProduct,
121  ParallelPreconditioner& parPreCond)
122  {
123  return solverWrapper_.get(parOperator,
124  parScalarProduct,
125  parPreCond);
126  }
127 
128  void cleanupSolver_()
129  {
130  solverWrapper_.cleanup();
131  }
132 
133  std::pair<bool, int> runSolver_(std::shared_ptr<RawLinearSolver> solver)
134  {
135  Dune::InverseOperatorResult result;
136  solver->apply(*this->overlappingx_, *this->overlappingb_, result);
137  return std::make_pair(result.converged, result.iterations);
138  }
139 
140  LinearSolverWrapper solverWrapper_;
141 };
142 
143 } // namespace Opm::Linear
144 
145 namespace Opm::Properties {
146 
147 template<class TypeTag>
148 struct LinearSolverBackend<TypeTag, TTag::ParallelIstlLinearSolver>
150 
151 template<class TypeTag>
152 struct LinearSolverWrapper<TypeTag, TTag::ParallelIstlLinearSolver>
153 { using type = Opm::Linear::SolverWrapperBiCGStab<TypeTag>; };
154 
155 template<class TypeTag>
156 struct PreconditionerWrapper<TypeTag, TTag::ParallelIstlLinearSolver>
158 
159 } // namespace Opm::Properties
160 
161 #endif
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(...))
Definition: propertysystem.hh:233
Provides the common code which is required by most linear solvers.
Definition: parallelbasebackend.hh:108
Provides all unmodified linear solvers from dune-istl.
Definition: parallelistlbackend.hh:81
Definition: parallelistlbackend.hh:40
An overlap aware preconditioner for any ISTL linear solver.
Definition: overlappingpreconditioner.hh:45
the preconditioner used by the linear solver
Definition: linalgproperties.hh:42
static void registerParameters()
Register all run-time parameters for the linear solver.
Definition: parallelistlbackend.hh:109
Definition: istlpreconditionerwrappers.hh:152
A sparse matrix interface backend for BCRSMatrix from dune-istl.
Definition: bicgstabsolver.hh:42
static void registerParameters()
Register all run-time parameters for the linear solver.
Definition: parallelbasebackend.hh:153
An overlap aware ISTL scalar product.
Definition: overlappingscalarproduct.hh:40
Provides wrapper classes for the iterative linear solvers available in dune-istl. ...
The generic type tag for problems using the immiscible multi-phase model.
Definition: blackoilmodel.hh:82
A sparse matrix interface backend for BCRSMatrix from dune-istl.
Definition: istlsparsematrixadapter.hh:42
Definition: blackoilmodel.hh:80
Definition: linalgproperties.hh:57
Declares the properties required by the black oil model.
An overlap aware linear operator usable by ISTL.
Definition: overlappingoperator.hh:40
The type of the linear solver to be used.
Definition: linalgproperties.hh:38
Provides the common code which is required by most linear solvers.