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"
32#include "istlsolverwrappers.hh"
34
35#include <dune/common/version.hh>
36
37namespace Opm::Properties::TTag {
38
39// Create new type tag
40struct ParallelIstlLinearSolver { using InheritsFrom = std::tuple<ParallelBaseLinearSolver>; };
41
42} // namespace Opm::Properties::TTag
43
44namespace Opm::Linear {
80template <class TypeTag>
82{
84
89
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
101public:
103 : ParentType(simulator)
104 { }
105
109 static void registerParameters()
110 {
112
113 LinearSolverWrapper::registerParameters();
114 }
115
116protected:
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
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
145namespace Opm::Properties {
146
147template<class TypeTag>
148struct LinearSolverBackend<TypeTag, TTag::ParallelIstlLinearSolver>
150
151template<class TypeTag>
152struct LinearSolverWrapper<TypeTag, TTag::ParallelIstlLinearSolver>
153{ using type = Opm::Linear::SolverWrapperBiCGStab<TypeTag>; };
154
155template<class TypeTag>
156struct PreconditionerWrapper<TypeTag, TTag::ParallelIstlLinearSolver>
158
159} // namespace Opm::Properties
160
161#endif
An overlap aware linear operator usable by ISTL.
Definition: overlappingoperator.hh:42
An overlap aware preconditioner for any ISTL linear solver.
Definition: overlappingpreconditioner.hh:48
An overlap aware ISTL scalar product.
Definition: overlappingscalarproduct.hh:42
Provides the common code which is required by most linear solvers.
Definition: parallelbasebackend.hh:109
GetPropType< TypeTag, Properties::OverlappingVector > OverlappingVector
Definition: parallelbasebackend.hh:122
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: parallelbasebackend.hh:114
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: parallelbasebackend.hh:113
Opm::Linear::OverlappingScalarProduct< OverlappingVector, Overlap > ParallelScalarProduct
Definition: parallelbasebackend.hh:129
OverlappingVector * overlappingx_
Definition: parallelbasebackend.hh:383
GetPropType< TypeTag, Properties::SparseMatrixAdapter > SparseMatrixAdapter
Definition: parallelbasebackend.hh:116
static void registerParameters()
Register all run-time parameters for the linear solver.
Definition: parallelbasebackend.hh:153
Opm::Linear::OverlappingOperator< OverlappingMatrix, OverlappingVector, OverlappingVector > ParallelOperator
Definition: parallelbasebackend.hh:132
OverlappingVector * overlappingb_
Definition: parallelbasebackend.hh:382
Opm::Linear::OverlappingPreconditioner< SequentialPreconditioner, Overlap > ParallelPreconditioner
Definition: parallelbasebackend.hh:128
Provides all unmodified linear solvers from dune-istl.
Definition: parallelistlbackend.hh:82
std::pair< bool, int > runSolver_(std::shared_ptr< RawLinearSolver > solver)
Definition: parallelistlbackend.hh:133
void cleanupSolver_()
Definition: parallelistlbackend.hh:128
ParallelIstlSolverBackend(const Simulator &simulator)
Definition: parallelistlbackend.hh:102
std::shared_ptr< RawLinearSolver > prepareSolver_(ParallelOperator &parOperator, ParallelScalarProduct &parScalarProduct, ParallelPreconditioner &parPreCond)
Definition: parallelistlbackend.hh:119
static void registerParameters()
Register all run-time parameters for the linear solver.
Definition: parallelistlbackend.hh:109
friend ParentType
Definition: parallelistlbackend.hh:117
LinearSolverWrapper solverWrapper_
Definition: parallelistlbackend.hh:140
Definition: istlpreconditionerwrappers.hh:153
Provides wrapper classes for the iterative linear solvers available in dune-istl.
Declares the properties required by the black oil model.
Definition: bicgstabsolver.hh:42
The generic type tag for problems using the immiscible multi-phase model.
Definition: blackoilmodel.hh:74
Definition: blackoilmodel.hh:72
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:235
The type of the linear solver to be used.
Definition: linalgproperties.hh:38
Opm::Linear::SolverWrapperBiCGStab< TypeTag > type
Definition: parallelistlbackend.hh:153
Definition: linalgproperties.hh:57
the preconditioner used by the linear solver
Definition: linalgproperties.hh:42
Definition: parallelistlbackend.hh:40
std::tuple< ParallelBaseLinearSolver > InheritsFrom
Definition: parallelistlbackend.hh:40