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 const std::string smoother = prm.get<std::string>( "smoother", "ParOverILU0");
96 if (smoother == "ILU0" || smoother == "ParOverILU0") {
97 using Smoother = SeqILU<M, V, V>;
99 } else if (smoother == "Jac") {
100 using Smoother = SeqJac<M, V, V>;
102 } else if (smoother == "GS") {
103 using Smoother = SeqGS<M, V, V>;
105 } else if (smoother == "DILU") {
108 } else if (smoother == "SOR") {
109 using Smoother = SeqSOR<M, V, V>;
111 } else if (smoother == "SSOR") {
112 using Smoother = SeqSSOR<M, V, V>;
114 } else if (smoother == "ILUn") {
115 using Smoother = SeqILU<M, V, V>;
118 OPM_THROW(std::invalid_argument, "Properties: No smoother with name " + smoother + ".");
121 F::addCreator( "kamg", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
122 const std::string smoother = prm.get<std::string>( "smoother", "ParOverILU0");
123 if (smoother == "ILU0" || smoother == "ParOverILU0") {
124 using Smoother = SeqILU<M, V, V>;
126 } else if (smoother == "Jac") {
127 using Smoother = SeqJac<M, V, V>;
129 } else if (smoother == "SOR") {
130 using Smoother = SeqSOR<M, V, V>;
132 } else if (smoother == "GS") {
133 using Smoother = SeqGS<M, V, V>;
135 } else if (smoother == "SSOR") {
136 using Smoother = SeqSSOR<M, V, V>;
138 } else if (smoother == "ILUn") {
139 using Smoother = SeqILU<M, V, V>;
142 OPM_THROW(std::invalid_argument, "Properties: No smoother with name " + smoother + ".");
145 F::addCreator( "famg", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
146 if constexpr (std::is_same_v<typename V::field_type, float>) {
147 OPM_THROW(std::logic_error, "famg requires UMFPack which is not available for floats");
151 Dune::Amg::Parameters parms;
152 parms.setNoPreSmoothSteps(1);
153 parms.setNoPostSmoothSteps(1);
154 return getRebuildOnUpdateWrapper<Dune::Amg::FastAMG<O, V>>(op, crit, parms);
160 if constexpr (M::block_type::rows == 1 && M::block_type::cols == 1) {
161 F::addCreator( "amgx", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
163 prm_copy.put( "setup_frequency", Opm::Parameters::Get<Opm::Parameters::CprReuseInterval>());
164 return std::make_shared<Amgx::AmgxPreconditioner<M, V, V>>(op.getmat(), prm_copy);
171 if constexpr (M::block_type::rows == 1 && M::block_type::cols == 1 &&
172 std::is_same_v<HYPRE_Real, typename V::field_type>) {
173 F::addCreator( "hypre", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
174 return std::make_shared<Hypre::HyprePreconditioner<M, V, V>>(op.getmat(), prm);
184 if constexpr (std::is_same_v<O, WellModelMatrixAdapter<M, V, V>>) {
187 []( const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
188 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
189 OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
191 using Scalar = typename V::field_type;
192 using LevelTransferPolicy
194 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
195 op, prm, weightsCalculator, pressureIndex);
201 []( const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
202 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
203 OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
205 using Scalar = typename V::field_type;
207 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
208 op, prm, weightsCalculator, pressureIndex);
212 []( const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
213 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
214 OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
216 using Scalar = typename V::field_type;
218 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
219 op, prm, weightsCalculator, pressureIndex);
228 F::addCreator( "GPUILU0", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
229 const double w = prm.get< double>( "relaxation", 1.0);
230 using field_type = typename V::field_type;
231 using GpuILU0 = typename gpuistl::
232 GpuSeqILU0<M, gpuistl::GpuVector<field_type>, gpuistl::GpuVector<field_type>>;
233 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, GpuILU0>>(
234 std::make_shared<GpuILU0>(op.getmat(), w));
237 F::addCreator( "GPUILU0Float", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
238 const double w = prm.get< double>( "relaxation", 1.0);
239 using block_type = typename V::block_type;
240 using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
241 using matrix_type_to =
242 typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
243 using GpuILU0 = typename gpuistl::
244 GpuSeqILU0<matrix_type_to, gpuistl::GpuVector<float>, gpuistl::GpuVector<float>>;
247 auto converted = std::make_shared<Converter>(op.getmat());
248 auto adapted = std::make_shared<Adapter>(std::make_shared<GpuILU0>(converted->getConvertedMatrix(), w));
249 converted->setUnderlyingPreconditioner(adapted);
253 F::addCreator( "GPUJAC", []( const O& op, const P& prm, const std::function<V()>&, std::size_t) {
254 const double w = prm.get< double>( "relaxation", 1.0);
255 using field_type = typename V::field_type;
258 gpuistl::GpuVector<field_type>, gpuistl::GpuVector<field_type>>;
261 gpuistl::GpuVector<field_type>, GPUJac, M>;
262 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, MatrixOwner>>(
263 std::make_shared<MatrixOwner>(op.getmat(), w));
266 F::addCreator( "OPMGPUILU0", []( const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
267 const bool split_matrix = prm.get< bool>( "split_matrix", true);
268 const bool tune_gpu_kernels = prm.get< bool>( "tune_gpu_kernels", true);
269 const int mixed_precision_scheme = prm.get< int>( "mixed_precision_scheme", 0);
271 using field_type = typename V::field_type;
274 gpuistl::GpuVector<field_type>, GPUILU0, M>;
275 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, MatrixOwner>>(
278 std::make_shared<MatrixOwner>(op.getmat(), op.getmat(), split_matrix, tune_gpu_kernels, mixed_precision_scheme));
282 F::addCreator( "GPUDILU", []( const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
283 const bool split_matrix = prm.get< bool>( "split_matrix", true);
284 const bool tune_gpu_kernels = prm.get< bool>( "tune_gpu_kernels", true);
285 const int mixed_precision_scheme = prm.get< int>( "mixed_precision_scheme", 0);
286 using field_type = typename V::field_type;
289 gpuistl::GpuVector<field_type>, GPUDILU, M>;
290 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, MatrixOwner>>(
293 std::make_shared<MatrixOwner>(op.getmat(), op.getmat(), split_matrix, tune_gpu_kernels, mixed_precision_scheme));
296 F::addCreator( "GPUDILUFloat", []( const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
297 const bool split_matrix = prm.get< bool>( "split_matrix", true);
298 const bool tune_gpu_kernels = prm.get< bool>( "tune_gpu_kernels", true);
299 const int mixed_precision_scheme = prm.get< int>( "mixed_precision_scheme", 0);
301 using block_type = typename V::block_type;
302 using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
303 using matrix_type_to = typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
306 gpuistl::GpuVector<float>, GpuDILU, matrix_type_to>;
311 auto converted = std::make_shared<Converter>(op.getmat());
314 auto adapted = std::make_shared<Adapter>(std::make_shared<MatrixOwner>(
315 converted->getConvertedMatrix(), converted->getConvertedMatrix(),
316 split_matrix, tune_gpu_kernels, mixed_precision_scheme));
317 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:50
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
|