https://mooseframework.inl.gov
Functions
PorousFlowCubic Namespace Reference

Utility to produce the value and derivative of a cubic function at a point. More...

Functions

Real cubic (Real x, Real x0, Real y0, Real y0p, Real x1, Real y1, Real y1p)
 Cubic function f(x) that satisfies f(x0) = y0 f'(x0) = y0p f(x1) = y1 f'(x1) = y1p. More...
 
Real dcubic (Real x, Real x0, Real y0, Real y0p, Real x1, Real y1, Real y1p)
 Derivative of cubic function, f(x), with respect to x. More...
 

Detailed Description

Utility to produce the value and derivative of a cubic function at a point.

The cubic is defined by values and derivatives at two points.

Function Documentation

◆ cubic()

Real PorousFlowCubic::cubic ( Real  x,
Real  x0,
Real  y0,
Real  y0p,
Real  x1,
Real  y1,
Real  y1p 
)

Cubic function f(x) that satisfies f(x0) = y0 f'(x0) = y0p f(x1) = y1 f'(x1) = y1p.

Parameters
xthe argument
Returns
value of the cubic function at x

Definition at line 16 of file PorousFlowCubic.C.

Referenced by PorousFlowVanGenuchten::relativePermeabilityHys(), PorousFlowVanGenuchten::relativePermeabilityNWHys(), and TEST().

17 {
18  mooseAssert(x0 != x1, "PorousFlowCubic: x0 cannot equal x1");
19  const Real d = x1 - x0;
20  const Real d2 = Utility::pow<2>(d);
21  const Real mean = 0.5 * (x1 + x0);
22  const Real sq3 = 0.5 * std::sqrt(3.0) * d;
23  const Real term1 = y0p * (x - x0) * Utility::pow<2>(x - x1) /
24  d2; // term1(x0) = term1(x1) = term1'(x1) = 0, term1'(x0) = y0p
25  const Real term2 = y1p * (x - x1) * Utility::pow<2>(x - x0) /
26  d2; // term2(x0) = term2(x1) = term2'(x0) = 0, term2'(x1) = y1p
27  const Real term3 = (x - mean - sq3) * (x - mean) * (x - mean + sq3);
28  // term3' = (x - mean) * (x - mean + sq3) + (x - mean - sq3) * (x - mean + sq3) + (x - mean - sq3)
29  // * (x - mean)
30  // = 3 (x - mean)^2 - sq3^2
31  // note term3' = 0 when x = mean +/- sq3/sqrt(3) = 0.5 * (x1 + x0) +/- 0.5 * (x1 - x0) = {x1, x0}
32  const Real term3_x0 = (x0 - mean - sq3) * (x0 - mean) * (x0 - mean + sq3);
33  const Real term3_x1 = (x1 - mean - sq3) * (x1 - mean) * (x1 - mean + sq3);
34  return (y0 * (term3 - term3_x1) + y1 * (term3_x0 - term3)) / (term3_x0 - term3_x1) + term1 +
35  term2;
36 }
const std::vector< double > x
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ dcubic()

Real PorousFlowCubic::dcubic ( Real  x,
Real  x0,
Real  y0,
Real  y0p,
Real  x1,
Real  y1,
Real  y1p 
)

Derivative of cubic function, f(x), with respect to x.

f(x) satisfies f(x0) = y0 f'(x0) = y0p f(x1) = y1 f'(x1) = y1p

Parameters
xthe argument
Returns
the derivative of the cubic function at x

Definition at line 39 of file PorousFlowCubic.C.

Referenced by PorousFlowVanGenuchten::drelativePermeabilityHys(), PorousFlowVanGenuchten::drelativePermeabilityNWHys(), and TEST().

40 {
41  mooseAssert(x0 != x1, "PorousFlowCubic: x0 cannot equal x1");
42  const Real d = x1 - x0;
43  const Real d2 = Utility::pow<2>(d);
44  const Real mean = 0.5 * (x1 + x0);
45  const Real sq3 = 0.5 * std::sqrt(3.0) * d;
46  const Real term1_prime = y0p * (Utility::pow<2>(x - x1) + (x - x0) * 2 * (x - x1)) / d2;
47  const Real term2_prime = y1p * (Utility::pow<2>(x - x0) + (x - x1) * 2 * (x - x0)) / d2;
48  const Real term3_prime =
49  3.0 * Utility::pow<2>(mean) - 6 * mean * x - 0.75 * d2 + 3.0 * Utility::pow<2>(x);
50  const Real term3_x0 = (x0 - mean - sq3) * (x0 - mean) * (x0 - mean + sq3);
51  const Real term3_x1 = (x1 - mean - sq3) * (x1 - mean) * (x1 - mean + sq3);
52  return (y0 - y1) * term3_prime / (term3_x0 - term3_x1) + term1_prime + term2_prime;
53 }
const std::vector< double > x
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real