Prevent zero division

This commit is contained in:
Michal Tóth committed 2025-03-10 09:07:35 +01:00
1 parent 98703f0c99
commit 847f9f496e
1 file changed
+8 -1
@@ -333,7 +333,14 @@ extractCPRPressureMatrix(PressureMatrix& jacobian,
nperf += 1;
}
}
cell_weights /= nperf;
if (nperf != 0)
cell_weights /= nperf;
else {
// Edge case: the well has no active perforations on this rank (duneC_.size==0).
// Add positive weight to diagonal to regularize Jacobian (other row entries are 0).
// Row's variable has no observable effect, since there are no perforations.
cell_weights = 1.;
}
BVectorWell bweights(1);
std::size_t blockSz = duneD_[0][0].N();