mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
clean up and fix multiprocess RebuildOnUpdate wrapper
This commit is contained in:
@@ -180,7 +180,7 @@ struct StandardPreconditioners
|
||||
const int n = prm.get<int>("ilulevel", 0);
|
||||
const double w = prm.get<double>("relaxation", 1.0);
|
||||
const bool resort = prm.get<bool>("resort", false);
|
||||
return wrapBlockPreconditioner<RebuildOnUpdatePreconditioner<Dune::SeqILU<M, V, V>, M>>(comm, op.getmat(), n, w, resort);
|
||||
return wrapBlockPreconditioner<RebuildOnUpdatePreconditioner<Dune::SeqILU<M, V, V>, const M*>>(comm, &op.getmat(), n, w, resort);
|
||||
});
|
||||
F::addCreator("DILU", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
|
||||
DUNE_UNUSED_PARAMETER(prm);
|
||||
|
||||
@@ -85,13 +85,13 @@ wrapPreconditioner(Args&&... args)
|
||||
return std::make_shared<DummyUpdatePreconditioner<OriginalPreconditioner>>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class OriginalPreconditioner, class Matrix>
|
||||
template <class OriginalPreconditioner, class MatrixPtr>
|
||||
class RebuildOnUpdatePreconditioner : public PreconditionerWithUpdate<typename OriginalPreconditioner::domain_type,
|
||||
typename OriginalPreconditioner::range_type>
|
||||
{
|
||||
public:
|
||||
RebuildOnUpdatePreconditioner(Matrix op_mat, const int n, const double w, const bool resort)
|
||||
: orig_precond_(std::make_unique<OriginalPreconditioner>(op_mat, n, w, resort)), op_mat_(op_mat), n_(n), w_(w), resort_(resort)
|
||||
RebuildOnUpdatePreconditioner(MatrixPtr mat_ptr, const int n, const double w, const bool resort)
|
||||
: orig_precond_(std::make_unique<OriginalPreconditioner>(*mat_ptr, n, w, resort)), mat_ptr_(mat_ptr), n_(n), w_(w), resort_(resort)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -118,19 +118,18 @@ public:
|
||||
return orig_precond_->category();
|
||||
}
|
||||
|
||||
// The update() function does nothing for a wrapped preconditioner.
|
||||
virtual void update() override
|
||||
// Rebuild the preconditioner on update
|
||||
void update() override
|
||||
{
|
||||
orig_precond_ = std::make_unique<OriginalPreconditioner>(op_mat_, n_, w_, resort_);
|
||||
orig_precond_ = std::make_unique<OriginalPreconditioner>(*mat_ptr_, n_, w_, resort_);
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<OriginalPreconditioner> orig_precond_;
|
||||
//TODO: replace excess copy of matrix with pointer
|
||||
Matrix op_mat_;
|
||||
int n_;
|
||||
double w_;
|
||||
bool resort_;
|
||||
const MatrixPtr mat_ptr_;
|
||||
const int n_;
|
||||
const double w_;
|
||||
const bool resort_;
|
||||
};
|
||||
|
||||
} // namespace Dune
|
||||
|
||||
Reference in New Issue
Block a user