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 <cmath>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm {
|
||||||
{
|
|
||||||
|
|
||||||
void WellConvergence::
|
template<class Scalar>
|
||||||
checkConvergenceControlEq(const WellState<double>& well_state,
|
void WellConvergence<Scalar>::
|
||||||
|
checkConvergenceControlEq(const WellState<Scalar>& well_state,
|
||||||
const Tolerances& tolerances,
|
const Tolerances& tolerances,
|
||||||
const double well_control_residual,
|
const Scalar well_control_residual,
|
||||||
const bool well_is_stopped,
|
const bool well_is_stopped,
|
||||||
ConvergenceReport& report,
|
ConvergenceReport& report,
|
||||||
DeferredLogger& deferred_logger) const
|
DeferredLogger& deferred_logger) const
|
||||||
{
|
{
|
||||||
double control_tolerance = 0.;
|
Scalar control_tolerance = 0.;
|
||||||
using CR = ConvergenceReport;
|
using CR = ConvergenceReport;
|
||||||
CR::WellFailure::Type ctrltype = CR::WellFailure::Type::Invalid;
|
CR::WellFailure::Type ctrltype = CR::WellFailure::Type::Invalid;
|
||||||
|
|
||||||
@ -120,21 +120,21 @@ checkConvergenceControlEq(const WellState<double>& well_state,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
template<class Scalar>
|
||||||
WellConvergence::
|
void WellConvergence<Scalar>::
|
||||||
checkConvergencePolyMW(const std::vector<double>& res,
|
checkConvergencePolyMW(const std::vector<Scalar>& res,
|
||||||
const int Bhp,
|
const int Bhp,
|
||||||
const double maxResidualAllowed,
|
const Scalar maxResidualAllowed,
|
||||||
ConvergenceReport& report) const
|
ConvergenceReport& report) const
|
||||||
{
|
{
|
||||||
if (well_.isInjector()) {
|
if (well_.isInjector()) {
|
||||||
// checking the convergence of the perforation rates
|
// 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;
|
const int dummy_component = -1;
|
||||||
using CR = ConvergenceReport;
|
using CR = ConvergenceReport;
|
||||||
const auto wat_vel_failure_type = CR::WellFailure::Type::MassBalance;
|
const auto wat_vel_failure_type = CR::WellFailure::Type::MassBalance;
|
||||||
for (int perf = 0; perf < well_.numPerfs(); ++perf) {
|
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)) {
|
if (std::isnan(wat_vel_residual)) {
|
||||||
report.setWellFailed({wat_vel_failure_type, CR::Severity::NotANumber, dummy_component, well_.name()});
|
report.setWellFailed({wat_vel_failure_type, CR::Severity::NotANumber, dummy_component, well_.name()});
|
||||||
} else if (wat_vel_residual > maxResidualAllowed * 10.) {
|
} else if (wat_vel_residual > maxResidualAllowed * 10.) {
|
||||||
@ -145,10 +145,10 @@ checkConvergencePolyMW(const std::vector<double>& res,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checking the convergence of the skin pressure
|
// 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;
|
const auto pskin_failure_type = CR::WellFailure::Type::Pressure;
|
||||||
for (int perf = 0; perf < well_.numPerfs(); ++perf) {
|
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)) {
|
if (std::isnan(pskin_residual)) {
|
||||||
report.setWellFailed({pskin_failure_type, CR::Severity::NotANumber, dummy_component, well_.name()});
|
report.setWellFailed({pskin_failure_type, CR::Severity::NotANumber, dummy_component, well_.name()});
|
||||||
} else if (pskin_residual > maxResidualAllowed * 10.) {
|
} 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 WellInterfaceGeneric;
|
||||||
template<class Scalar> class WellState;
|
template<class Scalar> class WellState;
|
||||||
|
|
||||||
|
template<class Scalar>
|
||||||
class WellConvergence
|
class WellConvergence
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WellConvergence(const WellInterfaceGeneric<double>& well)
|
WellConvergence(const WellInterfaceGeneric<Scalar>& well)
|
||||||
: well_(well)
|
: well_(well)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
struct Tolerances {
|
struct Tolerances {
|
||||||
double bhp; //!< Tolerance for bhp controlled well
|
Scalar bhp; //!< Tolerance for bhp controlled well
|
||||||
double thp; //!< Tolerance for thp controlled well
|
Scalar thp; //!< Tolerance for thp controlled well
|
||||||
double rates; //!< Tolerance for a rate controlled well
|
Scalar rates; //!< Tolerance for a rate controlled well
|
||||||
double grup; //!< Tolerance for a grup controlled well
|
Scalar grup; //!< Tolerance for a grup controlled well
|
||||||
double max_residual_allowed; //!< Max residual allowd
|
Scalar max_residual_allowed; //!< Max residual allowd
|
||||||
};
|
};
|
||||||
|
|
||||||
// checking the convergence of the well control equations
|
// 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 Tolerances& tolerances,
|
||||||
const double well_control_residual,
|
const Scalar well_control_residual,
|
||||||
const bool well_is_stopped,
|
const bool well_is_stopped,
|
||||||
ConvergenceReport& report,
|
ConvergenceReport& report,
|
||||||
DeferredLogger& deferred_logger) const;
|
DeferredLogger& deferred_logger) const;
|
||||||
|
|
||||||
void checkConvergencePolyMW(const std::vector<double>& res,
|
void checkConvergencePolyMW(const std::vector<Scalar>& res,
|
||||||
const int Bhp,
|
const int Bhp,
|
||||||
const double maxResidualAllowed,
|
const Scalar maxResidualAllowed,
|
||||||
ConvergenceReport& report) const;
|
ConvergenceReport& report) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const WellInterfaceGeneric<double>& well_;
|
const WellInterfaceGeneric<Scalar>& well_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user