mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
make relaxationFactorRate an anon helper in StandardWellPrimaryVariables
This commit is contained in:
@@ -55,31 +55,6 @@ StandardWellGeneric(const WellInterfaceGeneric& baseif)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Scalar>
|
|
||||||
double
|
|
||||||
StandardWellGeneric<Scalar>::
|
|
||||||
relaxationFactorRate(const std::vector<double>& primary_variables,
|
|
||||||
const double newton_update)
|
|
||||||
{
|
|
||||||
double relaxation_factor = 1.0;
|
|
||||||
static constexpr int WQTotal = 0;
|
|
||||||
|
|
||||||
// For injector, we only check the total rates to avoid sign change of rates
|
|
||||||
const double original_total_rate = primary_variables[WQTotal];
|
|
||||||
const double possible_update_total_rate = primary_variables[WQTotal] - newton_update;
|
|
||||||
|
|
||||||
// 0.8 here is a experimental value, which remains to be optimized
|
|
||||||
// if the original rate is zero or possible_update_total_rate is zero, relaxation_factor will
|
|
||||||
// always be 1.0, more thoughts might be needed.
|
|
||||||
if (original_total_rate * possible_update_total_rate < 0.) { // sign changed
|
|
||||||
relaxation_factor = std::abs(original_total_rate / newton_update) * 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(relaxation_factor >= 0.0 && relaxation_factor <= 1.0);
|
|
||||||
|
|
||||||
return relaxation_factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Scalar>
|
template<class Scalar>
|
||||||
void
|
void
|
||||||
StandardWellGeneric<Scalar>::
|
StandardWellGeneric<Scalar>::
|
||||||
|
|||||||
@@ -48,11 +48,6 @@ class WellState;
|
|||||||
template<class Scalar>
|
template<class Scalar>
|
||||||
class StandardWellGeneric
|
class StandardWellGeneric
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
// calculate a relaxation factor to avoid overshoot of total rates
|
|
||||||
static double relaxationFactorRate(const std::vector<double>& primary_variables,
|
|
||||||
const double newton_update);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StandardWellGeneric(const WellInterfaceGeneric& baseif);
|
StandardWellGeneric(const WellInterfaceGeneric& baseif);
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,30 @@ Scalar relaxationFactorFraction(const Scalar old_value,
|
|||||||
return relaxation_factor;
|
return relaxation_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \brief Calculate a relaxation factor to avoid overshoot of total rates.
|
||||||
|
template<class Scalar>
|
||||||
|
Scalar relaxationFactorRate(const std::vector<Scalar>& primary_variables,
|
||||||
|
const Scalar newton_update)
|
||||||
|
{
|
||||||
|
Scalar relaxation_factor = 1.0;
|
||||||
|
static constexpr int WQTotal = 0;
|
||||||
|
|
||||||
|
// For injector, we only check the total rates to avoid sign change of rates
|
||||||
|
const Scalar original_total_rate = primary_variables[WQTotal];
|
||||||
|
const Scalar possible_update_total_rate = primary_variables[WQTotal] - newton_update;
|
||||||
|
|
||||||
|
// 0.8 here is a experimental value, which remains to be optimized
|
||||||
|
// if the original rate is zero or possible_update_total_rate is zero, relaxation_factor will
|
||||||
|
// always be 1.0, more thoughts might be needed.
|
||||||
|
if (original_total_rate * possible_update_total_rate < 0.) { // sign changed
|
||||||
|
relaxation_factor = std::abs(original_total_rate / newton_update) * 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(relaxation_factor >= 0.0 && relaxation_factor <= 1.0);
|
||||||
|
|
||||||
|
return relaxation_factor;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
@@ -253,7 +277,7 @@ updateNewton(const BVectorWell& dwells,
|
|||||||
this->processFractions();
|
this->processFractions();
|
||||||
|
|
||||||
// updating the total rates Q_t
|
// updating the total rates Q_t
|
||||||
const double relaxation_factor_rate = StandardWellGeneric<Scalar>::relaxationFactorRate(old_primary_variables, dwells[0][WQTotal]);
|
const double relaxation_factor_rate = relaxationFactorRate(old_primary_variables, dwells[0][WQTotal]);
|
||||||
value_[WQTotal] = old_primary_variables[WQTotal] - dwells[0][WQTotal] * relaxation_factor_rate;
|
value_[WQTotal] = old_primary_variables[WQTotal] - dwells[0][WQTotal] * relaxation_factor_rate;
|
||||||
|
|
||||||
// updating the bottom hole pressure
|
// updating the bottom hole pressure
|
||||||
|
|||||||
Reference in New Issue
Block a user