23#include <opm/common/ErrorMacros.hpp>
24#include <opm/common/TimingMacros.hpp>
26#include <opm/simulators/linalg/PreconditionerFactory.hpp>
28#include <opm/simulators/linalg/DILU.hpp>
29#include <opm/simulators/linalg/ExtraSmoothers.hpp>
30#include <opm/simulators/linalg/FlexibleSolver.hpp>
31#include <opm/simulators/linalg/FlowLinearSolverParameters.hpp>
32#include <opm/simulators/linalg/OwningBlockPreconditioner.hpp>
33#include <opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp>
34#include <opm/simulators/linalg/ParallelOverlappingILU0.hpp>
35#include <opm/simulators/linalg/PressureBhpTransferPolicy.hpp>
36#include <opm/simulators/linalg/PressureTransferPolicy.hpp>
37#include <opm/simulators/linalg/PropertyTree.hpp>
38#include <opm/simulators/linalg/WellOperators.hpp>
40#include <opm/simulators/linalg/ilufirstelement.hh>
41#include <opm/simulators/linalg/matrixblock.hh>
43#include <dune/common/unused.hh>
44#include <dune/istl/owneroverlapcopy.hh>
45#include <dune/istl/paamg/amg.hh>
46#include <dune/istl/paamg/fastamg.hh>
47#include <dune/istl/paamg/kamg.hh>
48#include <dune/istl/preconditioners.hh>
51#include <opm/simulators/linalg/PreconditionerFactoryGPUIncludeWrapper.hpp>
54#include <opm/simulators/linalg/HyprePreconditioner.hpp>
58#include <opm/simulators/linalg/AmgxPreconditioner.hpp>
65template <
class Smoother>
70 using SmootherArgs =
typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
81template <
class M,
class V,
class C>
87 using SmootherArgs =
typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
92 const MILU_VARIANT milu = convertString2Milu(prm.
get<std::string>(
"milutype", std::string(
"ilu")));
109void setUseFixedOrder(C&, ...)
114template <
class Operator,
class Comm,
class Matrix,
class Vector>
115typename AMGHelper<Operator, Comm, Matrix, Vector>::Criterion
116AMGHelper<Operator, Comm, Matrix, Vector>::criterion(
const PropertyTree& prm)
118 Criterion criterion(15, prm.get<
int>(
"coarsenTarget", 1200));
119 criterion.setDefaultValuesIsotropic(2);
120 criterion.setAlpha(prm.get<
double>(
"alpha", 0.33));
121 criterion.setBeta(prm.get<
double>(
"beta", 1
e-5));
122 criterion.setMaxLevel(prm.get<
int>(
"maxlevel", 15));
123 criterion.setSkipIsolated(prm.get<
bool>(
"skip_isolated",
false));
124 criterion.setNoPreSmoothSteps(prm.get<
int>(
"pre_smooth", 1));
125 criterion.setNoPostSmoothSteps(prm.get<
int>(
"post_smooth", 1));
126 criterion.setDebugLevel(prm.get<
int>(
"verbosity", 0));
130 criterion.setAccumulate(
static_cast<Dune::Amg::AccumulationMode
>(prm.get<
int>(
"accumulate", 1)));
131 criterion.setProlongationDampingFactor(prm.get<
double>(
"prolongationdamping", 1.6));
132 criterion.setMaxDistance(prm.get<
int>(
"maxdistance", 2));
133 criterion.setMaxConnectivity(prm.get<
int>(
"maxconnectivity", 15));
134 criterion.setMaxAggregateSize(prm.get<
int>(
"maxaggsize", 6));
135 criterion.setMinAggregateSize(prm.get<
int>(
"minaggsize", 4));
136 setUseFixedOrder(criterion,
true);
140template <
class Operator,
class Comm,
class Matrix,
class Vector>
141template <
class Smoother>
142typename AMGHelper<Operator, Comm, Matrix, Vector>::PrecPtr
143AMGHelper<Operator, Comm, Matrix, Vector>::makeAmgPreconditioner(
const Operator&
op,
144 const PropertyTree& prm,
147 auto crit = criterion(prm);
148 auto sargs = AMGSmootherArgsHelper<Smoother>::args(prm);
151 return std::make_shared<Type>(
152 op,
crit,
sargs, prm.get<std::size_t>(
"max_krylov", 1), prm.get<
double>(
"min_reduction", 1
e-1));
159template <
class Operator,
class Comm>
163 using namespace Dune;
167 using M =
typename F::Matrix;
168 using V =
typename F::Vector;
170 F::addCreator(
"ILU0", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
171 return createParILU(
op, prm, comm, 0);
173 F::addCreator(
"ParOverILU0",
174 [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
175 return createParILU(
op, prm, comm, prm.get<
int>(
"ilulevel", 0));
177 F::addCreator(
"ILUn", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
178 return createParILU(
op, prm, comm, prm.get<
int>(
"ilulevel", 0));
180 F::addCreator(
"DuneILU", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
181 const int n = prm.get<
int>(
"ilulevel", 0);
182 const double w = prm.get<
double>(
"relaxation", 1.0);
183 const bool resort = prm.get<
bool>(
"resort",
false);
187 F::addCreator(
"DILU", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
191 F::addCreator(
"Jac", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
192 const int n = prm.get<
int>(
"repeats", 1);
193 const double w = prm.get<
double>(
"relaxation", 1.0);
196 F::addCreator(
"GS", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
197 const int n = prm.get<
int>(
"repeats", 1);
198 const double w = prm.get<
double>(
"relaxation", 1.0);
201 F::addCreator(
"SOR", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
202 const int n = prm.get<
int>(
"repeats", 1);
203 const double w = prm.get<
double>(
"relaxation", 1.0);
206 F::addCreator(
"SSOR", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
207 const int n = prm.get<
int>(
"repeats", 1);
208 const double w = prm.get<
double>(
"relaxation", 1.0);
216 if constexpr (std::is_same_v<O, Dune::OverlappingSchwarzOperator<M, V, V, C>> ||
217 std::is_same_v<O, Opm::GhostLastMatrixAdapter<M, V, V, C>>) {
218 F::addCreator(
"amg", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
219 using PrecPtr = std::shared_ptr<Dune::PreconditionerWithUpdate<V, V>>;
220 const std::string smoother = prm.get<std::string>(
"smoother",
"ParOverILU0");
222 if (smoother ==
"ILU0" || smoother ==
"ParOverILU0") {
226 PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(
op,
crit,
sargs, comm);
228 }
else if (smoother ==
"DILU") {
230 using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
231 using SmootherArgs =
typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
234 PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(
op,
crit,
sargs, comm);
236 }
else if (smoother ==
"Jac") {
238 using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
239 using SmootherArgs =
typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
242 PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(
op,
crit,
sargs, comm);
244 }
else if (smoother ==
"GS") {
246 using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
247 using SmootherArgs =
typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
250 PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(
op,
crit,
sargs, comm);
252 }
else if (smoother ==
"SOR") {
254 using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
255 using SmootherArgs =
typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
258 PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(
op,
crit,
sargs, comm);
260 }
else if (smoother ==
"SSOR") {
262 using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
263 using SmootherArgs =
typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
266 PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(
op,
crit,
sargs, comm);
268 }
else if (smoother ==
"ILUn") {
270 using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
271 using SmootherArgs =
typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
274 PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(
op,
crit,
sargs, comm);
277 OPM_THROW(std::invalid_argument,
"Properties: No smoother with name " + smoother +
".");
286 std::size_t pressureIndex,
289 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
291 "Pressure index out of bounds. It needs to specified for CPR");
293 using Scalar =
typename V::field_type;
295 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(
298 F::addCreator(
"cprt",
302 std::size_t pressureIndex,
305 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
307 "Pressure index out of bounds. It needs to specified for CPR");
309 using Scalar =
typename V::field_type;
311 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(
315 if constexpr (std::is_same_v<O, WellModelGhostLastMatrixAdapter<M, V, V, true>>) {
316 F::addCreator(
"cprw",
320 std::size_t pressureIndex,
323 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
325 "Pressure index out of bounds. It needs to specified for CPR");
327 using Scalar =
typename V::field_type;
329 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(
335 F::addCreator(
"GPUILU0", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
336 const double w = prm.get<
double>(
"relaxation", 1.0);
337 using field_type =
typename V::field_type;
338 using GpuILU0 =
typename gpuistl::
339 GpuSeqILU0<M, gpuistl::GpuVector<field_type>, gpuistl::GpuVector<field_type>>;
340 auto gpuILU0 = std::make_shared<GpuILU0>(
op.getmat(),
w);
342 auto adapted = std::make_shared<gpuistl::PreconditionerAdapter<V, V, GpuILU0>>(
gpuILU0);
343 auto wrapped = std::make_shared<gpuistl::GpuBlockPreconditioner<V, V, Comm>>(
adapted, comm);
347 F::addCreator(
"GPUJAC", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
348 const double w = prm.get<
double>(
"relaxation", 1.0);
349 using field_type =
typename V::field_type;
352 auto gpuJac = std::make_shared<GpuJac>(
op.getmat(),
w);
354 auto adapted = std::make_shared<gpuistl::PreconditionerAdapter<V, V, GpuJac>>(
gpuJac);
355 auto wrapped = std::make_shared<gpuistl::GpuBlockPreconditioner<V, V, Comm>>(
adapted, comm);
359 F::addCreator(
"GPUDILU", [](
const O&
op, [[
maybe_unused]]
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
360 const bool split_matrix = prm.get<
bool>(
"split_matrix",
true);
363 using field_type =
typename V::field_type;
367 auto adapted = std::make_shared<gpuistl::PreconditionerAdapter<V, V, GpuDILU>>(
gpuDILU);
368 auto wrapped = std::make_shared<gpuistl::GpuBlockPreconditioner<V, V, Comm>>(
adapted, comm);
372 F::addCreator(
"OPMGPUILU0", [](
const O&
op, [[
maybe_unused]]
const P& prm,
const std::function<
V()>&, std::size_t,
const C& comm) {
373 const bool split_matrix = prm.get<
bool>(
"split_matrix",
true);
376 using field_type =
typename V::field_type;
380 auto adapted = std::make_shared<gpuistl::PreconditionerAdapter<V, V, OpmGpuILU0>>(
gpuilu0);
381 auto wrapped = std::make_shared<gpuistl::GpuBlockPreconditioner<V, V, Comm>>(
adapted, comm);
392 using M =
typename F::Matrix;
393 using V =
typename F::Vector;
395 const double w = prm.
get<
double>(
"relaxation", 1.0);
396 const bool redblack = prm.
get<
bool>(
"redblack",
false);
402 return std::make_shared<ParallelOverlappingILU0<M, V, V, Comm>>(
405 return std::make_shared<ParallelOverlappingILU0<M, V, V, Comm>>(
418 const auto&
is = comm.indexSet();
419 for (
const auto&
ind :
is) {
420 if (Comm::OwnerSet::contains(
ind.local().attribute())) {
433template <
class Operator>
437 using namespace Dune;
439 using C = Dune::Amg::SequentialInformation;
441 using M =
typename F::Matrix;
442 using V =
typename F::Vector;
444 F::addCreator(
"ILU0", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
445 const double w = prm.get<
double>(
"relaxation", 1.0);
446 return std::make_shared<ParallelOverlappingILU0<M, V, V, C>>(
449 F::addCreator(
"DuneILU", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
450 const double w = prm.get<
double>(
"relaxation", 1.0);
451 const int n = prm.get<
int>(
"ilulevel", 0);
452 const bool resort = prm.get<
bool>(
"resort",
false);
455 F::addCreator(
"ParOverILU0", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
456 const double w = prm.get<
double>(
"relaxation", 1.0);
457 const int n = prm.get<
int>(
"ilulevel", 0);
458 return std::make_shared<ParallelOverlappingILU0<M, V, V, C>>(
461 F::addCreator(
"ILUn", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
462 const int n = prm.get<
int>(
"ilulevel", 0);
463 const double w = prm.get<
double>(
"relaxation", 1.0);
464 return std::make_shared<ParallelOverlappingILU0<M, V, V, C>>(
467 F::addCreator(
"DILU", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
469 return std::make_shared<MultithreadDILU<M, V, V>>(
op.getmat());
471 F::addCreator(
"Jac", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
472 const int n = prm.get<
int>(
"repeats", 1);
473 const double w = prm.get<
double>(
"relaxation", 1.0);
476 F::addCreator(
"GS", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
477 const int n = prm.get<
int>(
"repeats", 1);
478 const double w = prm.get<
double>(
"relaxation", 1.0);
481 F::addCreator(
"SOR", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
482 const int n = prm.get<
int>(
"repeats", 1);
483 const double w = prm.get<
double>(
"relaxation", 1.0);
486 F::addCreator(
"SSOR", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
487 const int n = prm.get<
int>(
"repeats", 1);
488 const double w = prm.get<
double>(
"relaxation", 1.0);
494 if constexpr (std::is_same_v<O, Dune::MatrixAdapter<M, V, V>>) {
495 F::addCreator(
"amg", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
496 const std::string smoother = prm.get<std::string>(
"smoother",
"ParOverILU0");
497 if (smoother ==
"ILU0" || smoother ==
"ParOverILU0") {
500 }
else if (smoother ==
"Jac") {
503 }
else if (smoother ==
"GS") {
506 }
else if (smoother ==
"DILU") {
509 }
else if (smoother ==
"SOR") {
512 }
else if (smoother ==
"SSOR") {
515 }
else if (smoother ==
"ILUn") {
519 OPM_THROW(std::invalid_argument,
"Properties: No smoother with name " + smoother +
".");
522 F::addCreator(
"kamg", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
523 const std::string smoother = prm.get<std::string>(
"smoother",
"ParOverILU0");
524 if (smoother ==
"ILU0" || smoother ==
"ParOverILU0") {
527 }
else if (smoother ==
"Jac") {
530 }
else if (smoother ==
"SOR") {
533 }
else if (smoother ==
"GS") {
536 }
else if (smoother ==
"SSOR") {
539 }
else if (smoother ==
"ILUn") {
543 OPM_THROW(std::invalid_argument,
"Properties: No smoother with name " + smoother +
".");
546 F::addCreator(
"famg", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
547 if constexpr (std::is_same_v<typename V::field_type, float>) {
548 OPM_THROW(std::logic_error,
"famg requires UMFPack which is not available for floats");
552 Dune::Amg::Parameters
parms;
553 parms.setNoPreSmoothSteps(1);
554 parms.setNoPostSmoothSteps(1);
561 if constexpr (M::block_type::rows == 1 && M::block_type::cols == 1) {
562 F::addCreator(
"amgx", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
564 prm_copy.put(
"setup_frequency", Opm::Parameters::Get<Opm::Parameters::CprReuseInterval>());
565 return std::make_shared<Amgx::AmgxPreconditioner<M, V, V>>(
op.getmat(),
prm_copy);
572 if constexpr (M::block_type::rows == 1 && M::block_type::cols == 1 &&
573 std::is_same_v<HYPRE_Real, typename V::field_type>) {
574 F::addCreator(
"hypre", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
575 return std::make_shared<Hypre::HyprePreconditioner<M, V, V>>(
op.getmat(), prm);
580 if constexpr (std::is_same_v<O, WellModelMatrixAdapter<M, V, V>>) {
584 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
585 OPM_THROW(std::logic_error,
"Pressure index out of bounds. It needs to specified for CPR");
587 using Scalar =
typename V::field_type;
590 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
598 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
599 OPM_THROW(std::logic_error,
"Pressure index out of bounds. It needs to specified for CPR");
601 using Scalar =
typename V::field_type;
603 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
609 if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
610 OPM_THROW(std::logic_error,
"Pressure index out of bounds. It needs to specified for CPR");
612 using Scalar =
typename V::field_type;
614 return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
619 F::addCreator(
"GPUILU0", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
620 const double w = prm.get<
double>(
"relaxation", 1.0);
621 using field_type =
typename V::field_type;
622 using GpuILU0 =
typename gpuistl::
623 GpuSeqILU0<M, gpuistl::GpuVector<field_type>, gpuistl::GpuVector<field_type>>;
624 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, GpuILU0>>(
625 std::make_shared<GpuILU0>(
op.getmat(),
w));
628 F::addCreator(
"GPUILU0Float", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
629 const double w = prm.get<
double>(
"relaxation", 1.0);
630 using block_type =
typename V::block_type;
631 using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
632 using matrix_type_to =
633 typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
634 using GpuILU0 =
typename gpuistl::
635 GpuSeqILU0<matrix_type_to, gpuistl::GpuVector<float>, gpuistl::GpuVector<float>>;
638 auto converted = std::make_shared<Converter>(
op.getmat());
639 auto adapted = std::make_shared<Adapter>(std::make_shared<GpuILU0>(
converted->getConvertedMatrix(),
w));
644 F::addCreator(
"GPUJAC", [](
const O&
op,
const P& prm,
const std::function<
V()>&, std::size_t) {
645 const double w = prm.get<
double>(
"relaxation", 1.0);
646 using field_type =
typename V::field_type;
649 return std::make_shared<gpuistl::PreconditionerAdapter<V, V, GPUJac>>(
650 std::make_shared<GPUJac>(
op.getmat(),
w));
653 F::addCreator(
"OPMGPUILU0", [](
const O&
op, [[
maybe_unused]]
const P& prm,
const std::function<
V()>&, std::size_t) {
654 const bool split_matrix = prm.get<
bool>(
"split_matrix",
true);
658 using field_type =
typename V::field_type;
664 F::addCreator(
"GPUDILU", [](
const O&
op, [[
maybe_unused]]
const P& prm,
const std::function<
V()>&, std::size_t) {
665 const bool split_matrix = prm.get<
bool>(
"split_matrix",
true);
668 using field_type =
typename V::field_type;
673 F::addCreator(
"GPUDILUFloat", [](
const O&
op, [[
maybe_unused]]
const P& prm,
const std::function<
V()>&, std::size_t) {
674 const bool split_matrix = prm.get<
bool>(
"split_matrix",
true);
678 using block_type =
typename V::block_type;
679 using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
680 using matrix_type_to =
typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
684 auto converted = std::make_shared<Converter>(
op.getmat());
693template <
class Operator,
class Comm>
699template <
class Operator,
class Comm>
701PreconditionerFactory<Operator, Comm>::instance()
707template <
class Operator,
class Comm>
709PreconditionerFactory<Operator, Comm>::doCreate(
const Operator&
op,
710 const PropertyTree& prm,
712 std::size_t pressureIndex)
715 StandardPreconditioners<Operator, Comm>::add();
718 const std::string& type = prm.get<std::string>(
"type",
"ParOverILU0");
719 auto it = creators_.find(type);
720 if (it == creators_.end()) {
721 std::ostringstream
msg;
722 msg <<
"Preconditioner type " << type <<
" is not registered in the factory. Available types are: ";
723 for (
const auto& prec : creators_) {
724 msg << prec.first <<
' ';
732template <
class Operator,
class Comm>
734PreconditionerFactory<Operator, Comm>::doCreate(
const Operator&
op,
735 const PropertyTree& prm,
737 std::size_t pressureIndex,
741 StandardPreconditioners<Operator, Comm>::add();
744 const std::string& type = prm.get<std::string>(
"type",
"ParOverILU0");
745 auto it = parallel_creators_.find(type);
746 if (it == parallel_creators_.end()) {
747 std::ostringstream
msg;
748 msg <<
"Parallel preconditioner type " << type <<
" is not registered in the factory. Available types are: ";
749 for (
const auto& prec : parallel_creators_) {
750 msg << prec.first <<
' ';
758template <
class Operator,
class Comm>
760PreconditionerFactory<Operator, Comm>::doAddCreator(
const std::string& type, Creator
c)
765template <
class Operator,
class Comm>
767PreconditionerFactory<Operator, Comm>::doAddCreator(
const std::string& type, ParCreator
c)
769 parallel_creators_[type] =
c;
772template <
class Operator,
class Comm>
777 std::size_t pressureIndex)
782template <
class Operator,
class Comm>
788 std::size_t pressureIndex)
794template <
class Operator,
class Comm>
799 std::size_t pressureIndex)
801 return instance().doCreate(
op, prm, std::function<Vector()>(), pressureIndex, comm);
804template <
class Operator,
class Comm>
808 instance().doAddCreator(type,
creator);
811template <
class Operator,
class Comm>
815 instance().doAddCreator(type,
creator);
818using CommSeq = Dune::Amg::SequentialInformation;
820template<
class Scalar,
int Dim>
821using OpFSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, Dim, Dim>>,
822 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
823 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>>;
824template<
class Scalar,
int Dim>
825using OpBSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<MatrixBlock<Scalar, Dim, Dim>>,
826 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
827 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>>;
829template<
class Scalar,
int Dim,
bool overlap>
831 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
832 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>>;
834template<
class Scalar,
int Dim,
bool overlap>
836 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
837 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
841using CommPar = Dune::OwnerOverlapCopyCommunication<int, int>;
843template<
class Scalar,
int Dim>
844using OpFPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<Dune::FieldMatrix<Scalar, Dim, Dim>>,
845 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
846 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
849template<
class Scalar,
int Dim>
850using OpBPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<MatrixBlock<Scalar, Dim, Dim>>,
851 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
852 Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
854template<
class Scalar,
int Dim>
856 Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>,
857 Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>,
860template<
class Scalar,
int Dim>
862 Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>,
863 Dune::BlockVector<Dune::FieldVector<Scalar,Dim>>,
866#define INSTANTIATE_PF_PAR(T,Dim) \
867 template class PreconditionerFactory<OpBSeq<T,Dim>, CommPar>; \
868 template class PreconditionerFactory<OpFPar<T,Dim>, CommPar>; \
869 template class PreconditionerFactory<OpBPar<T,Dim>, CommPar>; \
870 template class PreconditionerFactory<OpGLFPar<T,Dim>, CommPar>; \
871 template class PreconditionerFactory<OpGLBPar<T,Dim>, CommPar>; \
872 template class PreconditionerFactory<OpW<T,Dim, false>, CommPar>; \
873 template class PreconditionerFactory<OpWG<T,Dim, true>, CommPar>; \
874 template class PreconditionerFactory<OpBPar<T,Dim>, CommSeq>; \
875 template class PreconditionerFactory<OpGLBPar<T,Dim>, CommSeq>;
878#define INSTANTIATE_PF_SEQ(T,Dim) \
879 template class PreconditionerFactory<OpFSeq<T,Dim>, CommSeq>; \
880 template class PreconditionerFactory<OpBSeq<T,Dim>, CommSeq>; \
881 template class PreconditionerFactory<OpW<T,Dim, false>, CommSeq>; \
882 template class PreconditionerFactory<OpWG<T,Dim, true>, CommSeq>;
885#define INSTANTIATE_PF(T,Dim) \
886 INSTANTIATE_PF_PAR(T,Dim) \
887 INSTANTIATE_PF_SEQ(T,Dim)
889#define INSTANTIATE_PF(T,Dim) INSTANTIATE_PF_SEQ(T,Dim)
Parallel algebraic multigrid based on agglomeration.
Definition amgcpr.hh:88
Definition PreconditionerWithUpdate.hpp:43
The OpenMP thread parallelized DILU preconditioner.
Definition DILU.hpp:53
Dune linear operator that assumes ghost rows are ordered after interior rows.
Definition WellOperators.hpp:402
A two-step version of an overlapping Schwarz preconditioner using one step ILU0 as.
Definition ParallelOverlappingILU0.hpp:131
This is an object factory for creating preconditioners.
Definition PreconditionerFactory.hpp:64
static PrecPtr create(const Operator &op, const PropertyTree &prm, const std::function< Vector()> &weightsCalculator={}, std::size_t pressureIndex=std::numeric_limits< std::size_t >::max())
Create a new serial preconditioner and return a pointer to it.
Definition PreconditionerFactory_impl.hpp:774
std::function< PrecPtr(const Operator &, const PropertyTree &, const std::function< Vector()> &, std::size_t)> Creator
The type of creator functions passed to addCreator().
Definition PreconditionerFactory.hpp:75
static void addCreator(const std::string &type, Creator creator)
Add a creator for a serial preconditioner to the PreconditionerFactory.
Definition PreconditionerFactory_impl.hpp:806
std::shared_ptr< Dune::PreconditionerWithUpdate< Vector, Vector > > PrecPtr
The type of pointer returned by create().
Definition PreconditionerFactory.hpp:71
Definition PressureBhpTransferPolicy.hpp:99
Definition PressureTransferPolicy.hpp:55
Hierarchical collection of key/value pairs.
Definition PropertyTree.hpp:39
T get(const std::string &key) const
Retrieve property value given hierarchical property key.
Definition PropertyTree.cpp:59
Adapter to combine a matrix and another linear operator into a combined linear operator.
Definition WellOperators.hpp:299
Adapter to combine a matrix and another linear operator into a combined linear operator.
Definition WellOperators.hpp:225
DILU preconditioner on the GPU.
Definition GpuDILU.hpp:47
Jacobi preconditioner on the GPU.
Definition GpuJac.hpp:47
ILU0 preconditioner on the GPU.
Definition OpmGpuILU0.hpp:48
Makes a CUDA preconditioner available to a CPU simulator.
Definition PreconditionerAdapter.hpp:43
Converts the field type (eg.
Definition PreconditionerConvertFieldTypeAdapter.hpp:86
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
MILU_VARIANT
Definition MILU.hpp:34
@ ILU
Do not perform modified ILU.
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
Definition PreconditionerFactory.hpp:43
Definition PreconditionerFactory_impl.hpp:67
Definition PreconditionerFactory_impl.hpp:160
static std::size_t interiorIfGhostLast(const Comm &comm)
Helper method to determine if the local partitioning has the K interior cells from [0,...
Definition PreconditionerFactory_impl.hpp:414