TpsaPreconditionerFactory.hpp
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 Copyright 2025 NORCE AS
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20*/
21#ifndef OPM_TPSA_PRECONDITIONER_FACTORY_HPP
22#define OPM_TPSA_PRECONDITIONER_FACTORY_HPP
23
24#include <dune/istl/operators.hh>
25#include <dune/istl/paamg/pinfo.hh>
26
31
32#include <cstddef>
33#include <functional>
34#include <memory>
35
36namespace Opm
37{
38
39template <class Operator, class Comm, typename>
40struct StandardPreconditioners;
41
42template <typename Scalar>
43using TpsaSeqOperator = Dune::MatrixAdapter<Linear::TpsaMatrixView<Scalar>,
46
47#if HAVE_MPI
50 const Dune::OwnerOverlapCopyCommunication<int, int>&,
51 const Dune::OwnerOverlapCopyCommunication<int, int>&,
52 const Dune::OwnerOverlapCopyCommunication<int, int>&,
53 const Dune::OwnerOverlapCopyCommunication<int, int>&>;
54
55template <typename Scalar>
56using TpsaParOperator = Dune::OverlappingSchwarzOperator<Linear::TpsaMatrixView<Scalar>,
59 TpsaComm>;
60#endif
61
62namespace detail
63{
64
65 template <typename Scalar>
66 void
68 {
72 using P = PropertyTree;
73
74 F::addCreator("tpsa_block",
75 [](const O& op,
76 const P& prm,
77 const std::function<V()>&,
78 std::size_t) {
79 using PreCond = TpsaPreconditioner<Scalar,
83 return std::make_shared<PreCond>(op.getmat(), prm);
84 });
85 }
86
87#if HAVE_MPI
88 template <typename Scalar>
89 void
91 {
92 // An MPI build running on a single rank still instantiates the parallel
93 // operator, but with sequential information.
97 using P = PropertyTree;
98
99 F::addCreator("tpsa_block",
100 [](const O& op,
101 const P& prm,
102 const std::function<V()>&,
103 std::size_t) {
104 using PreCond = TpsaPreconditioner<Scalar,
108 return std::make_shared<PreCond>(op.getmat(), prm);
109 });
110 }
111
112 template <typename Scalar>
113 void
115 {
116 using O = TpsaParOperator<Scalar>;
119 using P = PropertyTree;
120
121 F::addCreator("tpsa_block",
122 [](const O& op,
123 const P& prm,
124 const std::function<V()>&,
125 std::size_t,
126 const TpsaComm& comm) {
127 // All five fields share one dof partition.
128 const auto& fieldComm = comm[Dune::Indices::_0];
129 using PreCond = TpsaPreconditioner<Scalar,
134 return std::make_shared<PreCond>(op.getmat(), prm, fieldComm);
135 });
136 }
137#endif
138
139} // namespace detail
140
141template <>
142struct StandardPreconditioners<TpsaSeqOperator<double>, Dune::Amg::SequentialInformation, void>
143{
144 static void add()
145 {
146 detail::addTpsaBlockSeq<double>();
147 }
148};
149
150template <>
151struct StandardPreconditioners<TpsaSeqOperator<float>, Dune::Amg::SequentialInformation, void>
152{
153 static void add()
154 {
155 detail::addTpsaBlockSeq<float>();
156 }
157};
158
159#if HAVE_MPI
160template <>
161struct StandardPreconditioners<TpsaParOperator<double>, Dune::Amg::SequentialInformation, void>
162{
163 static void add()
164 {
165 detail::addTpsaBlockParSeq<double>();
166 }
167};
168
169template <>
170struct StandardPreconditioners<TpsaParOperator<float>, Dune::Amg::SequentialInformation, void>
171{
172 static void add()
173 {
174 detail::addTpsaBlockParSeq<float>();
175 }
176};
177
178template <>
180{
181 static void add()
182 {
183 detail::addTpsaBlockPar<double>();
184 }
185};
186
187template <>
189{
190 static void add()
191 {
192 detail::addTpsaBlockPar<float>();
193 }
194};
195#endif
196
197} // namespace Opm
198
199#endif // OPM_TPSA_PRECONDITIONER_FACTORY_HPP
Definition: MultiComm.hpp:120
Definition: PreconditionerFactory.hpp:64
Hierarchical collection of key/value pairs.
Definition: PropertyTree.hpp:39
Block lower-triangular preconditioner for the field-split TPSA system.
Definition: TpsaPreconditioner.hpp:106
Definition: fvbaseprimaryvariables.hh:161
Dune::MultiTypeBlockVector< DispVector0T< Scalar >, DispVector1T< Scalar >, DispVector2T< Scalar >, RotVectorT< Scalar >, SPresVectorT< Scalar > > TpsaMultiVector
The vector the Krylov solver and the preconditioner operate on.
Definition: TpsaTypes.hpp:116
void addTpsaBlockPar()
Definition: TpsaPreconditionerFactory.hpp:114
void addTpsaBlockParSeq()
Definition: TpsaPreconditionerFactory.hpp:90
void addTpsaBlockSeq()
Definition: TpsaPreconditionerFactory.hpp:67
Definition: blackoilbioeffectsmodules.hh:45
Dune::OverlappingSchwarzOperator< Linear::SPresSPresMatrixT< Scalar >, Linear::SPresVectorT< Scalar >, Linear::SPresVectorT< Scalar >, TpsaParComm > ParSPresSPresOperatorT
Parallel operator for the solid pressure block.
Definition: TpsaPreconditioner.hpp:78
Dune::MatrixAdapter< Linear::RotRotMatrixT< Scalar >, Linear::RotVectorT< Scalar >, Linear::RotVectorT< Scalar > > SeqRotRotOperatorT
Sequential operator for the rotation block.
Definition: TpsaPreconditioner.hpp:50
Dune::MatrixAdapter< Linear::TpsaMatrixView< Scalar >, Linear::TpsaMultiVector< Scalar >, Linear::TpsaMultiVector< Scalar > > TpsaSeqOperator
Definition: TpsaPreconditionerFactory.hpp:45
Dune::MatrixAdapter< Linear::DispDispMatrix00T< Scalar >, Linear::DispVector0T< Scalar >, Linear::DispVector0T< Scalar > > SeqDispDispOperatorT
Sequential operator for one of the three scalar displacement blocks.
Definition: TpsaPreconditioner.hpp:45
Dune::OverlappingSchwarzOperator< Linear::DispDispMatrix00T< Scalar >, Linear::DispVector0T< Scalar >, Linear::DispVector0T< Scalar >, TpsaParComm > ParDispDispOperatorT
Parallel operator for one of the three scalar displacement blocks.
Definition: TpsaPreconditioner.hpp:66
Dune::OverlappingSchwarzOperator< Linear::RotRotMatrixT< Scalar >, Linear::RotVectorT< Scalar >, Linear::RotVectorT< Scalar >, TpsaParComm > ParRotRotOperatorT
Parallel operator for the rotation block.
Definition: TpsaPreconditioner.hpp:72
Dune::MatrixAdapter< Linear::SPresSPresMatrixT< Scalar >, Linear::SPresVectorT< Scalar >, Linear::SPresVectorT< Scalar > > SeqSPresSPresOperatorT
Sequential operator for the solid pressure block.
Definition: TpsaPreconditioner.hpp:55
Dune::OverlappingSchwarzOperator< Linear::TpsaMatrixView< Scalar >, Linear::TpsaMultiVector< Scalar >, Linear::TpsaMultiVector< Scalar >, TpsaComm > TpsaParOperator
Definition: TpsaPreconditionerFactory.hpp:59
Dune::OwnerOverlapCopyCommunication< int, int > TpsaParComm
Communication type of a single TPSA field.
Definition: TpsaPreconditioner.hpp:59
static void add()
Definition: TpsaPreconditionerFactory.hpp:181
static void add()
Definition: TpsaPreconditionerFactory.hpp:190
Definition: StandardPreconditioners_mpi.hpp:139