From e71d1abad60d9cad73c21c5a18d779160a8c2a18 Mon Sep 17 00:00:00 2001 From: jakobtorben Date: Thu, 27 Mar 2025 12:38:59 +0100 Subject: [PATCH] Make WellModelMatrixAdapter serial only --- opm/simulators/linalg/FlexibleSolver_impl.hpp | 2 +- opm/simulators/linalg/ISTLSolver.cpp | 2 +- .../linalg/PreconditionerFactory_impl.hpp | 5 ++- opm/simulators/linalg/WellOperators.hpp | 33 ++++--------------- 4 files changed, 10 insertions(+), 32 deletions(-) diff --git a/opm/simulators/linalg/FlexibleSolver_impl.hpp b/opm/simulators/linalg/FlexibleSolver_impl.hpp index b04e65ea18..49a6c664e7 100644 --- a/opm/simulators/linalg/FlexibleSolver_impl.hpp +++ b/opm/simulators/linalg/FlexibleSolver_impl.hpp @@ -277,7 +277,7 @@ using OBM = Dune::BCRSMatrix>; template using SeqOpM = Dune::MatrixAdapter, BV, BV>; template -using SeqOpW = Opm::WellModelMatrixAdapter, BV, BV, false>; +using SeqOpW = Opm::WellModelMatrixAdapter, BV, BV>; #if HAVE_MPI diff --git a/opm/simulators/linalg/ISTLSolver.cpp b/opm/simulators/linalg/ISTLSolver.cpp index e5fa905010..705cc08eb9 100644 --- a/opm/simulators/linalg/ISTLSolver.cpp +++ b/opm/simulators/linalg/ISTLSolver.cpp @@ -145,7 +145,7 @@ void FlexibleSolverInfo::create(const Matrix& matrix, this->op_ = std::move(sop); this->solver_ = std::move(sol); } else { - using SeqOperatorType = WellModelMatrixAdapter; + using SeqOperatorType = WellModelMatrixAdapter; auto sop = std::make_unique(matrix, *wellOperator_); using FlexibleSolverType = Dune::FlexibleSolver; auto sol = std::make_unique(*sop, prm, diff --git a/opm/simulators/linalg/PreconditionerFactory_impl.hpp b/opm/simulators/linalg/PreconditionerFactory_impl.hpp index 44287b6eb9..80fabb5d5b 100644 --- a/opm/simulators/linalg/PreconditionerFactory_impl.hpp +++ b/opm/simulators/linalg/PreconditionerFactory_impl.hpp @@ -577,7 +577,7 @@ struct StandardPreconditioners { } #endif } - if constexpr (std::is_same_v>) { + if constexpr (std::is_same_v>) { F::addCreator( "cprw", [](const O& op, const P& prm, const std::function& weightsCalculator, std::size_t pressureIndex) { @@ -829,8 +829,7 @@ using OpBSeq = Dune::MatrixAdapter using OpW = WellModelMatrixAdapter>, Dune::BlockVector>, - Dune::BlockVector>, - overlap>; + Dune::BlockVector>>; template using OpWG = WellModelGhostLastMatrixAdapter>, diff --git a/opm/simulators/linalg/WellOperators.hpp b/opm/simulators/linalg/WellOperators.hpp index d7a9deac9e..49d0e03905 100644 --- a/opm/simulators/linalg/WellOperators.hpp +++ b/opm/simulators/linalg/WellOperators.hpp @@ -217,11 +217,10 @@ private: Adapts a matrix A plus another linear operator W (typically from wells) to the assembled linear operator interface by returning S from getmat() and making apply() and applyscaleadd() apply both A - and W to the input vector. In addition this is a parallel-aware - adapter, that does not require the W operator to be parallel, but - makes it into one by making the proper projections. + and W to the input vector. The adapter is for serial use only as the + current parallel version in use is WellModelGhostLastMatrixAdapter. */ -template +template class WellModelMatrixAdapter : public Dune::AssembledLinearOperator { public: @@ -230,23 +229,16 @@ public: using range_type = Y; using field_type = typename X::field_type; using PressureMatrix = Dune::BCRSMatrix>; -#if HAVE_MPI - using communication_type = Dune::OwnerOverlapCopyCommunication; -#else - using communication_type = Dune::Communication; -#endif Dune::SolverCategory::Category category() const override { - return overlapping ? - Dune::SolverCategory::overlapping : Dune::SolverCategory::sequential; + return Dune::SolverCategory::sequential; } //! constructor: just store a reference to a matrix WellModelMatrixAdapter (const M& A, - const LinearOperatorExtra& wellOper, - const std::shared_ptr& comm = {}) - : A_( A ), wellOper_( wellOper ), comm_(comm) + const LinearOperatorExtra& wellOper) + : A_( A ), wellOper_( wellOper ) {} void apply( const X& x, Y& y ) const override @@ -256,12 +248,6 @@ public: // add well model modification to y wellOper_.apply(x, y); - - #if HAVE_MPI - if (comm_) { - comm_->project(y); - } - #endif } // y += \alpha * A * x @@ -272,12 +258,6 @@ public: // add scaled well model modification to y wellOper_.applyscaleadd(alpha, x, y); - - #if HAVE_MPI - if (comm_) { - comm_->project( y ); - } - #endif } const matrix_type& getmat() const override { return A_; } @@ -304,7 +284,6 @@ public: protected: const matrix_type& A_ ; const LinearOperatorExtra& wellOper_; - std::shared_ptr comm_; }; /*!