Merge pull request #1207 from GitPaean/improve_WellModelMatrixAdapter

making wellMod_ in WellModelMatrixAdapter is actually a well model
This commit is contained in:
Atgeirr Flø Rasmussen 2017-06-09 10:46:13 +02:00 committed by GitHub
commit 462d90aeb1
3 changed files with 12 additions and 25 deletions

View File

@ -100,7 +100,6 @@ namespace Opm {
/// upwind weighting of mobilities. /// upwind weighting of mobilities.
class BlackoilModelEbos class BlackoilModelEbos
{ {
typedef BlackoilModelEbos ThisType;
public: public:
// --------- Types and enums --------- // --------- Types and enums ---------
typedef BlackoilState ReservoirState; typedef BlackoilState ReservoirState;
@ -437,18 +436,6 @@ namespace Opm {
return istlSolver().iterations(); return istlSolver().iterations();
} }
template <class X, class Y>
void applyWellModelAdd(const X& x, Y& y )
{
wellModel().apply(x, y);
}
template <class X, class Y>
void applyWellModelScaleAdd(const Scalar alpha, const X& x, Y& y )
{
wellModel().applyScaleAdd(alpha, x, y);
}
/// Solve the Jacobian system Jx = r where J is the Jacobian and /// Solve the Jacobian system Jx = r where J is the Jacobian and
/// r is the residual. /// r is the residual.
void solveJacobianSystem(BVector& x, BVector& xw) const void solveJacobianSystem(BVector& x, BVector& xw) const
@ -462,15 +449,15 @@ namespace Opm {
// Solve system. // Solve system.
if( isParallel() ) if( isParallel() )
{ {
typedef WellModelMatrixAdapter< Mat, BVector, BVector, ThisType, true > Operator; typedef WellModelMatrixAdapter< Mat, BVector, BVector, StandardWellsDense<TypeTag>, true > Operator;
Operator opA(ebosJac, const_cast< ThisType& > (*this), istlSolver().parallelInformation() ); Operator opA(ebosJac, well_model_, istlSolver().parallelInformation() );
assert( opA.comm() ); assert( opA.comm() );
istlSolver().solve( opA, x, ebosResid, *(opA.comm()) ); istlSolver().solve( opA, x, ebosResid, *(opA.comm()) );
} }
else else
{ {
typedef WellModelMatrixAdapter< Mat, BVector, BVector, ThisType, false > Operator; typedef WellModelMatrixAdapter< Mat, BVector, BVector, StandardWellsDense<TypeTag>, false > Operator;
Operator opA(ebosJac, const_cast< ThisType& > (*this) ); Operator opA(ebosJac, well_model_);
istlSolver().solve( opA, x, ebosResid ); istlSolver().solve( opA, x, ebosResid );
} }
@ -516,7 +503,7 @@ namespace Opm {
}; };
//! constructor: just store a reference to a matrix //! constructor: just store a reference to a matrix
WellModelMatrixAdapter (const M& A, WellModel& wellMod, const boost::any& parallelInformation = boost::any() ) WellModelMatrixAdapter (const M& A, const WellModel& wellMod, const boost::any& parallelInformation = boost::any() )
: A_( A ), wellMod_( wellMod ), comm_() : A_( A ), wellMod_( wellMod ), comm_()
{ {
#if HAVE_MPI #if HAVE_MPI
@ -533,7 +520,7 @@ namespace Opm {
{ {
A_.mv( x, y ); A_.mv( x, y );
// add well model modification to y // add well model modification to y
wellMod_.applyWellModelAdd(x, y ); wellMod_.apply(x, y );
#if HAVE_MPI #if HAVE_MPI
if( comm_ ) if( comm_ )
@ -546,7 +533,7 @@ namespace Opm {
{ {
A_.usmv(alpha,x,y); A_.usmv(alpha,x,y);
// add scaled well model modification to y // add scaled well model modification to y
wellMod_.applyWellModelScaleAdd( alpha, x, y ); wellMod_.applyScaleAdd( alpha, x, y );
#if HAVE_MPI #if HAVE_MPI
if( comm_ ) if( comm_ )
@ -563,7 +550,7 @@ namespace Opm {
protected: protected:
const matrix_type& A_ ; const matrix_type& A_ ;
WellModel& wellMod_; const WellModel& wellMod_;
std::unique_ptr< communication_type > comm_; std::unique_ptr< communication_type > comm_;
}; };

View File

@ -160,10 +160,10 @@ enum WellVariablePositions {
void apply( BVector& r) const; void apply( BVector& r) const;
// subtract B*inv(D)*C * x from A*x // subtract B*inv(D)*C * x from A*x
void apply(const BVector& x, BVector& Ax); void apply(const BVector& x, BVector& Ax) const;
// apply well model with scaling of alpha // apply well model with scaling of alpha
void applyScaleAdd(const Scalar alpha, const BVector& x, BVector& Ax); void applyScaleAdd(const Scalar alpha, const BVector& x, BVector& Ax) const;
// xw = inv(D)*(rw - C*x) // xw = inv(D)*(rw - C*x)
void recoverVariable(const BVector& x, BVector& xw) const; void recoverVariable(const BVector& x, BVector& xw) const;

View File

@ -397,7 +397,7 @@ namespace Opm {
template<typename TypeTag> template<typename TypeTag>
void void
StandardWellsDense<TypeTag>:: StandardWellsDense<TypeTag>::
apply(const BVector& x, BVector& Ax) apply(const BVector& x, BVector& Ax) const
{ {
if ( ! localWellsActive() ) { if ( ! localWellsActive() ) {
return; return;
@ -420,7 +420,7 @@ namespace Opm {
template<typename TypeTag> template<typename TypeTag>
void void
StandardWellsDense<TypeTag>:: StandardWellsDense<TypeTag>::
applyScaleAdd(const Scalar alpha, const BVector& x, BVector& Ax) applyScaleAdd(const Scalar alpha, const BVector& x, BVector& Ax) const
{ {
if ( ! localWellsActive() ) { if ( ! localWellsActive() ) {
return; return;