9 #include "gtest/gtest.h" 14 #include "libmesh/utility.h" 21 Real lower_bound = 0.7;
22 Real upper_bound = 17.3;
24 Real xref = 2 / (upper_bound - lower_bound) * (
x - (upper_bound + lower_bound) / 2);
27 Real val = 1 / 8.0 * (63.0 * Utility::pow<5>(xref) - 70.0 * xref * xref * xref + 15.0 * xref);
28 EXPECT_NEAR(poly_val, val,
tol);
30 std::vector<Real> xq_ref(5);
31 xq_ref[0] = -1 / 3.0 * std::sqrt(5.0 + 2.0 * std::sqrt(10.0 / 7.0));
32 xq_ref[1] = -1 / 3.0 * std::sqrt(5.0 - 2.0 * std::sqrt(10.0 / 7.0));
34 xq_ref[3] = -xq_ref[0];
35 xq_ref[4] = -xq_ref[1];
36 for (
unsigned int n = 0; n < 5; ++n)
37 xq_ref[n] = xq_ref[n] * (upper_bound - lower_bound) / 2.0 + (upper_bound + lower_bound) / 2.0;
39 std::vector<Real> wq_ref(5);
40 wq_ref[0] = (322.0 - 13.0 * std::sqrt(70.0)) / 1800.0;
41 wq_ref[1] = (322.0 + 13.0 * std::sqrt(70.0)) / 1800.0;
42 wq_ref[2] = 64.0 / 225.0;
43 wq_ref[3] = wq_ref[0];
44 wq_ref[4] = wq_ref[1];
49 for (
unsigned int n = 0; n < 5; ++n)
51 EXPECT_NEAR(xq[n], xq_ref[n],
tol);
52 EXPECT_NEAR(wq[n], wq_ref[n],
tol);
65 Real val = Utility::pow<4>(xref) - 6.0 * xref * xref + 3.0;
66 EXPECT_NEAR(poly_val, val,
tol);
68 std::vector<Real> xq_ref(4);
69 xq_ref[0] = -std::sqrt(3.0 + std::sqrt(6.0));
70 xq_ref[1] = -std::sqrt(3.0 - std::sqrt(6.0));
71 xq_ref[2] = -xq_ref[1];
72 xq_ref[3] = -xq_ref[0];
73 for (
unsigned int n = 0; n < 4; ++n)
74 xq_ref[n] = xq_ref[n] * sig +
mu;
76 std::vector<Real> wq_ref(4);
77 wq_ref[0] = 1.0 / (4.0 * (3.0 + std::sqrt(6.0)));
78 wq_ref[1] = 1.0 / (4.0 * (3.0 - std::sqrt(6.0)));
79 wq_ref[2] = wq_ref[1];
80 wq_ref[3] = wq_ref[0];
85 for (
unsigned int n = 0; n < 4; ++n)
87 EXPECT_NEAR(xq[n], xq_ref[n],
tol);
88 EXPECT_NEAR(wq[n], wq_ref[n],
tol);
96 EXPECT_EQ((std::size_t)11, xq.size());
97 EXPECT_EQ((std::size_t)11, wq.size());
99 EXPECT_NEAR(xq[0], -1.0000000000000000e+00,
tol);
100 EXPECT_NEAR(xq[1], -9.5105651629515353e-01,
tol);
101 EXPECT_NEAR(xq[2], -8.0901699437494745e-01,
tol);
102 EXPECT_NEAR(xq[3], -5.8778525229247314e-01,
tol);
103 EXPECT_NEAR(xq[4], -3.0901699437494745e-01,
tol);
104 EXPECT_NEAR(xq[5], +0.0000000000000000e+00,
tol);
105 EXPECT_NEAR(xq[6], +3.0901699437494745e-01,
tol);
106 EXPECT_NEAR(xq[7], +5.8778525229247314e-01,
tol);
107 EXPECT_NEAR(xq[8], +8.0901699437494745e-01,
tol);
108 EXPECT_NEAR(xq[9], +9.5105651629515353e-01,
tol);
109 EXPECT_NEAR(xq[10], +1.0000000000000000e+00,
tol);
111 EXPECT_NEAR(wq[0], +5.0505050505050535e-03,
tol);
112 EXPECT_NEAR(wq[1], +4.7289527441850783e-02,
tol);
113 EXPECT_NEAR(wq[2], +9.2817607212123884e-02,
tol);
114 EXPECT_NEAR(wq[3], +1.2679416664184331e-01,
tol);
115 EXPECT_NEAR(wq[4], +1.4960663521211851e-01,
tol);
116 EXPECT_NEAR(wq[5], +1.5688311688311693e-01,
tol);
117 EXPECT_NEAR(wq[6], +1.4960663521211851e-01,
tol);
118 EXPECT_NEAR(wq[7], +1.2679416664184331e-01,
tol);
119 EXPECT_NEAR(wq[8], +9.2817607212123884e-02,
tol);
120 EXPECT_NEAR(wq[9], +4.7289527441850783e-02,
tol);
121 EXPECT_NEAR(wq[10], +5.0505050505050535e-03,
tol);
128 const Real lower_bound = 0.7;
129 const Real upper_bound = 17.3;
130 std::unique_ptr<const Polynomial> ptr0 =
131 std::make_unique<const Legendre>(lower_bound, upper_bound);
133 std::stringbuf buffer;
134 std::iostream stream(&buffer);
137 std::unique_ptr<const Polynomial> ptr1;
140 EXPECT_EQ(ptr0->innerProduct(1), ptr1->innerProduct(1));
147 const Real sig = 0.9438;
148 std::unique_ptr<const Polynomial> ptr0 = std::make_unique<const Hermite>(
mu, sig);
150 std::stringbuf buffer;
151 std::iostream stream(&buffer);
154 std::unique_ptr<const Polynomial> ptr1;
157 EXPECT_EQ(ptr0->innerProduct(1), ptr1->innerProduct(1));
void gauss_hermite(const unsigned int order, std::vector< Real > &points, std::vector< Real > &weights, const Real mu, const Real sig)
Generalized formula for any polynomial order.
void dataStore(std::ostream &stream, FaceCenteredMapFunctor< T, Map > &m, void *context)
const std::vector< double > x
static const std::string mu
void clenshaw_curtis(const unsigned int order, std::vector< Real > &points, std::vector< Real > &weights)
Real hermite(const unsigned int order, const Real x, const Real mu=0.0, const Real sig=1.0)
Hermite polynomial of specified order.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Polynomials and quadratures based on defined distributions for Polynomial Chaos.
Real legendre(const unsigned int order, const Real x, const Real lower_bound=-1.0, const Real upper_bound=1.0)
Legendre polynomial of specified order.
void dataLoad(std::istream &stream, FaceCenteredMapFunctor< T, Map > &m, void *context)
TEST(PolynomialQuadrature, legendre)
void gauss_legendre(const unsigned int order, std::vector< Real > &points, std::vector< Real > &weights, const Real lower_bound, const Real upper_bound)
Generalized formula for any polynomial order.