mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
changed interface to only have minimal overhead using true impes.
It gives overhead in constructor when linear system is created. No overhead if reuse is used.
This commit 141903a26
cherry-picked, cleaned and made compilable with
recent changes
This commit is contained in:
parent
bfa859c099
commit
90b22d8713
@ -148,6 +148,9 @@ public:
|
||||
assert(recreate_solver == false);
|
||||
// Never recreate solver.
|
||||
}
|
||||
|
||||
VectorType weights;
|
||||
|
||||
if( prm_.get<std::string>("preconditioner.type") == "cpr" ||
|
||||
prm_.get<std::string>("preconditioner.type") == "cprt"
|
||||
)
|
||||
@ -157,17 +160,21 @@ public:
|
||||
transpose = true;
|
||||
}
|
||||
|
||||
|
||||
if(prm_.get<std::string>("preconditioner.weight_type") == "quasiimpes") {
|
||||
VectorType weights = Opm::Amg::getQuasiImpesWeights<MatrixType, VectorType>(
|
||||
mat.istlMatrix(),
|
||||
prm_.get<int>("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<MatrixType, VectorType>(
|
||||
mat.istlMatrix(),
|
||||
prm_.get<int>("preconditioner.pressure_var_index"), transpose);
|
||||
}
|
||||
|
||||
}else if(prm_.get<std::string>("preconditioner.weight_type") == "trueimpes" ){
|
||||
VectorType weights =
|
||||
weights =
|
||||
this->getTrueImpesWeights(b, prm_.get<int>("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;
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -88,7 +88,13 @@ public:
|
||||
: linear_operator_(linearoperator)
|
||||
, finesmoother_(PrecFactory::create(linearoperator, prm.get_child("finesmoother")))
|
||||
, comm_(nullptr)
|
||||
, weights_(prm.get<VectorType>("weights"))
|
||||
, weights_(
|
||||
(prm.get<std::string>("weight_type") != "quasiimpes") ?
|
||||
prm.get<VectorType>("weights") :
|
||||
Opm::Amg::getQuasiImpesWeights<MatrixType, VectorType>(linearoperator.getmat(),
|
||||
prm.get<int>("pressure_var_index"),
|
||||
transpose)
|
||||
)
|
||||
, levelTransferPolicy_(dummy_comm_, weights_, prm.get<int>("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<VectorType>("weights"))
|
||||
, weights_(
|
||||
(prm.get<std::string>("weight_type") != "quasiimpes") ?
|
||||
prm.get<VectorType>("weights") :
|
||||
Opm::Amg::getQuasiImpesWeights<MatrixType, VectorType>(linearoperator.getmat(),
|
||||
prm.get<int>("pressure_var_index"),
|
||||
transpose)
|
||||
)
|
||||
, levelTransferPolicy_(*comm_, weights_, prm.get<int>("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<MatrixType, VectorType>(
|
||||
// linear_operator_.getmat(), prm_.get<int>("pressure_var_index"), transpose, weights_);
|
||||
weights_ = prm.get<VectorType>("weights");
|
||||
// if(prm.get<std::string>("weight_type") == "quasiimpes"){
|
||||
// Opm::Amg::getQuasiImpesWeights<MatrixType, VectorType>(
|
||||
// linear_operator_.getmat(), prm_.get<int>("pressure_var_index"), transpose, weights_);
|
||||
// weights_ = prm.get<VectorType>("weights");
|
||||
// }else{
|
||||
weights_ = weights;
|
||||
//}
|
||||
updateImpl(comm_);
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -31,7 +31,7 @@ template <class X, class Y>
|
||||
class PreconditionerWithUpdate : public Preconditioner<X, Y>
|
||||
{
|
||||
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 <class OriginalPreconditioner>
|
||||
@ -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
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,8 @@ namespace Amg
|
||||
void updatePreconditioner()
|
||||
{
|
||||
pt::ptree prm;
|
||||
linsolver_->preconditioner().update(prm);
|
||||
X w;
|
||||
linsolver_->preconditioner().update(w, prm);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -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<class M, class X, class S, class PI, class A>
|
||||
void AMGCPR<M,X,S,PI,A>::update(const boost::property_tree::ptree& /* prm */)
|
||||
void AMGCPR<M,X,S,PI,A>::update(const X& /*w*/, const boost::property_tree::ptree& /*prm*/)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user