mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-09-05 04:40:19 -05: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 is contained in:
@@ -142,30 +142,32 @@ public:
|
|||||||
assert(recreate_solver == false);
|
assert(recreate_solver == false);
|
||||||
// Never recreate solver.
|
// Never recreate solver.
|
||||||
}
|
}
|
||||||
|
VectorType weights;
|
||||||
if( prm_.get<std::string>("preconditioner.type") == "cpr" ||
|
if( prm_.get<std::string>("preconditioner.type") == "cpr" ||
|
||||||
prm_.get<std::string>("preconditioner.type") == "cprt"
|
prm_.get<std::string>("preconditioner.type") == "cprt"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
bool transpose = false;
|
bool transpose = false;
|
||||||
if(prm_.get<std::string>("preconditioner.type") == "cprt"){
|
if(prm_.get<std::string>("preconditioner.type") == "cprt"){
|
||||||
transpose = true;
|
transpose = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(prm_.get<std::string>("preconditioner.weight_type") == "quasiimpes") {
|
if(prm_.get<std::string>("preconditioner.weight_type") == "quasiimpes") {
|
||||||
VectorType weights = Opm::Amg::getQuasiImpesWeights<MatrixType, VectorType>(
|
if( not( recreate_solver || !solver_) ){
|
||||||
mat.istlMatrix(),
|
// weighs will be created as default in the solver
|
||||||
prm_.get<int>("preconditioner.pressure_var_index"), transpose);
|
weights = Opm::Amg::getQuasiImpesWeights<MatrixType, VectorType>(
|
||||||
prm_.put("preconditioner.weights",weights);
|
mat.istlMatrix(),
|
||||||
|
prm_.get<int>("preconditioner.pressure_var_index"), transpose);
|
||||||
|
}
|
||||||
}else if(prm_.get<std::string>("preconditioner.weight_type") == "trueimpes" ){
|
}else if(prm_.get<std::string>("preconditioner.weight_type") == "trueimpes" ){
|
||||||
VectorType weights =
|
weights =
|
||||||
this->getTrueImpesWeights(b, prm_.get<int>("preconditioner.pressure_var_index"));
|
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{
|
}else{
|
||||||
throw std::runtime_error("no such weights implemented for cpr");
|
throw std::runtime_error("no such weights implemented for cpr");
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -181,7 +183,7 @@ public:
|
|||||||
}
|
}
|
||||||
rhs_ = b;
|
rhs_ = b;
|
||||||
} else {
|
} else {
|
||||||
solver_->preconditioner().update(prm_.get_child("preconditioner"));
|
solver_->preconditioner().update(weights, prm_.get_child("preconditioner"));
|
||||||
rhs_ = b;
|
rhs_ = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The update() function does nothing for a wrapped preconditioner.
|
// 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
|
||||||
{
|
{
|
||||||
orig_precond_.update(pt);
|
orig_precond_.update(w, pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -84,7 +84,13 @@ public:
|
|||||||
: linear_operator_(linearoperator)
|
: linear_operator_(linearoperator)
|
||||||
, finesmoother_(PrecFactory::create(linearoperator, prm.get_child("finesmoother")))
|
, finesmoother_(PrecFactory::create(linearoperator, prm.get_child("finesmoother")))
|
||||||
, comm_(nullptr)
|
, 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"))
|
, levelTransferPolicy_(dummy_comm_, weights_, prm.get<int>("pressure_var_index"))
|
||||||
, coarseSolverPolicy_(prm.get_child("coarsesolver"))
|
, coarseSolverPolicy_(prm.get_child("coarsesolver"))
|
||||||
, twolevel_method_(linearoperator,
|
, twolevel_method_(linearoperator,
|
||||||
@@ -108,7 +114,13 @@ public:
|
|||||||
: linear_operator_(linearoperator)
|
: linear_operator_(linearoperator)
|
||||||
, finesmoother_(PrecFactory::create(linearoperator, prm.get_child("finesmoother"), comm))
|
, finesmoother_(PrecFactory::create(linearoperator, prm.get_child("finesmoother"), comm))
|
||||||
, comm_(&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"))
|
, levelTransferPolicy_(*comm_, weights_, prm.get<int>("pressure_var_index"))
|
||||||
, coarseSolverPolicy_(prm.get_child("coarsesolver"))
|
, coarseSolverPolicy_(prm.get_child("coarsesolver"))
|
||||||
, twolevel_method_(linearoperator,
|
, twolevel_method_(linearoperator,
|
||||||
@@ -145,11 +157,16 @@ public:
|
|||||||
twolevel_method_.post(x);
|
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_);
|
// if(prm.get<std::string>("weight_type") == "quasiimpes"){
|
||||||
weights_ = prm.get<VectorType>("weights");
|
// 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_);
|
updateImpl(comm_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ template <class X, class Y>
|
|||||||
class PreconditionerWithUpdate : public Preconditioner<X, Y>
|
class PreconditionerWithUpdate : public Preconditioner<X, Y>
|
||||||
{
|
{
|
||||||
public:
|
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>
|
template <class OriginalPreconditioner>
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The update() function does nothing for a wrapped preconditioner.
|
// 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()
|
void updatePreconditioner()
|
||||||
{
|
{
|
||||||
pt::ptree prm;
|
pt::ptree prm;
|
||||||
linsolver_->preconditioner().update(prm);
|
X w;
|
||||||
|
linsolver_->preconditioner().update(w, prm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ namespace Dune
|
|||||||
/**
|
/**
|
||||||
* @brief Update the coarse solver and the hierarchies.
|
* @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();
|
virtual void update();
|
||||||
/**
|
/**
|
||||||
@@ -540,7 +540,7 @@ namespace Dune
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class M, class X, class S, class PI, class A>
|
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();
|
update();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user