MathUtils Namespace

MOOSE includes a number of C++ utility classes and functions that may be useful for developing applications with mathematical expressions.

Polynomial evaluations

MathUtils::poly evaluates a polynomial for any integer order n>0n>0 using the Horner's method of evaluation, p(x)=c0+c1x+c2x2+...+anxn p(x) = c_0 + c_1 x + c_2 x^2 + ... + a_n x^n p(x)=c0+x(a1+x(a2+...+x(an1+xan))) p(x) = c_0 + x * (a_1 + x(a_2 + ... + x (a_{n-1} + x a_n)))

Clamp

MathUtils::clamp returns a clamped value yy between an upper and lower bound, LlowerL_{lower} and LhigherL_{higher} respectively, y={Llowerx<LlowerLhigherx>LhigherxOtherwise y = \begin{cases} L_{lower} & x < L_{lower} \\ L_{higher} & x > L_{higher} \\ x & \text{Otherwise} \end{cases}

SmootherStep

MathUtils::smootherStep returns a smoothed step transition between a starting and ending bounds, BlowerB_{lower} and BhigherB_{higher} respectively, for a given value uu, x=uBlowerBhigherBlower x = \frac{u - B_{lower}}{B_{higher} - B_{lower}} y={0u<=Blower1u>=Bhigher6x515x4+10x3Otherwise y = \begin{cases} 0 & u <= B_{lower} \\ 1 & u >= B_{higher} \\ 6x^5 - 15 x^4 + 10x^3 & \text{Otherwise} \end{cases} This method ensures a smooth transition from 0 to 1 between the two bounds, while also ensuring the first and second derivatives are zero at the two bounds. Use of this method is especially useful when transitioning between two non-smooth regimes. The derivative with respect to the passed value uu is returned using the optional derivative bool. Note that if u=Blower=Bhigheru = B_{lower} = B_{higher}, then zero will be returned.