From 3ec01f7d7b207a5d330a11b03c9165df4c039e77 Mon Sep 17 00:00:00 2001 From: jakobtorben Date: Thu, 21 Nov 2024 13:18:35 +0100 Subject: [PATCH] Update second stage preconditioner for CPR instead of recreate --- opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp | 8 ++------ opm/simulators/linalg/twolevelmethodcpr.hh | 3 ++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp b/opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp index 79781964a..5f32cccc6 100644 --- a/opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp +++ b/opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp @@ -183,28 +183,24 @@ private: FlexibleSolver, LevelTransferPolicy>; using TwoLevelMethod - = Dune::Amg::TwoLevelMethodCpr>; + = Dune::Amg::TwoLevelMethodCpr>; // Handling parallel vs serial instantiation of preconditioner factory. template void updateImpl(const Comm*) { // Parallel case. - auto child = prm_.get_child_optional("finesmoother"); - finesmoother_ = PrecFactory::create(linear_operator_, child ? *child : Opm::PropertyTree(), *comm_); twolevel_method_.updatePreconditioner(finesmoother_, coarseSolverPolicy_); } void updateImpl(const Dune::Amg::SequentialInformation*) { // Serial case. - auto child = prm_.get_child_optional("finesmoother"); - finesmoother_ = PrecFactory::create(linear_operator_, child ? *child : Opm::PropertyTree()); twolevel_method_.updatePreconditioner(finesmoother_, coarseSolverPolicy_); } const OperatorType& linear_operator_; - std::shared_ptr> finesmoother_; + std::shared_ptr> finesmoother_; const Communication* comm_; std::function weightsCalculator_; VectorType weights_; diff --git a/opm/simulators/linalg/twolevelmethodcpr.hh b/opm/simulators/linalg/twolevelmethodcpr.hh index cb567e135..97435c82c 100644 --- a/opm/simulators/linalg/twolevelmethodcpr.hh +++ b/opm/simulators/linalg/twolevelmethodcpr.hh @@ -472,8 +472,9 @@ public: void updatePreconditioner(std::shared_ptr smoother, CoarseLevelSolverPolicy& coarsePolicy) { - //assume new matrix is not reallocated the new precondition should anyway be made smoother_ = smoother; + // We assume the matrix has the same sparsity structure and memory locations throughout, only the values are changed. + smoother_->update(); if (coarseSolver_) { policy_->calculateCoarseEntries(*operator_); coarsePolicy.setCoarseOperator(*policy_);