diff --git a/opm/simulators/linalg/ISTLSolverEbosFlexible.hpp b/opm/simulators/linalg/ISTLSolverEbosFlexible.hpp index 93b6abe40..58a76deb4 100644 --- a/opm/simulators/linalg/ISTLSolverEbosFlexible.hpp +++ b/opm/simulators/linalg/ISTLSolverEbosFlexible.hpp @@ -148,6 +148,9 @@ public: assert(recreate_solver == false); // Never recreate solver. } + + VectorType weights; + if( prm_.get("preconditioner.type") == "cpr" || prm_.get("preconditioner.type") == "cprt" ) @@ -157,17 +160,21 @@ public: transpose = true; } - if(prm_.get("preconditioner.weight_type") == "quasiimpes") { - VectorType weights = Opm::Amg::getQuasiImpesWeights( - mat.istlMatrix(), - prm_.get("preconditioner.pressure_var_index"), transpose); - prm_.put("preconditioner.weights",weights); + if( not( recreate_solver || !solver_) ){ + // weighs will be created as default in the solver + weights = Opm::Amg::getQuasiImpesWeights( + mat.istlMatrix(), + prm_.get("preconditioner.pressure_var_index"), transpose); + } }else if(prm_.get("preconditioner.weight_type") == "trueimpes" ){ - VectorType weights = + weights = this->getTrueImpesWeights(b, prm_.get("preconditioner.pressure_var_index")); - prm_.put("preconditioner.weights",weights); + if( recreate_solver || !solver_){ + // need weights for the constructor + prm_.put("preconditioner.weights",weights); + } }else{ throw std::runtime_error("no such weights implemented for cpr"); } @@ -183,7 +190,7 @@ public: } rhs_ = b; } else { - solver_->preconditioner().update(prm_); + solver_->preconditioner().update(weights, prm_.get_child("preconditioner")); rhs_ = b; } } diff --git a/opm/simulators/linalg/OwningBlockPreconditioner.hpp b/opm/simulators/linalg/OwningBlockPreconditioner.hpp index 5b5860478..23f3b9bf7 100644 --- a/opm/simulators/linalg/OwningBlockPreconditioner.hpp +++ b/opm/simulators/linalg/OwningBlockPreconditioner.hpp @@ -63,9 +63,9 @@ public: } // The update() function does nothing for a wrapped preconditioner. - virtual void update(const boost::property_tree::ptree& p) override + virtual void update(const X& w,const boost::property_tree::ptree& pt) override { - orig_precond_.update(p); + orig_precond_.update(w, pt); } private: diff --git a/opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp b/opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp index 08b54412f..91cb74498 100644 --- a/opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp +++ b/opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp @@ -88,7 +88,13 @@ public: : linear_operator_(linearoperator) , finesmoother_(PrecFactory::create(linearoperator, prm.get_child("finesmoother"))) , comm_(nullptr) - , weights_(prm.get("weights")) + , weights_( + (prm.get("weight_type") != "quasiimpes") ? + prm.get("weights") : + Opm::Amg::getQuasiImpesWeights(linearoperator.getmat(), + prm.get("pressure_var_index"), + transpose) + ) , levelTransferPolicy_(dummy_comm_, weights_, prm.get("pressure_var_index")) , coarseSolverPolicy_(prm.get_child("coarsesolver")) , twolevel_method_(linearoperator, @@ -112,7 +118,13 @@ public: : linear_operator_(linearoperator) , finesmoother_(PrecFactory::create(linearoperator, prm.get_child("finesmoother"), comm)) , comm_(&comm) - , weights_(prm.get("weights")) + , weights_( + (prm.get("weight_type") != "quasiimpes") ? + prm.get("weights") : + Opm::Amg::getQuasiImpesWeights(linearoperator.getmat(), + prm.get("pressure_var_index"), + transpose) + ) , levelTransferPolicy_(*comm_, weights_, prm.get("pressure_var_index")) , coarseSolverPolicy_(prm.get_child("coarsesolver")) , twolevel_method_(linearoperator, @@ -149,11 +161,15 @@ public: twolevel_method_.post(x); } - virtual void update(const boost::property_tree::ptree& prm) override + virtual void update(const VectorType& weights, const boost::property_tree::ptree& /*prm*/) override { - //Opm::Amg::getQuasiImpesWeights( - // linear_operator_.getmat(), prm_.get("pressure_var_index"), transpose, weights_); - weights_ = prm.get("weights"); + // if(prm.get("weight_type") == "quasiimpes"){ + // Opm::Amg::getQuasiImpesWeights( + // linear_operator_.getmat(), prm_.get("pressure_var_index"), transpose, weights_); + // weights_ = prm.get("weights"); + // }else{ + weights_ = weights; + //} updateImpl(comm_); } diff --git a/opm/simulators/linalg/ParallelOverlappingILU0.hpp b/opm/simulators/linalg/ParallelOverlappingILU0.hpp index 0f75f2b32..67e4feb0f 100644 --- a/opm/simulators/linalg/ParallelOverlappingILU0.hpp +++ b/opm/simulators/linalg/ParallelOverlappingILU0.hpp @@ -921,7 +921,7 @@ public: DUNE_UNUSED_PARAMETER(x); } - virtual void update(const boost::property_tree::ptree& = boost::property_tree::ptree()) override + virtual void update(const Range& = Range(), const boost::property_tree::ptree& = boost::property_tree::ptree()) override { // (For older DUNE versions the communicator might be // invalid if redistribution in AMG happened on the coarset level. diff --git a/opm/simulators/linalg/PreconditionerWithUpdate.hpp b/opm/simulators/linalg/PreconditionerWithUpdate.hpp index a0d0cede6..1bbf469b9 100644 --- a/opm/simulators/linalg/PreconditionerWithUpdate.hpp +++ b/opm/simulators/linalg/PreconditionerWithUpdate.hpp @@ -31,7 +31,7 @@ template class PreconditionerWithUpdate : public Preconditioner { public: - virtual void update(const boost::property_tree::ptree& pt) = 0; + virtual void update(const X& w, const boost::property_tree::ptree& pt) = 0; }; template @@ -69,7 +69,7 @@ public: } // The update() function does nothing for a wrapped preconditioner. - virtual void update(const boost::property_tree::ptree& /* pt */) override + virtual void update(const X& /*w*/, const boost::property_tree::ptree& /*pt*/) override { } diff --git a/opm/simulators/linalg/PressureSolverPolicy.hpp b/opm/simulators/linalg/PressureSolverPolicy.hpp index 21f4a2937..dab6ff669 100644 --- a/opm/simulators/linalg/PressureSolverPolicy.hpp +++ b/opm/simulators/linalg/PressureSolverPolicy.hpp @@ -85,7 +85,8 @@ namespace Amg void updatePreconditioner() { pt::ptree prm; - linsolver_->preconditioner().update(prm); + X w; + linsolver_->preconditioner().update(w, prm); } private: diff --git a/opm/simulators/linalg/amgcpr.hh b/opm/simulators/linalg/amgcpr.hh index 4176cdfd7..bd054fcec 100644 --- a/opm/simulators/linalg/amgcpr.hh +++ b/opm/simulators/linalg/amgcpr.hh @@ -239,7 +239,7 @@ namespace Dune /** * @brief Update the coarse solver and the hierarchies. */ - virtual void update(const boost::property_tree::ptree& prm); + virtual void update(const X& w, const boost::property_tree::ptree& prm); virtual void update(); /** @@ -470,7 +470,7 @@ namespace Dune } template - void AMGCPR::update(const boost::property_tree::ptree& /* prm */) + void AMGCPR::update(const X& /*w*/, const boost::property_tree::ptree& /*prm*/) { update(); }