mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-26 15:40:09 -05:00
Merge pull request #6113 from jakobtorben/Make_WellModelMatrixAdapter_serial_only
Make wellModelMatrixAdapter serial only
This commit is contained in:
5 files changed
+11
-33
No files matched your search
@@ -277,7 +277,7 @@ using OBM = Dune::BCRSMatrix<Opm::MatrixBlock<Scalar, N, N>>;
|
||||
template<class Scalar, int N>
|
||||
using SeqOpM = Dune::MatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>>;
|
||||
template<class Scalar, int N>
|
||||
using SeqOpW = Opm::WellModelMatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>, false>;
|
||||
using SeqOpW = Opm::WellModelMatrixAdapter<OBM<Scalar,N>, BV<Scalar,N>, BV<Scalar,N>>;
|
||||
|
||||
#if HAVE_MPI
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ void FlexibleSolverInfo<Matrix,Vector,Comm>::create(const Matrix& matrix,
|
||||
this->op_ = std::move(sop);
|
||||
this->solver_ = std::move(sol);
|
||||
} else {
|
||||
using SeqOperatorType = WellModelMatrixAdapter<Matrix, Vector, Vector, false>;
|
||||
using SeqOperatorType = WellModelMatrixAdapter<Matrix, Vector, Vector>;
|
||||
auto sop = std::make_unique<SeqOperatorType>(matrix, *wellOperator_);
|
||||
using FlexibleSolverType = Dune::FlexibleSolver<SeqOperatorType>;
|
||||
auto sol = std::make_unique<FlexibleSolverType>(*sop, prm,
|
||||
|
||||
@@ -577,7 +577,7 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if constexpr (std::is_same_v<O, WellModelMatrixAdapter<M, V, V, false>>) {
|
||||
if constexpr (std::is_same_v<O, WellModelMatrixAdapter<M, V, V>>) {
|
||||
F::addCreator(
|
||||
"cprw",
|
||||
[](const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
|
||||
@@ -829,8 +829,7 @@ using OpBSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<MatrixBlock<Scalar, Dim, Dim
|
||||
template<class Scalar, int Dim, bool overlap>
|
||||
using OpW = WellModelMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<Scalar, Dim, Dim>>,
|
||||
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
|
||||
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>,
|
||||
overlap>;
|
||||
Dune::BlockVector<Dune::FieldVector<Scalar, Dim>>>;
|
||||
|
||||
template<class Scalar, int Dim, bool overlap>
|
||||
using OpWG = WellModelGhostLastMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<Scalar, Dim, Dim>>,
|
||||
|
||||
@@ -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<class M, class X, class Y, bool overlapping >
|
||||
template<class M, class X, class Y>
|
||||
class WellModelMatrixAdapter : public Dune::AssembledLinearOperator<M,X,Y>
|
||||
{
|
||||
public:
|
||||
@@ -230,23 +229,16 @@ public:
|
||||
using range_type = Y;
|
||||
using field_type = typename X::field_type;
|
||||
using PressureMatrix = Dune::BCRSMatrix<MatrixBlock<field_type, 1, 1>>;
|
||||
#if HAVE_MPI
|
||||
using communication_type = Dune::OwnerOverlapCopyCommunication<int,int>;
|
||||
#else
|
||||
using communication_type = Dune::Communication<int>;
|
||||
#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<X, Y>& wellOper,
|
||||
const std::shared_ptr<communication_type>& comm = {})
|
||||
: A_( A ), wellOper_( wellOper ), comm_(comm)
|
||||
const LinearOperatorExtra<X, Y>& 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<X, Y>& wellOper_;
|
||||
std::shared_ptr<communication_type> comm_;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
@@ -77,7 +77,7 @@ createSolverAdapterWithMatrix(const size_t N = 10)
|
||||
auto sp = std::make_shared<Dune::ScalarProduct<Vector>>();
|
||||
auto prm = Opm::PropertyTree();
|
||||
prm.put<double>("relaxation", 1.0);
|
||||
prm.put<std::string>("type", "CUILU0");
|
||||
prm.put<std::string>("type", "GPUILU0");
|
||||
auto prec = PrecondFactory::create(*op, prm);
|
||||
auto solverAdapter = std::make_shared<SolverAdapter>(*op, *sp, prec, 1.0, 10, 0, Dune::Amg::SequentialInformation());
|
||||
|
||||
|
||||
Reference in new issue
Block a user