Propagate need for recreating solver properly for two level methods

This commit is contained in:
jakobtorben
2024-12-04 15:22:14 +01:00
parent 3b67d6dc54
commit e60aa7da13
4 changed files with 16 additions and 3 deletions

View File

@@ -192,8 +192,10 @@ public:
bool hasPerfectUpdate() const override bool hasPerfectUpdate() const override
{ {
// The Hypre preconditioner can depend on the values of the matrix, so it must be recreated // The Hypre preconditioner can depend on the values of the matrix so it does not have perfect update.
return false; // However, copying the matrix to Hypre requires to setup the solver again, so this is handled internally.
// So for ISTLSolver, we can return true.
return true;
} }
private: private:

View File

@@ -174,7 +174,7 @@ public:
} }
virtual bool hasPerfectUpdate() const override { virtual bool hasPerfectUpdate() const override {
return false; return twolevel_method_.hasPerfectUpdate();
} }
private: private:

View File

@@ -88,6 +88,11 @@ namespace Amg
return linsolver_->category(); return linsolver_->category();
} }
bool hasPerfectUpdate() const
{
return linsolver_->preconditioner().hasPerfectUpdate();
}
void apply(X& x, X& b, double reduction, Dune::InverseOperatorResult& res) override void apply(X& x, X& b, double reduction, Dune::InverseOperatorResult& res) override
{ {
linsolver_->apply(x, b, reduction, res); linsolver_->apply(x, b, reduction, res);

View File

@@ -495,6 +495,12 @@ public:
{ {
} }
bool hasPerfectUpdate() const
{
// The two-level method has perfect update if both the finesmoother and coarse solver do.
return smoother_->hasPerfectUpdate() && coarseSolver_->hasPerfectUpdate();
}
void apply(FineDomainType& v, const FineRangeType& d) void apply(FineDomainType& v, const FineRangeType& d)
{ {
FineDomainType u(v); FineDomainType u(v);