Go to the documentation of this file.
21#ifndef OPM_STANDARDPRECONDITIONERS_SERIAL_HPP
22#define OPM_STANDARDPRECONDITIONERS_SERIAL_HPP
31template < class Operator>
38 using C = Dune::Amg::SequentialInformation;
40 using M = typename F::Matrix;
41 using V = typename F::Vector;
43 F::addCreator( "ilu0", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
44 const double w = prm.get< double>( "relaxation", 1.0);
45 return std::make_shared<ParallelOverlappingILU0<M, V, V, C>>(
48 F::addCreator( "duneilu", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
49 const double w = prm.get< double>( "relaxation", 1.0);
50 const int n = prm.get< int>( "ilulevel", 0);
51 const bool resort = prm.get< bool>( "resort", false);
52 return getRebuildOnUpdateWrapper<Dune::SeqILU<M, V, V>>(op.getmat(), n, w, resort);
54 F::addCreator( "paroverilu0", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
55 const double w = prm.get< double>( "relaxation", 1.0);
56 const int n = prm.get< int>( "ilulevel", 0);
57 return std::make_shared<ParallelOverlappingILU0<M, V, V, C>>(
60 F::addCreator( "ilun", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
61 const int n = prm.get< int>( "ilulevel", 0);
62 const double w = prm.get< double>( "relaxation", 1.0);
63 return std::make_shared<ParallelOverlappingILU0<M, V, V, C>>(
66 F::addCreator( "dilu", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
67 DUNE_UNUSED_PARAMETER(prm);
68 return std::make_shared<MultithreadDILU<M, V, V>>(op.getmat());
70 F::addCreator( "jac", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
71 const int n = prm.get< int>( "repeats", 1);
72 const double w = prm.get< double>( "relaxation", 1.0);
73 return getDummyUpdateWrapper<SeqJac<M, V, V>>(op.getmat(), n, w);
75 F::addCreator( "gs", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
76 const int n = prm.get< int>( "repeats", 1);
77 const double w = prm.get< double>( "relaxation", 1.0);
78 return getDummyUpdateWrapper<SeqGS<M, V, V>>(op.getmat(), n, w);
80 F::addCreator( "sor", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
81 const int n = prm.get< int>( "repeats", 1);
82 const double w = prm.get< double>( "relaxation", 1.0);
83 return getDummyUpdateWrapper<SeqSOR<M, V, V>>(op.getmat(), n, w);
85 F::addCreator( "ssor", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
86 const int n = prm.get< int>( "repeats", 1);
87 const double w = prm.get< double>( "relaxation", 1.0);
88 return getDummyUpdateWrapper<SeqSSOR<M, V, V>>(op.getmat(), n, w);
93 if constexpr (std::is_same_v<O, Dune::MatrixAdapter<M, V, V>>) {
94 F::addCreator( "amg", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
95 std::string smoother = prm.get<std::string>( "smoother", "paroverilu0");
97 std::transform(smoother.begin(), smoother.end(), smoother.begin(), ::tolower);
98 if (smoother == "ilu0" || smoother == "paroverilu0") {
99 using Smoother = SeqILU<M, V, V>;
101 } else if (smoother == "jac") {
102 using Smoother = SeqJac<M, V, V>;
104 } else if (smoother == "gs") {
105 using Smoother = SeqGS<M, V, V>;
107 } else if (smoother == "dilu") {
110 } else if (smoother == "sor") {
111 using Smoother = SeqSOR<M, V, V>;
113 } else if (smoother == "ssor") {
114 using Smoother = SeqSSOR<M, V, V>;
116 } else if (smoother == "ilun") {
117 using Smoother = SeqILU<M, V, V>;
120 OPM_THROW(std::invalid_argument, "Properties: No smoother with name " + smoother + ".");
123 F::addCreator( "kamg", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
124 std::string smoother = prm.get<std::string>( "smoother", "paroverilu0");
126 std::transform(smoother.begin(), smoother.end(), smoother.begin(), ::tolower);
127 if (smoother == "ilu0" || smoother == "paroverilu0") {
128 using Smoother = SeqILU<M, V, V>;
130 } else if (smoother == "jac") {
131 using Smoother = SeqJac<M, V, V>;
133 } else if (smoother == "sor") {
134 using Smoother = SeqSOR<M, V, V>;
136 } else if (smoother == "gs") {
137 using Smoother = SeqGS<M, V, V>;
139 } else if (smoother == "ssor") {
140 using Smoother = SeqSSOR<M, V, V>;
142 } else if (smoother == "ilun") {
143 using Smoother = SeqILU<M, V, V>;
146 OPM_THROW(std::invalid_argument, "Properties: No smoother with name " + smoother + ".");
149 F::addCreator( "famg", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
150 if constexpr (std::is_same_v<typename V::field_type, float>) {
151 OPM_THROW(std::logic_error, "famg requires UMFPack which is not available for floats");
155 Dune::Amg::Parameters parms;
156 parms.setNoPreSmoothSteps(1);
157 parms.setNoPostSmoothSteps(1);
158 return getRebuildOnUpdateWrapper<Dune::Amg::FastAMG<O, V>>(op, crit, parms);
164 if constexpr (M::block_type::rows == 1 && M::block_type::cols == 1) {
165 F::addCreator( "amgx", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
167 prm_copy.put( "setup_frequency", Opm::Parameters::Get<Opm::Parameters::CprReuseInterval>());
168 return std::make_shared<Amgx::AmgxPreconditioner<M, V, V>>(op.getmat(), prm_copy);
175 if constexpr (M::block_type::rows == 1 && M::block_type::cols == 1 &&
176 std::is_same_v<HYPRE_Real, typename V::field_type>) {
177 F::addCreator( "hypre", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
178 return std::make_shared<Hypre::HyprePreconditioner<M, V, V, Dune::Amg::SequentialInformation>>(op.getmat(), prm, Dune::Amg::SequentialInformation());
188 if constexpr (std::is_same_v<O, WellModelMatrixAdapter<M, V, V>>) {
191 []( const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
192 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
193 OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
195 using Scalar = typename V::field_type;
196 using LevelTransferPolicy
198 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
199 op, prm, weightsCalculator, pressureIndex);
205 []( const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
206 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
207 OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
209 using Scalar = typename V::field_type;
211 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
212 op, prm, weightsCalculator, pressureIndex);
216 []( const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
217 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
218 OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
220 using Scalar = typename V::field_type;
222 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
223 op, prm, weightsCalculator, pressureIndex);
232 F::addCreator( "gpuilu0", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
233 const double w = prm.get< double>( "relaxation", 1.0);
234 using field_type = typename V::field_type;
235 using GpuILU0 = typename gpuistl::
237 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, GpuILU0>>(
238 std::make_shared<GpuILU0>(op.getmat(), w));
241 F::addCreator( "gpuilu0float", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
242 const double w = prm.get< double>( "relaxation", 1.0);
243 using block_type = typename V::block_type;
244 using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
245 using matrix_type_to =
246 typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
247 using GpuILU0 = typename gpuistl::
251 auto converted = std::make_shared<Converter>(op.getmat());
252 auto adapted = std::make_shared<Adapter>(std::make_shared<GpuILU0>(converted->getConvertedMatrix(), w));
253 converted->setUnderlyingPreconditioner(adapted);
257 F::addCreator( "gpujac", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
258 const double w = prm.get< double>( "relaxation", 1.0);
259 using field_type = typename V::field_type;
266 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, MatrixOwner>>(
267 std::make_shared<MatrixOwner>(op.getmat(), w));
270 F::addCreator( "opmgpuilu0", []( const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
271 const bool split_matrix = prm.get< bool>( "split_matrix", true);
272 const bool tune_gpu_kernels = prm.get< bool>( "tune_gpu_kernels", true);
273 const int mixed_precision_scheme = prm.get< int>( "mixed_precision_scheme", 0);
275 using field_type = typename V::field_type;
279 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, MatrixOwner>>(
282 std::make_shared<MatrixOwner>(op.getmat(), op.getmat(), split_matrix, tune_gpu_kernels, mixed_precision_scheme));
286 F::addCreator( "gpudilu", []( const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
287 const bool split_matrix = prm.get< bool>( "split_matrix", true);
288 const bool tune_gpu_kernels = prm.get< bool>( "tune_gpu_kernels", true);
289 const int mixed_precision_scheme = prm.get< int>( "mixed_precision_scheme", 0);
290 const bool reorder = prm.get< bool>( "reorder", true);
291 using field_type = typename V::field_type;
295 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, MatrixOwner>>(
298 std::make_shared<MatrixOwner>(op.getmat(), op.getmat(), split_matrix, tune_gpu_kernels, mixed_precision_scheme, reorder));
301 F::addCreator( "gpudilufloat", []( const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
302 const bool split_matrix = prm.get< bool>( "split_matrix", true);
303 const bool tune_gpu_kernels = prm.get< bool>( "tune_gpu_kernels", true);
304 const int mixed_precision_scheme = prm.get< int>( "mixed_precision_scheme", 0);
305 const bool reorder = prm.get< bool>( "reorder", true);
307 using block_type = typename V::block_type;
308 using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
309 using matrix_type_to = typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
317 auto converted = std::make_shared<Converter>(op.getmat());
320 auto adapted = std::make_shared<Adapter>(std::make_shared<MatrixOwner>(
321 converted->getConvertedMatrix(), converted->getConvertedMatrix(),
322 split_matrix, tune_gpu_kernels, mixed_precision_scheme, reorder));
323 converted->setUnderlyingPreconditioner(adapted);
The OpenMP thread parallelized DILU preconditioner. Definition: DILU.hpp:53
Definition: PreconditionerFactory.hpp:64
Definition: PressureBhpTransferPolicy.hpp:99
Definition: PressureTransferPolicy.hpp:55
Hierarchical collection of key/value pairs. Definition: PropertyTree.hpp:39
DILU preconditioner on the GPU. Definition: GpuDILU.hpp:53
Jacobi preconditioner on the GPU. Definition: GpuJac.hpp:47
ILU0 preconditioner on the GPU. Definition: OpmGpuILU0.hpp:51
Makes a CUDA preconditioner available to a CPU simulator. Definition: PreconditionerAdapter.hpp:43
Convert a CPU matrix to a GPU matrix and use a CUDA preconditioner on the GPU. Definition: PreconditionerCPUMatrixToGPUMatrix.hpp:42
Converts the field type (eg. double to float) to benchmark single precision preconditioners. Definition: PreconditionerConvertFieldTypeAdapter.hpp:86
Definition: fvbaseprimaryvariables.hh:141
Definition: blackoilboundaryratevector.hh:39
@ ILU Do not perform modified ILU.
Definition: PreconditionerFactory.hpp:43
static Criterion criterion(const PropertyTree &prm) Definition: StandardPreconditioners_mpi.hpp:83
Definition: StandardPreconditioners_mpi.hpp:128
|