Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
PorousFlowCubicTest.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 "gtest/gtest.h"
11 
12 #include "PorousFlowCubic.h"
13 
14 const double eps = 1.0E-8;
15 
18 {
19  EXPECT_NEAR(3.0, PorousFlowCubic::cubic(2.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), 1.0E-12);
20  EXPECT_NEAR(4.0,
21  (PorousFlowCubic::cubic(2.0 + eps, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0) -
22  PorousFlowCubic::cubic(2.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)) /
23  eps,
24  1.0E-5);
25  EXPECT_NEAR(6.0, PorousFlowCubic::cubic(5.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), 1.0E-12);
26  EXPECT_NEAR(7.0,
27  (PorousFlowCubic::cubic(5.0 + eps, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0) -
28  PorousFlowCubic::cubic(5.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)) /
29  eps,
30  1.0E-5);
31  EXPECT_NEAR(-6.0, PorousFlowCubic::cubic(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), 1.0E-12);
32  EXPECT_NEAR(4.0, PorousFlowCubic::cubic(3.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), 1.0E-12);
33  EXPECT_NEAR(3.0, PorousFlowCubic::cubic(4.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), 1.0E-12);
34  EXPECT_NEAR(48.0, PorousFlowCubic::cubic(7.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), 1.0E-12);
35 }
36 
39 {
40  EXPECT_NEAR(4.0, PorousFlowCubic::dcubic(2.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), 1.0E-12);
41  EXPECT_NEAR(7.0, PorousFlowCubic::dcubic(5.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0), 1.0E-12);
42  EXPECT_NEAR(PorousFlowCubic::dcubic(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0),
43  (PorousFlowCubic::cubic(1.0 + eps, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0) -
44  PorousFlowCubic::cubic(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)) /
45  eps,
46  1.0E-5);
47  EXPECT_NEAR(PorousFlowCubic::dcubic(3.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0),
48  (PorousFlowCubic::cubic(3.0 + eps, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0) -
49  PorousFlowCubic::cubic(3.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)) /
50  eps,
51  1.0E-5);
52  EXPECT_NEAR(PorousFlowCubic::dcubic(4.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0),
53  (PorousFlowCubic::cubic(4.0 + eps, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0) -
54  PorousFlowCubic::cubic(4.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)) /
55  eps,
56  1.0E-5);
57  EXPECT_NEAR(PorousFlowCubic::dcubic(7.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0),
58  (PorousFlowCubic::cubic(7.0 + eps, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0) -
59  PorousFlowCubic::cubic(7.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0)) /
60  eps,
61  1.0E-5);
62 }
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.
const double eps
TEST(PorousFlowCubic, cubic)
Test cubic.
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.