mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-26 07:30:08 -05:00
Merge pull request #6185 from lisajulia/fix/divisions-by-zero
Do not divide by zero but check before dividing
This commit is contained in:
2 files changed
+5
-9
No files matched your search
@@ -557,11 +557,9 @@ production(const std::size_t reportStepNum,
|
||||
|
||||
if (values[Ix::WaterRate] == 0.0) {
|
||||
values[Ix::WatGasRatio] = 0;
|
||||
} else {
|
||||
} else if (values[Ix::GasRate] != 0.0) {
|
||||
values[Ix::WatGasRatio] = values[Ix::WaterRate] / values[Ix::GasRate];
|
||||
}
|
||||
|
||||
if (std::isnan(values[Ix::WatGasRatio])) {
|
||||
} else {
|
||||
values[Ix::WatGasRatio] = 0.0;
|
||||
}
|
||||
|
||||
@@ -600,11 +598,9 @@ production(const std::size_t reportStepNum,
|
||||
{
|
||||
if (v[Ix::WaterRate] == 0.0) {
|
||||
v[Ix::WatGasRatio] = 0.0;
|
||||
} else {
|
||||
} else if (v[Ix::GasRate] != 0.0) {
|
||||
v[Ix::WatGasRatio] = v[Ix::WaterRate] / v[Ix::GasRate];
|
||||
}
|
||||
|
||||
if (std::isnan(v[Ix::WatGasRatio])) {
|
||||
} else {
|
||||
v[Ix::WatGasRatio] = 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ pressureAverage(const Scalar pressurePvHydrocarbon,
|
||||
if (hydrocarbon && (pvHydrocarbon > 1e-10))
|
||||
return pressurePvHydrocarbon / pvHydrocarbon;
|
||||
|
||||
return pressurePv / pv;
|
||||
return (pressurePv == 0) ? 0 : pressurePv / pv;
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
|
||||
Reference in new issue
Block a user