Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
PorousFlowCubic.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "PorousFlowCubic.h"
11 #include "libmesh/utility.h"
12 
13 namespace PorousFlowCubic
14 {
15 Real
16 cubic(Real x, Real x0, Real y0, Real y0p, Real x1, Real y1, Real y1p)
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 }
37 
38 Real
39 dcubic(Real x, Real x0, Real y0, Real y0p, Real x1, Real y1, Real y1p)
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 }
54 }
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&#39;(x0) = y0p f(x1) = y1 f&#39;(x1) = y1p.
const std::vector< double > x
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.
Utility to produce the value and derivative of a cubic function at a point.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real