mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #5758 from jakobtorben/remove_recreation_of_second_stage_preconditioner_for_cpr
Update second stage preconditioner for CPR instead of recreate
This commit is contained in:
@@ -183,28 +183,24 @@ private:
|
|||||||
FlexibleSolver<CoarseOperator>,
|
FlexibleSolver<CoarseOperator>,
|
||||||
LevelTransferPolicy>;
|
LevelTransferPolicy>;
|
||||||
using TwoLevelMethod
|
using TwoLevelMethod
|
||||||
= Dune::Amg::TwoLevelMethodCpr<OperatorType, CoarseSolverPolicy, Dune::Preconditioner<VectorType, VectorType>>;
|
= Dune::Amg::TwoLevelMethodCpr<OperatorType, CoarseSolverPolicy, Dune::PreconditionerWithUpdate<VectorType, VectorType>>;
|
||||||
|
|
||||||
// Handling parallel vs serial instantiation of preconditioner factory.
|
// Handling parallel vs serial instantiation of preconditioner factory.
|
||||||
template <class Comm>
|
template <class Comm>
|
||||||
void updateImpl(const Comm*)
|
void updateImpl(const Comm*)
|
||||||
{
|
{
|
||||||
// Parallel case.
|
// Parallel case.
|
||||||
auto child = prm_.get_child_optional("finesmoother");
|
|
||||||
finesmoother_ = PrecFactory::create(linear_operator_, child ? *child : Opm::PropertyTree(), *comm_);
|
|
||||||
twolevel_method_.updatePreconditioner(finesmoother_, coarseSolverPolicy_);
|
twolevel_method_.updatePreconditioner(finesmoother_, coarseSolverPolicy_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateImpl(const Dune::Amg::SequentialInformation*)
|
void updateImpl(const Dune::Amg::SequentialInformation*)
|
||||||
{
|
{
|
||||||
// Serial case.
|
// Serial case.
|
||||||
auto child = prm_.get_child_optional("finesmoother");
|
|
||||||
finesmoother_ = PrecFactory::create(linear_operator_, child ? *child : Opm::PropertyTree());
|
|
||||||
twolevel_method_.updatePreconditioner(finesmoother_, coarseSolverPolicy_);
|
twolevel_method_.updatePreconditioner(finesmoother_, coarseSolverPolicy_);
|
||||||
}
|
}
|
||||||
|
|
||||||
const OperatorType& linear_operator_;
|
const OperatorType& linear_operator_;
|
||||||
std::shared_ptr<Dune::Preconditioner<VectorType, VectorType>> finesmoother_;
|
std::shared_ptr<PreconditionerWithUpdate<VectorType, VectorType>> finesmoother_;
|
||||||
const Communication* comm_;
|
const Communication* comm_;
|
||||||
std::function<VectorType()> weightsCalculator_;
|
std::function<VectorType()> weightsCalculator_;
|
||||||
VectorType weights_;
|
VectorType weights_;
|
||||||
|
|||||||
@@ -472,8 +472,9 @@ public:
|
|||||||
void updatePreconditioner(std::shared_ptr<SmootherType> smoother,
|
void updatePreconditioner(std::shared_ptr<SmootherType> smoother,
|
||||||
CoarseLevelSolverPolicy& coarsePolicy)
|
CoarseLevelSolverPolicy& coarsePolicy)
|
||||||
{
|
{
|
||||||
//assume new matrix is not reallocated the new precondition should anyway be made
|
|
||||||
smoother_ = smoother;
|
smoother_ = smoother;
|
||||||
|
// We assume the matrix has the same sparsity structure and memory locations throughout, only the values are changed.
|
||||||
|
smoother_->update();
|
||||||
if (coarseSolver_) {
|
if (coarseSolver_) {
|
||||||
policy_->calculateCoarseEntries(*operator_);
|
policy_->calculateCoarseEntries(*operator_);
|
||||||
coarsePolicy.setCoarseOperator(*policy_);
|
coarsePolicy.setCoarseOperator(*policy_);
|
||||||
|
|||||||
Reference in New Issue
Block a user