Merge pull request #5758 from jakobtorben/remove_recreation_of_second_stage_preconditioner_for_cpr

Update second stage preconditioner for CPR instead of recreate
This commit is contained in:
Atgeirr Flø Rasmussen 2024-11-27 13:29:43 +01:00 committed by GitHub
commit b3b532e129
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 7 deletions

View File

@ -183,28 +183,24 @@ private:
FlexibleSolver<CoarseOperator>,
LevelTransferPolicy>;
using TwoLevelMethod
= Dune::Amg::TwoLevelMethodCpr<OperatorType, CoarseSolverPolicy, Dune::Preconditioner<VectorType, VectorType>>;
= Dune::Amg::TwoLevelMethodCpr<OperatorType, CoarseSolverPolicy, Dune::PreconditionerWithUpdate<VectorType, VectorType>>;
// Handling parallel vs serial instantiation of preconditioner factory.
template <class Comm>
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<Dune::Preconditioner<VectorType, VectorType>> finesmoother_;
std::shared_ptr<PreconditionerWithUpdate<VectorType, VectorType>> finesmoother_;
const Communication* comm_;
std::function<VectorType()> weightsCalculator_;
VectorType weights_;

View File

@ -472,8 +472,9 @@ public:
void updatePreconditioner(std::shared_ptr<SmootherType> 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_);