added: StandardWellEquations::invert()

this inverts the D matrix.
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 033718f027
commit 83c41e3f9c
3 changed files with 23 additions and 8 deletions

View File

@ -22,6 +22,10 @@
#include <config.h>
#include <opm/simulators/wells/StandardWellEquations.hpp>
#include <opm/common/Exceptions.hpp>
#include <opm/simulators/linalg/matrixblock.hh>
namespace Opm
{
@ -141,6 +145,21 @@ void StandardWellEquations<Scalar,numEq>::apply(BVector& r) const
duneC_.mmtv(invDrw_, r);
}
template<class Scalar, int numEq>
void StandardWellEquations<Scalar,numEq>::invert()
{
try {
invDuneD_ = duneD_; // Not strictly need if not cpr with well contributions is used
detail::invertMatrix(invDuneD_[0][0]);
} catch (NumericalProblem&) {
// for singular matrices, use identity as the inverse
invDuneD_[0][0] = 0.0;
for (size_t i = 0; i < invDuneD_[0][0].rows(); ++i) {
invDuneD_[0][0][i][i] = 1.0;
}
}
}
#define INSTANCE(N) \
template class StandardWellEquations<double,N>;

View File

@ -79,6 +79,9 @@ public:
//! \brief Apply linear operator to vector.
void apply(BVector& r) const;
//! \brief Invert D matrix.
void invert();
// two off-diagonal matrices
OffDiagMatWell duneB_;
OffDiagMatWell duneC_;

View File

@ -551,14 +551,7 @@ namespace Opm
// do the local inversion of D.
try {
this->linSys_.invDuneD_ = this->linSys_.duneD_; // Not strictly need if not cpr with well contributions is used
detail::invertMatrix(this->linSys_.invDuneD_[0][0]);
} catch (NumericalProblem&) {
// for singular matrices, use identity as the inverse
this->linSys_.invDuneD_[0][0] = 0.0;
for (size_t i = 0; i < this->linSys_.invDuneD_[0][0].rows(); ++i) {
this->linSys_.invDuneD_[0][0][i][i] = 1.0;
}
this->linSys_.invert();
} catch( ... ) {
OPM_DEFLOG_THROW(NumericalIssue,"Error when inverting local well equations for well " + name(), deferred_logger);
}