Nektar++
Loading...
Searching...
No Matches
Functions
Nektar::GaussGaussAlpha1Beta0UnitTests Namespace Reference

Functions

static NekDouble ExactMoment (const unsigned int k)
 The exact value of the integral of (1 - x) x^k over [-1, 1].
 
 BOOST_AUTO_TEST_CASE (TestGaussGaussAlpha1Beta0Quadrature)
 The n-point rule integrates (1 - x) x^k exactly for k up to 2n - 1, as a Gauss rule for that weight must, and not for k = 2n; its points are interior and ascending.
 
 BOOST_AUTO_TEST_CASE (TestGaussGaussAlpha1Beta0DerivAndInterp)
 The derivative matrix differentiates, and the interpolation matrix to Gauss-Lobatto-Legendre points interpolates, every polynomial of degree up to n - 1 exactly.
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

Nektar::GaussGaussAlpha1Beta0UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussGaussAlpha1Beta0DerivAndInterp  )

The derivative matrix differentiates, and the interpolation matrix to Gauss-Lobatto-Legendre points interpolates, every polynomial of degree up to n - 1 exactly.

Definition at line 107 of file TestGaussGaussAlpha1Beta0.cpp.

108{
109 for (unsigned int n = 2; n <= 8; ++n)
110 {
111 const PointsKey key(n, eGaussGaussAlpha1Beta0);
112 const auto &pts = PointsManager()[key];
114 pts->GetPoints(z);
115
116 const PointsKey toKey(10, eGaussLobattoLegendre);
118 PointsManager()[toKey]->GetPoints(zTo);
119
120 const auto D = pts->GetD();
121 const auto I = pts->GetI(toKey);
122 BOOST_REQUIRE_EQUAL(I->GetRows(), 10u);
123 BOOST_REQUIRE_EQUAL(I->GetColumns(), n);
124
125 for (unsigned int k = 0; k < n; ++k)
126 {
127 for (unsigned int i = 0; i < n; ++i)
128 {
129 NekDouble d = 0.0;
130 for (unsigned int j = 0; j < n; ++j)
131 {
132 d += D->GetValue(i, j) * std::pow(z[j], k);
133 }
134 const NekDouble exact =
135 k == 0 ? 0.0 : k * std::pow(z[i], k - 1);
136 BOOST_CHECK_SMALL(d - exact, 1.0e-11);
137 }
138
139 for (unsigned int i = 0; i < 10; ++i)
140 {
141 NekDouble v = 0.0;
142 for (unsigned int j = 0; j < n; ++j)
143 {
144 v += I->GetValue(i, j) * std::pow(z[j], k);
145 }
146 BOOST_CHECK_SMALL(v - std::pow(zTo[i], k), 1.0e-12);
147 }
148 }
149 }
150}
Defines a specification for a set of points.
Definition Points.h:50
PointsManagerT & PointsManager(void)

References Nektar::LibUtilities::eGaussGaussAlpha1Beta0, Nektar::LibUtilities::eGaussLobattoLegendre, and Nektar::LibUtilities::PointsManager().

◆ BOOST_AUTO_TEST_CASE() [2/2]

Nektar::GaussGaussAlpha1Beta0UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussGaussAlpha1Beta0Quadrature  )

The n-point rule integrates (1 - x) x^k exactly for k up to 2n - 1, as a Gauss rule for that weight must, and not for k = 2n; its points are interior and ascending.

Definition at line 64 of file TestGaussGaussAlpha1Beta0.cpp.

65{
66 for (unsigned int n = 2; n <= 8; ++n)
67 {
68 const PointsKey key(n, eGaussGaussAlpha1Beta0);
70 PointsManager()[key]->GetZW(z, w);
71 BOOST_REQUIRE_EQUAL(z.size(), n);
72
73 for (unsigned int i = 0; i < n; ++i)
74 {
75 BOOST_CHECK(z[i] > -1.0 && z[i] < 1.0);
76 if (i > 0)
77 {
78 BOOST_CHECK(z[i] > z[i - 1]);
79 }
80 }
81
82 for (unsigned int k = 0; k <= 2 * n; ++k)
83 {
84 NekDouble sum = 0.0;
85 for (unsigned int i = 0; i < n; ++i)
86 {
87 sum += w[i] * std::pow(z[i], k);
88 }
89 const NekDouble err = std::abs(sum - ExactMoment(k));
90 if (k <= 2 * n - 1)
91 {
92 BOOST_CHECK_SMALL(err, 1.0e-14);
93 }
94 else
95 {
96 BOOST_CHECK(err > 1.0e-6);
97 }
98 }
99 }
100}
std::map< int64_t, double > sum
static NekDouble ExactMoment(const unsigned int k)
The exact value of the integral of (1 - x) x^k over [-1, 1].

References Nektar::LibUtilities::eGaussGaussAlpha1Beta0, ExactMoment(), Nektar::LibUtilities::PointsManager(), and sum.

◆ ExactMoment()

static NekDouble Nektar::GaussGaussAlpha1Beta0UnitTests::ExactMoment ( const unsigned int  k)
static

The exact value of the integral of (1 - x) x^k over [-1, 1].

Definition at line 51 of file TestGaussGaussAlpha1Beta0.cpp.

52{
53 const auto mono = [](const unsigned int m) {
54 return (m % 2 == 0) ? 2.0 / (m + 1.0) : 0.0;
55 };
56 return mono(k) - mono(k + 1);
57}

Referenced by BOOST_AUTO_TEST_CASE().