added: MultisegmentWellEquations::recoverSolutionWell()

this recovers the well solution from a solution vector.
use the new method in the well implementation.
This commit is contained in:
Arne Morten Kvarving 2022-11-11 21:41:24 +01:00
parent bc312d1117
commit d50aaf8ed4
5 changed files with 19 additions and 20 deletions

View File

@ -168,6 +168,17 @@ MultisegmentWellEquations<Scalar,numWellEq,numEq>::solve() const
return mswellhelpers::applyUMFPack(*duneDSolver_, resWell_);
}
template<class Scalar, int numWellEq, int numEq>
void MultisegmentWellEquations<Scalar,numWellEq,numEq>::
recoverSolutionWell(const BVector& x, BVectorWell& xw) const
{
BVectorWell resWell = resWell_;
// resWell = resWell - B * x
duneB_.mmv(x, resWell);
// xw = D^-1 * resWell
xw = mswellhelpers::applyUMFPack(*duneDSolver_, resWell);
}
#define INSTANCE(numWellEq, numEq) \
template class MultisegmentWellEquations<double,numWellEq,numEq>;

View File

@ -86,6 +86,10 @@ public:
//! \brief Apply inverted D matrix to residual and return result.
BVectorWell solve() const;
//! \brief Recover well solution.
//! \details xw = inv(D)*(rw - C*x)
void recoverSolutionWell(const BVector& x, BVectorWell& xw) const;
// two off-diagonal matrices
OffDiagMatWell duneB_;
OffDiagMatWell duneC_;

View File

@ -389,20 +389,6 @@ updatePrimaryVariables(const WellState& well_state) const
}
}
template<typename FluidSystem, typename Indices, typename Scalar>
void
MultisegmentWellEval<FluidSystem,Indices,Scalar>::
recoverSolutionWell(const BVector& x, BVectorWell& xw) const
{
if (!baseif_.isOperableAndSolvable() && !baseif_.wellIsStopped()) return;
BVectorWell resWell = linSys_.resWell_;
// resWell = resWell - B * x
linSys_.duneB_.mmv(x, resWell);
// xw = D^-1 * resWell
xw = mswellhelpers::applyUMFPack(*linSys_.duneDSolver_, resWell);
}
template<typename FluidSystem, typename Indices, typename Scalar>
typename MultisegmentWellEval<FluidSystem,Indices,Scalar>::EvalWell
MultisegmentWellEval<FluidSystem,Indices,Scalar>::

View File

@ -142,10 +142,6 @@ protected:
// handling the overshooting and undershooting of the fractions
void processFractions(const int seg) const;
// xw = inv(D)*(rw - C*x)
void recoverSolutionWell(const BVector& x,
BVectorWell& xw) const;
void updatePrimaryVariables(const WellState& well_state) const;
void updateUpwindingSegments();

View File

@ -233,10 +233,12 @@ namespace Opm
WellState& well_state,
DeferredLogger& deferred_logger)
{
if (!this->isOperableAndSolvable() && !this->wellIsStopped()) return;
if (!this->isOperableAndSolvable() && !this->wellIsStopped()) {
return;
}
BVectorWell xw(1);
this->recoverSolutionWell(x, xw);
this->linSys_.recoverSolutionWell(x, xw);
updateWellState(xw, well_state, deferred_logger);
}