mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
WellConvergence: template Scalar type
This commit is contained in:
parent
96c4a2f510
commit
720e177aaa
@ -30,18 +30,18 @@
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
namespace Opm {
|
||||
|
||||
void WellConvergence::
|
||||
checkConvergenceControlEq(const WellState<double>& well_state,
|
||||
template<class Scalar>
|
||||
void WellConvergence<Scalar>::
|
||||
checkConvergenceControlEq(const WellState<Scalar>& well_state,
|
||||
const Tolerances& tolerances,
|
||||
const double well_control_residual,
|
||||
const Scalar well_control_residual,
|
||||
const bool well_is_stopped,
|
||||
ConvergenceReport& report,
|
||||
DeferredLogger& deferred_logger) const
|
||||
{
|
||||
double control_tolerance = 0.;
|
||||
Scalar control_tolerance = 0.;
|
||||
using CR = ConvergenceReport;
|
||||
CR::WellFailure::Type ctrltype = CR::WellFailure::Type::Invalid;
|
||||
|
||||
@ -120,21 +120,21 @@ checkConvergenceControlEq(const WellState<double>& well_state,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WellConvergence::
|
||||
checkConvergencePolyMW(const std::vector<double>& res,
|
||||
template<class Scalar>
|
||||
void WellConvergence<Scalar>::
|
||||
checkConvergencePolyMW(const std::vector<Scalar>& res,
|
||||
const int Bhp,
|
||||
const double maxResidualAllowed,
|
||||
const Scalar maxResidualAllowed,
|
||||
ConvergenceReport& report) const
|
||||
{
|
||||
if (well_.isInjector()) {
|
||||
// checking the convergence of the perforation rates
|
||||
const double wat_vel_tol = 1.e-8;
|
||||
const Scalar wat_vel_tol = 1.e-8;
|
||||
const int dummy_component = -1;
|
||||
using CR = ConvergenceReport;
|
||||
const auto wat_vel_failure_type = CR::WellFailure::Type::MassBalance;
|
||||
for (int perf = 0; perf < well_.numPerfs(); ++perf) {
|
||||
const double wat_vel_residual = res[Bhp + 1 + perf];
|
||||
const Scalar wat_vel_residual = res[Bhp + 1 + perf];
|
||||
if (std::isnan(wat_vel_residual)) {
|
||||
report.setWellFailed({wat_vel_failure_type, CR::Severity::NotANumber, dummy_component, well_.name()});
|
||||
} else if (wat_vel_residual > maxResidualAllowed * 10.) {
|
||||
@ -145,10 +145,10 @@ checkConvergencePolyMW(const std::vector<double>& res,
|
||||
}
|
||||
|
||||
// checking the convergence of the skin pressure
|
||||
const double pskin_tol = 1000.; // 1000 pascal
|
||||
const Scalar pskin_tol = 1000.; // 1000 pascal
|
||||
const auto pskin_failure_type = CR::WellFailure::Type::Pressure;
|
||||
for (int perf = 0; perf < well_.numPerfs(); ++perf) {
|
||||
const double pskin_residual = res[Bhp + 1 + perf + well_.numPerfs()];
|
||||
const Scalar pskin_residual = res[Bhp + 1 + perf + well_.numPerfs()];
|
||||
if (std::isnan(pskin_residual)) {
|
||||
report.setWellFailed({pskin_failure_type, CR::Severity::NotANumber, dummy_component, well_.name()});
|
||||
} else if (pskin_residual > maxResidualAllowed * 10.) {
|
||||
@ -160,4 +160,6 @@ checkConvergencePolyMW(const std::vector<double>& res,
|
||||
}
|
||||
}
|
||||
|
||||
template class WellConvergence<double>;
|
||||
|
||||
}
|
||||
|
@ -33,36 +33,37 @@ class DeferredLogger;
|
||||
template<class Scalar> class WellInterfaceGeneric;
|
||||
template<class Scalar> class WellState;
|
||||
|
||||
template<class Scalar>
|
||||
class WellConvergence
|
||||
{
|
||||
public:
|
||||
WellConvergence(const WellInterfaceGeneric<double>& well)
|
||||
WellConvergence(const WellInterfaceGeneric<Scalar>& well)
|
||||
: well_(well)
|
||||
{}
|
||||
|
||||
struct Tolerances {
|
||||
double bhp; //!< Tolerance for bhp controlled well
|
||||
double thp; //!< Tolerance for thp controlled well
|
||||
double rates; //!< Tolerance for a rate controlled well
|
||||
double grup; //!< Tolerance for a grup controlled well
|
||||
double max_residual_allowed; //!< Max residual allowd
|
||||
Scalar bhp; //!< Tolerance for bhp controlled well
|
||||
Scalar thp; //!< Tolerance for thp controlled well
|
||||
Scalar rates; //!< Tolerance for a rate controlled well
|
||||
Scalar grup; //!< Tolerance for a grup controlled well
|
||||
Scalar max_residual_allowed; //!< Max residual allowd
|
||||
};
|
||||
|
||||
// checking the convergence of the well control equations
|
||||
void checkConvergenceControlEq(const WellState<double>& well_state,
|
||||
void checkConvergenceControlEq(const WellState<Scalar>& well_state,
|
||||
const Tolerances& tolerances,
|
||||
const double well_control_residual,
|
||||
const Scalar well_control_residual,
|
||||
const bool well_is_stopped,
|
||||
ConvergenceReport& report,
|
||||
DeferredLogger& deferred_logger) const;
|
||||
|
||||
void checkConvergencePolyMW(const std::vector<double>& res,
|
||||
void checkConvergencePolyMW(const std::vector<Scalar>& res,
|
||||
const int Bhp,
|
||||
const double maxResidualAllowed,
|
||||
const Scalar maxResidualAllowed,
|
||||
ConvergenceReport& report) const;
|
||||
|
||||
private:
|
||||
const WellInterfaceGeneric<double>& well_;
|
||||
const WellInterfaceGeneric<Scalar>& well_;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user