Skip to content

[MathLib] Avoid the division by zero in componentwiseDivide

wenqing requested to merge wenqing/ogs:fix_alg into master

The function MathLib::LinAlg::componentwiseDivide computes the division of two vectors, x/y component-wise. In the Eigen specialization of that template function, Eigen vector member function cwiseQuotient is called to compute x/y. Unfortunately, the division by zero gives nan by cwiseQuotient. This MR replaces cwiseQuotient with binaryExpr.

Note that MathLib::LinAlg::componentwiseDivide is used in the extrapolation function, where y is a vector stores the counts of elements for a node for extrapolation. For a node, if there is no contribution of the extrapolated integration point values from its connected elements, the count is zero.

  1. Feature description was added to the changelog
  2. Tests covering your feature were added?
  3. Any new feature or behavior change was documented?
Edited by wenqing

Merge request reports