mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-16 17:24:46 -06:00
Add method for defining if preconditioners should be recreated
This commit is contained in:
parent
ac1cbd8987
commit
5d54c50ba0
@ -162,6 +162,10 @@ public:
|
||||
return SolverCategory::sequential;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
//! \brief The matrix we operate on.
|
||||
const M& A_;
|
||||
|
@ -495,6 +495,13 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
if (!flexibleSolver_[activeSolverNum_].solver_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (flexibleSolver_[activeSolverNum_].pre_->hasPerfectUpdate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For AMG based preconditioners, the hierarchy depends on the matrix values
|
||||
// so it is recreated at certain intervals
|
||||
if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 0) {
|
||||
// Always recreate solver.
|
||||
return true;
|
||||
@ -509,7 +516,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
return this->iterations() > 10;
|
||||
}
|
||||
if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 3) {
|
||||
// Recreate solver if the last solve used more than 10 iterations.
|
||||
// Never recreate the solver
|
||||
return false;
|
||||
}
|
||||
if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 4) {
|
||||
@ -518,7 +525,6 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
const bool create = ((solveCount_ % step) == 0);
|
||||
return create;
|
||||
}
|
||||
|
||||
// If here, we have an invalid parameter.
|
||||
const bool on_io_rank = (simulator_.gridView().comm().rank() == 0);
|
||||
std::string msg = "Invalid value: " + std::to_string(this->parameters_[activeSolverNum_].cpr_reuse_setup_)
|
||||
@ -528,7 +534,6 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
}
|
||||
throw std::runtime_error(msg);
|
||||
|
||||
// Never reached.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,10 @@ public:
|
||||
orig_precond_.update();
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return orig_precond_.hasPerfectUpdate();
|
||||
}
|
||||
|
||||
private:
|
||||
OriginalPreconditioner orig_precond_;
|
||||
BlockPreconditioner<X, Y, Comm, OriginalPreconditioner> block_precond_;
|
||||
|
@ -173,6 +173,10 @@ public:
|
||||
return linear_operator_.category();
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
using CoarseOperator = typename LevelTransferPolicy::CoarseOperator;
|
||||
using CoarseSolverPolicy = Dune::Amg::PressureSolverPolicy<CoarseOperator,
|
||||
|
@ -144,6 +144,10 @@ public:
|
||||
using block_type = typename matrix_type::block_type;
|
||||
using size_type = typename matrix_type::size_type;
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
struct CRS
|
||||
{
|
||||
|
@ -32,6 +32,9 @@ class PreconditionerWithUpdate : public Preconditioner<X, Y>
|
||||
{
|
||||
public:
|
||||
virtual void update() = 0;
|
||||
|
||||
// Force derived classes to define if preconditioner has perfect update
|
||||
virtual bool hasPerfectUpdate() const = 0;
|
||||
};
|
||||
|
||||
template <class OriginalPreconditioner>
|
||||
@ -73,6 +76,10 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
OriginalPreconditioner orig_precond_;
|
||||
};
|
||||
@ -162,6 +169,10 @@ public:
|
||||
orig_precond_ = preconditioner_maker_->make();
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
using AbstractMakerType = GeneralPreconditionerMaker<OriginalPreconditioner>;
|
||||
using GenericPreconditioner = Preconditioner<typename OriginalPreconditioner::domain_type, typename OriginalPreconditioner::range_type>;
|
||||
|
@ -169,6 +169,10 @@ namespace Dune
|
||||
return category_;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** \copydoc Preconditioner::post */
|
||||
void post(Domain& x);
|
||||
|
||||
|
@ -113,6 +113,10 @@ public:
|
||||
return m_preconditioner;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//! \brief a sequential preconditioner
|
||||
|
@ -98,6 +98,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//! \brief Reference to the underlying matrix
|
||||
|
@ -93,6 +93,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//! \brief Reference to the underlying matrix
|
||||
|
@ -96,6 +96,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//! \brief Reference to the underlying matrix
|
||||
|
@ -99,6 +99,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//! \brief Reference to the underlying matrix
|
||||
|
@ -123,6 +123,10 @@ public:
|
||||
return m_underlyingPreconditioner;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return m_underlyingPreconditioner->hasPerfectUpdate();
|
||||
}
|
||||
|
||||
private:
|
||||
//! \brief the underlying preconditioner to use
|
||||
std::shared_ptr<CudaPreconditionerType> m_underlyingPreconditioner;
|
||||
|
@ -189,6 +189,10 @@ public:
|
||||
m_underlyingPreconditioner = conditioner;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return m_underlyingPreconditioner->hasPerfectUpdate();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void updateMatrix()
|
||||
|
@ -110,6 +110,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool hasPerfectUpdate() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
const SpMatrixFloat& m_matrix;
|
||||
|
Loading…
Reference in New Issue
Block a user