Nektar++
Classes | Functions
Nektar::UnitTests Namespace Reference

Classes

class  PointTestClass
 
struct  TenD
 
class  TestPoint
 
class  VectorTestClass
 

Functions

double ddot (int n, double *x, int incx, double *y, int incy)
 Dot product two vectors. More...
 
std::vector< double > z (NPUPPER)
 
std::vector< double > w (NPUPPER)
 
std::vector< double > p (NPUPPER)
 
std::vector< double > d (NPUPPER *NPUPPER)
 
std::vector< double > q (NPUPPER *NPUPPER)
 
void TestIntegral (std::function< void(double *, double *, int, double, double)> func, int o)
 Test integrals of Jacobi polynomials. More...
 
void TestDifferentiation (std::function< void(double *, double *, int, double, double)> func, std::function< void(double *, double *, int, double, double)> funcD)
 Test derivatives using Gaussian quadrature. More...
 
void TestInterpolation (std::function< void(double *, double *, int, double, double)> func, std::function< void(double *, double *, double *, int, int, double, double)> funcI)
 Evaluate interpolation using Gaussian quadrature. More...
 
void TestIntegralMatrix (std::function< void(double *, double *, int, double, double)> func, std::function< void(double *, double *, int)> funcQ)
 
 BOOST_AUTO_TEST_CASE (TestGaussInt)
 
 BOOST_AUTO_TEST_CASE (TestGaussRadauM)
 
 BOOST_AUTO_TEST_CASE (TestGaussRadauP)
 
 BOOST_AUTO_TEST_CASE (TestGaussLobatto)
 
 BOOST_AUTO_TEST_CASE (TestGaussDiff)
 
 BOOST_AUTO_TEST_CASE (TestGaussRadauMDiff)
 
 BOOST_AUTO_TEST_CASE (TestGaussRadauPDiff)
 
 BOOST_AUTO_TEST_CASE (TestGaussLobattoDiff)
 
 BOOST_AUTO_TEST_CASE (TestGaussInterp)
 
 BOOST_AUTO_TEST_CASE (TestGaussRadauMInterp)
 
 BOOST_AUTO_TEST_CASE (TestGaussRadauPInterp)
 
 BOOST_AUTO_TEST_CASE (TestGaussLobattoInterp)
 
 BOOST_AUTO_TEST_CASE (TestGaussIntMatrix)
 
 BOOST_AUTO_TEST_CASE (TestGaussRadauMIntMatrix)
 
 BOOST_AUTO_TEST_CASE (TestGaussRadauPIntMatrix)
 
 BOOST_AUTO_TEST_CASE (TestGaussLobattoIntMatrix)
 
 BOOST_AUTO_TEST_CASE (TestGammaFraction)
 
 BOOST_AUTO_TEST_CASE (testNekMatrixConstruction)
 
 BOOST_AUTO_TEST_CASE (testNekMatrixBasicMath)
 
bool operator== (const PointTestClass &lhs, const PointTestClass &rhs)
 
bool operator!= (const PointTestClass &lhs, const PointTestClass &rhs)
 
void test ()
 
 BOOST_AUTO_TEST_CASE (testNekPointConstruction)
 
bool operator== (const VectorTestClass &lhs, const VectorTestClass &rhs)
 
bool operator!= (const VectorTestClass &lhs, const VectorTestClass &rhs)
 
 BOOST_AUTO_TEST_CASE (TestNekVectorConstruction)
 
 BOOST_AUTO_TEST_CASE (TestNekVectorOperators)
 
 BOOST_AUTO_TEST_CASE (TestNekVectorArithmetic)
 
 BOOST_AUTO_TEST_CASE (TestNorms)
 
 BOOST_AUTO_TEST_CASE (TestMatrixVectorMultiply)
 
 BOOST_AUTO_TEST_CASE (TestVectorConstructorsWithSizeArguments)
 
void RedirectCerrIfNeeded ()
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGammaFraction  )

Definition at line 326 of file TestPolylib.cpp.

327{
328 double a, c;
329
330 using arrT = std::tuple<int, double, int, double>;
331 std::vector<std::tuple<double, arrT, arrT>> ac = {
332 {362880.0, std::make_tuple(10, 0.0, 0, 1.0),
333 std::make_tuple(1, 0.0, 12, -2.0)},
334 {30.0, std::make_tuple(4, 3., 5, 0.), std::make_tuple(5, 0., 7, 0.)},
335 {21651.09375, std::make_tuple(7, 3.5, 5, 0.5),
336 std::make_tuple(5, 0.5, 10, 0.5)},
337 {97429.921875, std::make_tuple(10, 0.5, 5, -0.5),
338 std::make_tuple(5, -0.5, 11, -0.5)},
339 {2279.0625, std::make_tuple(10, -0.5, 5, 0.5),
340 std::make_tuple(5, 0.5, 10, -0.5)},
341 {639383.8623046875, std::make_tuple(10, 0.5, 0, 0.5),
342 std::make_tuple(0, 0.5, 10, 0.5)},
343 {5967498288235982848., std::make_tuple(100, 0., 90, 0.5),
344 std::make_tuple(90, 0.5, 100, 0.)},
345 {5618641603777298169856., std::make_tuple(200, 0., 191, -0.5),
346 std::make_tuple(190, 0.5, 200, 0.)},
347 {77396694214720029196288., std::make_tuple(200, 0., 190, 0.),
348 std::make_tuple(190, 0., 200, 0.)}};
349
350 for (auto &test : ac)
351 {
352 double a = std::get<0>(test);
353 arrT c1 = std::get<1>(test);
354 arrT c2 = std::get<2>(test);
355 double c1e = Polylib::gammaFracGammaF(std::get<0>(c1), std::get<1>(c1),
356 std::get<2>(c1), std::get<3>(c1));
357 double c2e = Polylib::gammaFracGammaF(std::get<0>(c2), std::get<1>(c2),
358 std::get<2>(c2), std::get<3>(c2));
359
360 BOOST_CHECK_SMALL(c1e / a - 1.0, EPS);
361 BOOST_CHECK_SMALL(c2e * a - 1.0, EPS);
362 }
363
364 int Q = 2;
365 for (double alpha = -0.5; alpha <= 150.; alpha += 0.5)
366 {
367 for (double beta = -0.5; beta <= 150.; beta += 0.5)
368 {
369 a = Polylib::gammaF(Q + alpha) / Polylib::gammaF(Q + beta);
370 c = Polylib::gammaFracGammaF(Q, alpha, Q, beta) / a - 1.;
371 BOOST_CHECK_SMALL(c, EPS);
372 }
373 }
374}
#define EPS
Tolerance to be used for floating point comparisons.
Definition: TestPolylib.cpp:54
@ beta
Gauss Radau pinned at x=-1,.
Definition: PointsType.h:61
double gammaF(const double x)
Calculate the Gamma function , , for integer values and halves.
Definition: Polylib.cpp:1347
double gammaFracGammaF(const int x, const double alpha, const int y, const double beta)
Calculate fraction of two Gamma functions, , for integer values and halves.
Definition: Polylib.cpp:1396

References Nektar::LibUtilities::beta, EPS, Polylib::gammaF(), Polylib::gammaFracGammaF(), and test().

◆ BOOST_AUTO_TEST_CASE() [2/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussDiff  )

Definition at line 266 of file TestPolylib.cpp.

267{
269}
void TestDifferentiation(std::function< void(double *, double *, int, double, double)> func, std::function< void(double *, double *, int, double, double)> funcD)
Test derivatives using Gaussian quadrature.
void Dgj(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Jacobi zeros.
Definition: Polylib.cpp:647
void zwgj(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Jacobi zeros and weights.
Definition: Polylib.cpp:154

References Polylib::Dgj(), TestDifferentiation(), and Polylib::zwgj().

◆ BOOST_AUTO_TEST_CASE() [3/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussInt  )

Definition at line 246 of file TestPolylib.cpp.

247{
249}
void TestIntegral(std::function< void(double *, double *, int, double, double)> func, int o)
Test integrals of Jacobi polynomials.
Definition: TestPolylib.cpp:83

References TestIntegral(), and Polylib::zwgj().

◆ BOOST_AUTO_TEST_CASE() [4/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussInterp  )

Definition at line 286 of file TestPolylib.cpp.

287{
289}
void TestInterpolation(std::function< void(double *, double *, int, double, double)> func, std::function< void(double *, double *, double *, int, int, double, double)> funcI)
Evaluate interpolation using Gaussian quadrature.
void Imgj(double *im, const double *zgj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Jacobi points to an arbitrary distribution at points zm.
Definition: Polylib.cpp:1012

References Polylib::Imgj(), TestInterpolation(), and Polylib::zwgj().

◆ BOOST_AUTO_TEST_CASE() [5/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussIntMatrix  )

Definition at line 306 of file TestPolylib.cpp.

307{
309}
void TestIntegralMatrix(std::function< void(double *, double *, int, double, double)> func, std::function< void(double *, double *, int)> funcQ)
void Qg(double *Q, const double *z, const int np)
Compute the Integration Matrix.
Definition: Polylib.cpp:605

References Polylib::Qg(), TestIntegralMatrix(), and Polylib::zwgj().

◆ BOOST_AUTO_TEST_CASE() [6/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussLobatto  )

Definition at line 261 of file TestPolylib.cpp.

262{
264}
void zwglj(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Lobatto-Jacobi zeros and weights with end point at z=-1,1.
Definition: Polylib.cpp:262

References TestIntegral(), and Polylib::zwglj().

◆ BOOST_AUTO_TEST_CASE() [7/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussLobattoDiff  )

Definition at line 281 of file TestPolylib.cpp.

282{
284}
void Dglj(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix associated with the Gauss-Lobatto-Jacobi zeros.
Definition: Polylib.cpp:807

References Polylib::Dglj(), TestDifferentiation(), and Polylib::zwglj().

◆ BOOST_AUTO_TEST_CASE() [8/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussLobattoInterp  )

Definition at line 301 of file TestPolylib.cpp.

302{
304}
void Imglj(double *im, const double *zglj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Lobatto-Jacobi points to an arbitrary distrubtion at points zm.
Definition: Polylib.cpp:1105

References Polylib::Imglj(), TestInterpolation(), and Polylib::zwglj().

◆ BOOST_AUTO_TEST_CASE() [9/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussLobattoIntMatrix  )

◆ BOOST_AUTO_TEST_CASE() [10/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauM  )

Definition at line 251 of file TestPolylib.cpp.

252{
254}
void zwgrjm(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=-1.
Definition: Polylib.cpp:182

References TestIntegral(), and Polylib::zwgrjm().

◆ BOOST_AUTO_TEST_CASE() [11/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauMDiff  )

Definition at line 271 of file TestPolylib.cpp.

272{
274}
void Dgrjm(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix and its transpose associated with the Gauss-Radau-Jacobi zeros with a z...
Definition: Polylib.cpp:694

References Polylib::Dgrjm(), TestDifferentiation(), and Polylib::zwgrjm().

◆ BOOST_AUTO_TEST_CASE() [12/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauMInterp  )

Definition at line 291 of file TestPolylib.cpp.

292{
294}
void Imgrjm(double *im, const double *zgrj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=-1) to an arbitrary distrubtion at...
Definition: Polylib.cpp:1043

References Polylib::Imgrjm(), TestInterpolation(), and Polylib::zwgrjm().

◆ BOOST_AUTO_TEST_CASE() [13/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauMIntMatrix  )

◆ BOOST_AUTO_TEST_CASE() [14/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauP  )

Definition at line 256 of file TestPolylib.cpp.

257{
259}
void zwgrjp(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Radau-Jacobi zeros and weights with end point at z=1.
Definition: Polylib.cpp:223

References TestIntegral(), and Polylib::zwgrjp().

◆ BOOST_AUTO_TEST_CASE() [15/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauPDiff  )

Definition at line 276 of file TestPolylib.cpp.

277{
279}
void Dgrjp(double *D, const double *z, const int np, const double alpha, const double beta)
Compute the Derivative Matrix associated with the Gauss-Radau-Jacobi zeros with a zero at z=1.
Definition: Polylib.cpp:750

References Polylib::Dgrjp(), TestDifferentiation(), and Polylib::zwgrjp().

◆ BOOST_AUTO_TEST_CASE() [16/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauPInterp  )

Definition at line 296 of file TestPolylib.cpp.

297{
299}
void Imgrjp(double *im, const double *zgrj, const double *zm, const int nz, const int mz, const double alpha, const double beta)
Interpolation Operator from Gauss-Radau-Jacobi points (including z=1) to an arbitrary distrubtion at ...
Definition: Polylib.cpp:1074

References Polylib::Imgrjp(), TestInterpolation(), and Polylib::zwgrjp().

◆ BOOST_AUTO_TEST_CASE() [17/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauPIntMatrix  )

◆ BOOST_AUTO_TEST_CASE() [18/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestMatrixVectorMultiply  )

Definition at line 191 of file testNekVector.cpp.

192{
193 {
194 // double matrix_buf[] = {1.0, 2.0, 3.0,
195 // 4.0, 5.0, 6.0,
196 // 7.0, 8.0, 9.0};
197 double matrix_buf[] = {1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0};
198 double vector_buf[] = {20.0, 30.0, 40.0};
199
200 NekMatrix<double> m(3, 3, matrix_buf);
201 NekVector<double> v(3, vector_buf);
202 NekVector<double> result = m * v;
203
204 double result_buf[] = {200.0, 470.0, 740.0};
205 NekVector<double> expected_result(3, result_buf);
206 BOOST_CHECK_EQUAL(result, expected_result);
207 BOOST_CHECK_EQUAL(3u, result.GetDimension());
208 }
209
210 {
211 // double matrix_buf[] = {1.0, 2.0, 3.0,
212 // 4.0, 5.0, 6.0,
213 // 7.0, 8.0, 9.0};
214 double matrix_buf[] = {1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0};
215 double vector_buf[] = {20.0, 30.0, 40.0};
216
217 std::shared_ptr<NekMatrix<double>> m(
218 new NekMatrix<double>(3, 3, matrix_buf));
219 NekMatrix<NekMatrix<double>, ScaledMatrixTag> s(2.0, m);
220 NekVector<double> v(3, vector_buf);
221 NekVector<double> result = s * v;
222
223 double result_buf[] = {400.0, 940.0, 1480.0};
224 NekVector<double> expected_result(3, result_buf);
225 BOOST_CHECK_EQUAL(result, expected_result);
226 BOOST_CHECK_EQUAL(3u, result.GetDimension());
227 }
228
229 {
230 // double m1_buf[] = {1.0, 2.0, 3.0, 4.0};
231 // double m2_buf[] = {5.0, 6.0, 7.0, 8.0};
232 // double m3_buf[] = {9.0, 10.0, 11.0, 12.0};
233 double m1_buf[] = {1.0, 3.0, 2.0, 4.0};
234 double m2_buf[] = {5.0, 7.0, 6.0, 8.0};
235 double m3_buf[] = {9.0, 11.0, 10.0, 12.0};
236 double vector_buf[] = {20.0, 30.0};
237
238 std::shared_ptr<NekMatrix<double>> m1(
239 new NekMatrix<double>(2, 2, m1_buf));
240 std::shared_ptr<NekMatrix<double>> m2(
241 new NekMatrix<double>(2, 2, m2_buf));
242 std::shared_ptr<NekMatrix<double>> m3(
243 new NekMatrix<double>(2, 2, m3_buf));
244
245 NekMatrix<NekMatrix<double>, BlockMatrixTag> b(3, 1, 2, 2);
246 b.SetBlock(0, 0, m1);
247 b.SetBlock(1, 0, m2);
248 b.SetBlock(2, 0, m3);
249
250 NekVector<double> v(2, vector_buf);
251 NekVector<double> result = b * v;
252
253 double result_buf[] = {80.0, 180.0, 280.0, 380.0, 480.0, 580.0};
254 NekVector<double> expected_result(6, result_buf);
255 BOOST_CHECK_EQUAL(result, expected_result);
256 BOOST_CHECK_EQUAL(6u, result.GetDimension());
257 }
258
259 {
260 double m_buf[] = {1, 4, 7, 2, 5, 8, 3, 6, 9};
261 double v_buf[] = {10, 11, 12};
262 double expected_result_buf[] = {68, 167, 266};
263 double expected_transpose_result_buf[] = {138, 171, 204};
264
265 NekMatrix<double> m(3, 3, m_buf);
266 NekVector<double> v_variable(3, v_buf);
267 NekVector<double> v_constant(3, v_buf);
268 NekVector<double> expected_result(3, expected_result_buf);
269 NekVector<double> expected_transpose_result(
270 3, expected_transpose_result_buf);
271
272 NekVector<double> constantResult = m * v_constant;
273 NekVector<double> variableResult = m * v_variable;
274 BOOST_CHECK_EQUAL(variableResult, expected_result);
275 BOOST_CHECK_EQUAL(constantResult, expected_result);
276
277 m.Transpose();
278 constantResult = m * v_constant;
279 variableResult = m * v_variable;
280 BOOST_CHECK_EQUAL(variableResult, expected_transpose_result);
281 BOOST_CHECK_EQUAL(constantResult, expected_transpose_result);
282
283 m.Transpose();
284 constantResult = m * v_constant;
285 variableResult = m * v_variable;
286 BOOST_CHECK_EQUAL(variableResult, expected_result);
287 BOOST_CHECK_EQUAL(constantResult, expected_result);
288
289 NekMatrix<double> transposed = Transpose(m);
290 constantResult = transposed * v_constant;
291 variableResult = transposed * v_variable;
292 BOOST_CHECK_EQUAL(variableResult, expected_transpose_result);
293 BOOST_CHECK_EQUAL(constantResult, expected_transpose_result);
294 }
295
296 {
297 double m_buf[] = {1, 4, 2, 5, 3, 6};
298 double v_non_transposed_buf[] = {10, 11, 12};
299 double v_transposed_buf[] = {20, 21};
300 double expected_result_buf[] = {68, 167};
301 double expected_transpose_result_buf[] = {104, 145, 186};
302
303 NekMatrix<double> m(2, 3, m_buf);
304 NekVector<double> v_non_transposed_variable(3, v_non_transposed_buf);
305 NekVector<double> v_non_transposed_constant(3, v_non_transposed_buf);
306 NekVector<double> v_transposed_variable(2, v_transposed_buf);
307 NekVector<double> v_transposed_constant(2, v_transposed_buf);
308 NekVector<double> expected_result(2, expected_result_buf);
309 NekVector<double> expected_transpose_result(
310 3, expected_transpose_result_buf);
311
312 NekVector<double> variableResult = m * v_non_transposed_variable;
313 NekVector<double> constantResult = m * v_non_transposed_constant;
314 BOOST_CHECK_EQUAL(variableResult, expected_result);
315 BOOST_CHECK_EQUAL(constantResult, expected_result);
316
317 m.Transpose();
318 variableResult = m * v_transposed_variable;
319 constantResult = m * v_transposed_constant;
320 BOOST_CHECK_EQUAL(variableResult, expected_transpose_result);
321 BOOST_CHECK_EQUAL(constantResult, expected_transpose_result);
322
323 m.Transpose();
324 variableResult = m * v_non_transposed_variable;
325 constantResult = m * v_non_transposed_constant;
326 BOOST_CHECK_EQUAL(variableResult, expected_result);
327 BOOST_CHECK_EQUAL(constantResult, expected_result);
328
329 NekMatrix<double> transposed = Transpose(m);
330 variableResult = transposed * v_transposed_variable;
331 constantResult = transposed * v_transposed_constant;
332 BOOST_CHECK_EQUAL(variableResult, expected_transpose_result);
333 BOOST_CHECK_EQUAL(constantResult, expected_transpose_result);
334 }
335}
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)

References Nektar::NekVector< DataType >::GetDimension(), and Nektar::Transpose().

◆ BOOST_AUTO_TEST_CASE() [19/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( testNekMatrixBasicMath  )

Definition at line 429 of file testNekMatrix.cpp.

430{
431 // Addition tests.
432 {
433 double buf[] = {1.0, 4.0, 7.0, 2.0, 5.0, 8.0, 3.0, 6.0, 9.0};
434 NekMatrix<double> m1(3, 3, buf);
435 NekMatrix<double> m2(3, 3, buf);
436 NekMatrix<double> m3 = m1 + m2;
437
438 for (unsigned int i = 0; i < 3; ++i)
439 {
440 for (unsigned int j = 0; j < 3; ++j)
441 {
442 BOOST_CHECK(m3(i, j) == buf[3 * j + i] + buf[3 * j + i]);
443 }
444 }
445
446 NekMatrix<double> m4(3, 3, buf);
447 NekMatrix<double> m5(3, 3, buf);
448 NekMatrix<double> m6 = m4 + m5;
449
450 for (unsigned int i = 0; i < 3; ++i)
451 {
452 for (unsigned int j = 0; j < 3; ++j)
453 {
454 BOOST_CHECK(m6(i, j) == buf[3 * j + i] + buf[3 * j + i]);
455 }
456 }
457 }
458 // Multiply
459
460 {
461 double buf1[] = {1, 4, 7, 2, 5, 8, 3, 6, 9};
462 double buf2[] = {10, 15, 19, 11, 16, 20, 12, 17, 21};
463 NekMatrix<double> lhs(3, 3, buf1);
464 NekMatrix<double> rhs(3, 3, buf2);
465
466 NekMatrix<double> result = lhs * rhs;
467
468 BOOST_CHECK(result.GetRows() == 3);
469 BOOST_CHECK(result.GetColumns() == 3);
470
471 double epsilon = 1e-12;
472 BOOST_CHECK_CLOSE(*result(0, 0), 97.0, epsilon);
473 BOOST_CHECK_CLOSE(*result(0, 1), 103.0, epsilon);
474 BOOST_CHECK_CLOSE(*result(0, 2), 109.0, epsilon);
475
476 BOOST_CHECK_CLOSE(*result(1, 0), 229.0, epsilon);
477 BOOST_CHECK_CLOSE(*result(1, 1), 244.0, epsilon);
478 BOOST_CHECK_CLOSE(*result(1, 2), 259.0, epsilon);
479
480 BOOST_CHECK_CLOSE(*result(2, 0), 361.0, epsilon);
481 BOOST_CHECK_CLOSE(*result(2, 1), 385.0, epsilon);
482 BOOST_CHECK_CLOSE(*result(2, 2), 409.0, epsilon);
483 }
484
485 {
486 double buf1[] = {1, 4, 7, 2, 5, 8, 3, 6, 9};
487 double buf2[] = {10, 15, 19, 11, 16, 20, 12, 17, 21, 14, 18, 22};
488 NekMatrix<double> lhs(3, 3, buf1);
489 NekMatrix<double> rhs(3, 4, buf2);
490
491 NekMatrix<double> result = lhs * rhs;
492
493 BOOST_CHECK(result.GetRows() == 3);
494 BOOST_CHECK(result.GetColumns() == 4);
495
496 double epsilon = 1e-12;
497 BOOST_CHECK_CLOSE(*result(0, 0), 97.0, epsilon);
498 BOOST_CHECK_CLOSE(*result(0, 1), 103.0, epsilon);
499 BOOST_CHECK_CLOSE(*result(0, 2), 109.0, epsilon);
500 BOOST_CHECK_CLOSE(*result(0, 3), 116.0, epsilon);
501
502 BOOST_CHECK_CLOSE(*result(1, 0), 229.0, epsilon);
503 BOOST_CHECK_CLOSE(*result(1, 1), 244.0, epsilon);
504 BOOST_CHECK_CLOSE(*result(1, 2), 259.0, epsilon);
505 BOOST_CHECK_CLOSE(*result(1, 3), 278.0, epsilon);
506
507 BOOST_CHECK_CLOSE(*result(2, 0), 361.0, epsilon);
508 BOOST_CHECK_CLOSE(*result(2, 1), 385.0, epsilon);
509 BOOST_CHECK_CLOSE(*result(2, 2), 409.0, epsilon);
510 BOOST_CHECK_CLOSE(*result(2, 3), 440.0, epsilon);
511 }
512
513 //
514 // // Transpose
515 //
516 // // Determinant.
517 //
518 // // Invert/Check for singularity.
519 //
520 // // Eigenvalues/vectors
521 //
522 // // Condition number wrt various norms.
523 //
524 // // Various norm computations.
525 //
526 // // LU Decomposition? More appropriate in LinAlg?
527}

◆ BOOST_AUTO_TEST_CASE() [20/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( testNekMatrixConstruction  )

Definition at line 408 of file testNekMatrix.cpp.

409{
410 // Basic, dense matrix construction.
411 {
412 double buf[] = {1.0, 4.0, 7.0, 10.0, 2.0, 5.0,
413 8.0, 11.0, 3.0, 6.0, 9.0, 12.0};
414 NekMatrix<double> dynamic_matrix(4, 3, buf);
415
416 BOOST_CHECK(dynamic_matrix.GetRows() == 4);
417 BOOST_CHECK(dynamic_matrix.GetColumns() == 3);
418
419 for (unsigned int i = 0; i < 4; ++i)
420 {
421 for (unsigned int j = 0; j < 3; ++j)
422 {
423 BOOST_CHECK(dynamic_matrix(i, j) == buf[4 * j + i]);
424 }
425 }
426 }
427}

◆ BOOST_AUTO_TEST_CASE() [21/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( testNekPointConstruction  )

Definition at line 105 of file testNekPoint.cpp.

106{
107 using namespace Nektar;
108
109 // Test the constructors on a numeric type.
110 {
112 BOOST_CHECK(p1.x() == 0.0);
113 BOOST_CHECK(p1.y() == 0.0);
114 BOOST_CHECK(p1.z() == 0.0);
115
116 NekPoint<double> p3(p1);
117 BOOST_CHECK(p1 == p3);
118 }
119
120 // Now test it on an arbitrary type.
121 {
123 BOOST_CHECK(p1.x() == PointTestClass(0));
124 BOOST_CHECK(p1.y() == PointTestClass(0));
125 BOOST_CHECK(p1.z() == PointTestClass(0));
126
127 BOOST_CHECK(p1.x() == PointTestClass());
128 BOOST_CHECK(p1.y() == PointTestClass());
129 BOOST_CHECK(p1.z() == PointTestClass());
130
132 BOOST_CHECK(p1 == p3);
133 }
134}
boost::call_traits< DataType >::const_reference x() const
Definition: NekPoint.hpp:160
boost::call_traits< DataType >::const_reference z() const
Definition: NekPoint.hpp:172
boost::call_traits< DataType >::const_reference y() const
Definition: NekPoint.hpp:166
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2

References Nektar::NekPoint< data_type >::x(), Nektar::NekPoint< data_type >::y(), and Nektar::NekPoint< data_type >::z().

◆ BOOST_AUTO_TEST_CASE() [22/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestNekVectorArithmetic  )

Definition at line 176 of file testNekVector.cpp.

177{
178}

◆ BOOST_AUTO_TEST_CASE() [23/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestNekVectorConstruction  )

Definition at line 96 of file testNekVector.cpp.

97{
98 // Test the constructors on a numeric type.
99 {
100 NekVector<double> p1(10, 2.7);
101 BOOST_CHECK(p1.GetDimension() == 10);
102 for (unsigned int i = 0; i < p1.GetDimension(); ++i)
103 {
104 BOOST_CHECK(p1(i) == 2.7);
105 BOOST_CHECK(p1[i] == 2.7);
106 }
107
108 NekVector<double> p2(1, 0.0);
109 BOOST_CHECK(p2.GetDimension() == 1);
110 BOOST_CHECK(p2(0) == 0.0);
111
112 NekVector<double> p3(p1);
113 BOOST_CHECK(p3.GetDimension() == 10);
114 for (unsigned int i = 0; i < p3.GetDimension(); ++i)
115 {
116 BOOST_CHECK(p3(i) == 2.7);
117 BOOST_CHECK(p3[i] == 2.7);
118 }
119
120 p2 = p3;
121 BOOST_CHECK(p2.GetDimension() == 10);
122 for (unsigned int i = 0; i < p2.GetDimension(); ++i)
123 {
124 BOOST_CHECK_EQUAL(p2(i), 2.7);
125 BOOST_CHECK_EQUAL(p2[i], 2.7);
126 }
127 }
128}

References Nektar::NekVector< DataType >::GetDimension().

◆ BOOST_AUTO_TEST_CASE() [24/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestNekVectorOperators  )

Definition at line 130 of file testNekVector.cpp.

131{
132 NekVector<double> v1(3, 1.0);
133 v1(0) = 1.1;
134 v1(1) = 1.2;
135 v1(2) = 1.3;
136
137 BOOST_CHECK(v1(0) == 1.1);
138 BOOST_CHECK(v1(1) == 1.2);
139 BOOST_CHECK(v1(2) == 1.3);
140
141 v1[0] = 1.4;
142 v1[1] = 1.5;
143 v1[2] = 1.6;
144
145 BOOST_CHECK(v1[0] == 1.4);
146 BOOST_CHECK(v1[1] == 1.5);
147 BOOST_CHECK(v1[2] == 1.6);
148
149 v1.x() = 1.7;
150 v1.y() = 1.8;
151 v1.z() = 1.9;
152
153 BOOST_CHECK(v1[0] == 1.7);
154 BOOST_CHECK(v1[1] == 1.8);
155 BOOST_CHECK(v1[2] == 1.9);
156
157 BOOST_CHECK(v1.x() == 1.7);
158 BOOST_CHECK(v1.y() == 1.8);
159 BOOST_CHECK(v1.z() == 1.9);
160
161 NekVector<double> v2(3, 1.0);
162 v2.x() = 1.7;
163 v2.y() = 1.8;
164 v2.z() = 1.9;
165
166 BOOST_CHECK(v1 == v2);
167 BOOST_CHECK(!(v1 != v2));
168
169 NekVector<double> v3(4, 2.0);
170 BOOST_CHECK(v3 != v1);
171
172 NekVector<double> v4(3, 0.0);
173 BOOST_CHECK(v4 != v1);
174}

References Nektar::NekVector< DataType >::x(), Nektar::NekVector< DataType >::y(), and Nektar::NekVector< DataType >::z().

◆ BOOST_AUTO_TEST_CASE() [25/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestNorms  )

Definition at line 180 of file testNekVector.cpp.

181{
182 double vals[] = {1, -2, 3};
183 NekVector<double> v(3, vals);
184
185 double epsilon = 1e-11;
186 BOOST_CHECK_EQUAL(v.L1Norm(), 1.0 + 2.0 + 3.0);
187 BOOST_CHECK_CLOSE(v.L2Norm(), sqrt(1.0 + 4.0 + 9.0), epsilon);
188 BOOST_CHECK_EQUAL(v.InfinityNorm(), 3);
189}
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294

References Nektar::NekVector< DataType >::InfinityNorm(), Nektar::NekVector< DataType >::L1Norm(), Nektar::NekVector< DataType >::L2Norm(), and tinysimd::sqrt().

◆ BOOST_AUTO_TEST_CASE() [26/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestVectorConstructorsWithSizeArguments  )

Definition at line 337 of file testNekVector.cpp.

338{
339 {
340 double buf[] = {1.0, 2.0, 3.0, 4.0};
341 Array<OneD, double> a(4, buf);
342 NekVector<double> b(3, a);
343
344 BOOST_CHECK_EQUAL(b.GetRows(), 3u);
345 BOOST_CHECK_EQUAL(b.GetDimension(), 3u);
346 BOOST_CHECK_EQUAL(b[0], 1.0);
347 BOOST_CHECK_EQUAL(b[1], 2.0);
348 BOOST_CHECK_EQUAL(b[2], 3.0);
349
350 NekVector<double>::iterator iter = b.begin();
351 BOOST_CHECK_EQUAL(*iter, 1.0);
352 ++iter;
353 BOOST_CHECK_EQUAL(*iter, 2.0);
354 ++iter;
355 BOOST_CHECK_EQUAL(*iter, 3.0);
356 ++iter;
357 BOOST_CHECK(iter == b.end());
358 }
359
360 {
361 double buf[] = {1.0, 2.0, 3.0, 4.0};
362 Array<OneD, const double> a(4, buf);
363 NekVector<double> b(3, a);
364
365 BOOST_CHECK_EQUAL(b.GetRows(), 3u);
366 BOOST_CHECK_EQUAL(b.GetDimension(), 3u);
367 BOOST_CHECK_EQUAL(b[0], 1.0);
368 BOOST_CHECK_EQUAL(b[1], 2.0);
369 BOOST_CHECK_EQUAL(b[2], 3.0);
370
371 NekVector<double>::iterator iter = b.begin();
372 BOOST_CHECK_EQUAL(*iter, 1.0);
373 ++iter;
374 BOOST_CHECK_EQUAL(*iter, 2.0);
375 ++iter;
376 BOOST_CHECK_EQUAL(*iter, 3.0);
377 ++iter;
378 BOOST_CHECK(iter == b.end());
379 }
380
381 {
382 double buf[] = {1.0, 2.0, 3.0, 4.0};
383 Array<OneD, double> a(4, buf);
384 NekVector<double> b(3, a, eWrapper);
385
386 BOOST_CHECK_EQUAL(b.GetRows(), 3u);
387 BOOST_CHECK_EQUAL(b.GetDimension(), 3u);
388 BOOST_CHECK_EQUAL(b[0], 1.0);
389 BOOST_CHECK_EQUAL(b[1], 2.0);
390 BOOST_CHECK_EQUAL(b[2], 3.0);
391
392 NekVector<double>::iterator iter = b.begin();
393 BOOST_CHECK_EQUAL(*iter, 1.0);
394 ++iter;
395 BOOST_CHECK_EQUAL(*iter, 2.0);
396 ++iter;
397 BOOST_CHECK_EQUAL(*iter, 3.0);
398 ++iter;
399 BOOST_CHECK(iter == b.end());
400
401 b[0] = 5.0;
402 BOOST_CHECK_EQUAL(b[0], a[0]);
403 }
404}
iterator begin()
Definition: NekVector.cpp:235
DataType * iterator
Definition: NekVector.hpp:109

References Nektar::NekVector< DataType >::begin(), Nektar::NekVector< DataType >::end(), Nektar::eWrapper, Nektar::NekVector< DataType >::GetDimension(), and Nektar::NekVector< DataType >::GetRows().

◆ d()

std::vector< double > Nektar::UnitTests::d ( NPUPPER NPUPPER)

Referenced by CellMLToNektar.translators.ConfigurationStore::_find_transmembrane_currents_from_voltage_ode(), Nektar::SpatialDomains::GeomFactors::Adjoint(), Nektar::MemoryManager< DataType >::AllocateSharedPtrD(), Nektar::AsString(), Nektar::ScaledMatrixUnitTests::BOOST_AUTO_TEST_CASE(), Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE(), Nektar::SolverUtils::DiffusionIP::CalcTraceNumFlux(), Nektar::GlobalMapping::MappingGeneral::CalculateMetricTerms(), Nektar::SharedArrayUnitTests::CheckAddresses(), Nektar::Collections::Helmholtz_IterPerExp::CheckFactors(), Nektar::MultiRegions::ExpList::CreateCollections(), Nektar::SpatialDomains::MeshGraphXml::CreateCompositeOrdering(), Nektar::FieldUtils::Field::CreateExp(), Nektar::MMFDiffusion::DoOdeRhs(), Arpack::Dseupd(), Lapack::Dsterf(), Nektar::SolverUtils::DriverSteadyState::EvalEV_ScalarSFD(), EvaluateTangent(), Nektar::LibUtilities::Interpolator::FindNeighbours(), Nektar::LibUtilities::Interpolator::FindNNeighbours(), Nektar::FullMatrixOperationsUnitTests::foo(), Nektar::PulseWaveSystem::GetCommArray(), Nektar::NavierStokesCFE::GetDivCurlSquared(), Nektar::SpatialDomains::MeshGraph::GetElementsFromEdge(), Nektar::LibUtilities::FieldIO::GetFileType(), Nektar::CompressibleFlowSystem::GetFluxVector(), Nektar::VariableConverter::GetInternalEnergy(), Nektar::NavierStokesCFE::GetViscousFluxBilinearFormKernel(), Nektar::NavierStokesCFE::GetViscousFluxVectorConservVar(), Nektar::NavierStokesCFE::GetViscousSymmtrFluxConservVar(), Nektar::NonlinearPeregrine::LaitoneSolitaryWave(), main(), Nektar::NekMatrix< DataType, StandardMatrixTag >::NekMatrix(), Nektar::FieldUtils::OutputVtk::OutputFromExpLowOrder(), Nektar::FieldUtils::OutputVtk::OutputFromExpLowOrderMultiBlock(), Nektar::FieldUtils::ProcessGrad::ParserOptions(), Polylib::polycoeffs(), PolyFit(), PolyInterp(), Nektar::SpatialDomains::MeshGraph::ReadExpansionInfo(), Nektar::PulseWaveSystem::SetUpDomainInterfaceBCs(), Nektar::PulseWaveSystem::SetUpDomainInterfaces(), Nektar::SpatialDomains::MeshGraph::SetUpExpansionInfoMap(), Nektar::Matrix< DataType >::SetValue(), Nektar::NekMatrix< DataType, StandardMatrixTag >::SetValue(), boost::python::converter::shared_ptr_to_python(), Nektar::LocalRegions::Expansion::StdDerivBaseOnTraceMat(), TestDifferentiation(), TestInterpolation(), Polylib::TriQL(), Nektar::LibUtilities::NodalTetElec::v_CalculatePoints(), Nektar::SpatialDomains::RefRegionCylinder::v_Contains(), Nektar::SpatialDomains::RefRegionParallelogram::v_Contains(), Nektar::PulseWaveSystem::v_DoInitialise(), Nektar::SpatialDomains::HexGeom::v_GenGeomFactors(), Nektar::SpatialDomains::PrismGeom::v_GenGeomFactors(), Nektar::SpatialDomains::QuadGeom::v_GenGeomFactors(), Nektar::SpatialDomains::TriGeom::v_GenGeomFactors(), Nektar::LocalRegions::Expansion2D::v_GenMatrix(), Nektar::LocalRegions::Expansion3D::v_GenMatrix(), Nektar::LibUtilities::NodalTriElec::v_GetI(), Nektar::LibUtilities::NodalTriEvenlySpaced::v_GetI(), Nektar::LibUtilities::NodalTriFekete::v_GetI(), Nektar::LibUtilities::NodalPrismElec::v_GetI(), Nektar::LibUtilities::NodalPrismEvenlySpaced::v_GetI(), Nektar::LibUtilities::NodalTetElec::v_GetI(), Nektar::LibUtilities::NodalTetEvenlySpaced::v_GetI(), Nektar::LibUtilities::PolyEPoints::v_GetI(), Nektar::PulseWaveSystem::v_InitObject(), Nektar::FieldUtils::InputFld::v_Process(), Nektar::FieldUtils::ProcessCreateExp::v_Process(), and Nektar::NekMatrix< DataType, StandardMatrixTag >::v_SetValue().

◆ ddot()

double Nektar::UnitTests::ddot ( int  n,
double *  x,
int  incx,
double *  y,
int  incy 
)

Dot product two vectors.

Definition at line 57 of file TestPolylib.cpp.

58{
59 double sum = 0.0;
60
61 while (n--)
62 {
63 sum += (*x) * (*y);
64 x += incx;
65 y += incy;
66 }
67
68 return sum;
69}

Referenced by TestDifferentiation(), TestIntegral(), TestIntegralMatrix(), and TestInterpolation().

◆ operator!=() [1/2]

bool Nektar::UnitTests::operator!= ( const PointTestClass lhs,
const PointTestClass rhs 
)

Definition at line 78 of file testNekPoint.cpp.

79{
80 return !(lhs == rhs);
81}

◆ operator!=() [2/2]

bool Nektar::UnitTests::operator!= ( const VectorTestClass lhs,
const VectorTestClass rhs 
)

Definition at line 86 of file testNekVector.cpp.

87{
88 return !(lhs == rhs);
89}

◆ operator==() [1/2]

bool Nektar::UnitTests::operator== ( const PointTestClass lhs,
const PointTestClass rhs 
)

Definition at line 73 of file testNekPoint.cpp.

74{
75 return lhs.value() == rhs.value();
76}

References Nektar::UnitTests::PointTestClass::value().

◆ operator==() [2/2]

bool Nektar::UnitTests::operator== ( const VectorTestClass lhs,
const VectorTestClass rhs 
)

Definition at line 81 of file testNekVector.cpp.

82{
83 return lhs.value() == rhs.value();
84}

References Nektar::UnitTests::VectorTestClass::value().

◆ p()

std::vector< double > Nektar::UnitTests::p ( NPUPPER  )

◆ q()

std::vector< double > Nektar::UnitTests::q ( NPUPPER NPUPPER)

Referenced by Nektar::LibUtilities::FractionalInTimeIntegrationScheme::advanceSandbox(), Nektar::MultiRegions::AssemblyMapCG::AssemblyMapCG(), Nektar::NekLinAlgTests::BOOST_AUTO_TEST_CASE(), Nektar::FieldUtils::ProcessInterpPoints::calcCp0(), Nektar::FieldUtils::ProcessInterpPtsToPts::calcCp0(), Polylib::chri1(), EvaluateTangent(), Nektar::LibUtilities::Basis::GenBasis(), Nektar::Collections::CoalescedGeomData::GetDerivFactorsInterLeave(), Nektar::Collections::CoalescedGeomData::GetJacInterLeave(), Nektar::StdRegions::StdPrismExp::GetMode(), Nektar::GramSchmidtOrthogonalization(), Nektar::LibUtilities::FractionalInTimeIntegrationScheme::integralClassInitialize(), Nektar::LibUtilities::FractionalInTimeIntegrationScheme::integralContribution(), main(), MappingEVids(), Nektar::FieldUtils::MatSymEVals(), Nektar::LibUtilities::SessionReader::MergeDoc(), Nektar::LibUtilities::FractionalInTimeIntegrationScheme::talbotQuadrature(), TestIntegralMatrix(), Nektar::LibUtilities::FractionalInTimeIntegrationScheme::timeAdvance(), Nektar::LibUtilities::FractionalInTimeIntegrationScheme::updateStage(), Nektar::StdRegions::StdHexExp::v_GetBoundaryMap(), Nektar::StdRegions::StdPrismExp::v_GetBoundaryMap(), Nektar::StdRegions::StdPyrExp::v_GetBoundaryMap(), Nektar::StdRegions::StdHexExp::v_GetEdgeInteriorToElementMap(), Nektar::StdRegions::StdHexExp::v_GetInteriorMap(), Nektar::StdRegions::StdPrismExp::v_GetInteriorMap(), Nektar::StdRegions::StdPyrExp::v_GetInteriorMap(), Nektar::StdRegions::StdPrismExp::v_GetTraceCoeffMap(), Nektar::StdRegions::StdPyrExp::v_GetTraceCoeffMap(), Nektar::StdRegions::StdHexExp::v_GetTraceInteriorToElementMap(), Nektar::StdRegions::StdPrismExp::v_GetTraceInteriorToElementMap(), Nektar::StdRegions::StdPyrExp::v_GetTraceInteriorToElementMap(), Nektar::StdRegions::StdHexExp::v_GetVertexMap(), Nektar::FieldUtils::ProcessQualityMetric::v_Process(), Nektar::SpatialDomains::MeshGraphXml::v_WriteQuads(), and Nektar::SpatialDomains::MeshGraphXmlCompressed::v_WriteQuads().

◆ RedirectCerrIfNeeded()

void Nektar::UnitTests::RedirectCerrIfNeeded ( )

◆ test()

void Nektar::UnitTests::test ( )

◆ TestDifferentiation()

void Nektar::UnitTests::TestDifferentiation ( std::function< void(double *, double *, int, double, double)>  func,
std::function< void(double *, double *, int, double, double)>  funcD 
)
inline

Test derivatives using Gaussian quadrature.

This routine evaluates the deriatives

\[ \frac{d}{dx}(x^n) = nx^{n-1} \]

using \( -0.5 \leq \alpha,\beta \leq 5 \) and using \( N \) points where \( N \) lies between NPLOWER and NPUPPER. Tolerance is taken using the EPS value.

Definition at line 118 of file TestPolylib.cpp.

121{
122 double alpha = -0.5;
123 while (alpha <= 5.0)
124 {
125 double beta = -0.5;
126 while (beta <= 5.0)
127 {
128 for (int np = NPLOWER; np <= NPUPPER; ++np)
129 {
130 func(&z[0], &w[0], np, alpha, beta);
131 funcD(&d[0], &z[0], np, alpha, beta);
132 for (int n = 2; n < np - 1; ++n)
133 {
134 for (int i = 0; i < np; ++i)
135 {
136 p[i] = pow(z[i], n);
137 }
138
139 double sum = 0.0;
140
141 for (int i = 0; i < np; ++i)
142 {
143 sum += fabs(ddot(np, &d[0] + i, np, &p[0], 1) -
144 n * pow(z[i], n - 1));
145 }
146 sum /= np;
147
148 BOOST_CHECK_SMALL(sum, EPS);
149 }
150 }
151 beta += 0.5;
152 }
153 alpha += 0.5;
154 }
155}
#define NPUPPER
Upper range of number of quadrature points to use for unit tests.
Definition: TestPolylib.cpp:52
#define NPLOWER
Lower range of number of quadrature points to use for unit tests.
Definition: TestPolylib.cpp:50
std::vector< double > w(NPUPPER)
std::vector< double > p(NPUPPER)
std::vector< double > z(NPUPPER)
std::vector< double > d(NPUPPER *NPUPPER)
double ddot(int n, double *x, int incx, double *y, int incy)
Dot product two vectors.
Definition: TestPolylib.cpp:57

References Nektar::LibUtilities::beta, d(), ddot(), EPS, NPLOWER, NPUPPER, p(), w(), and z().

Referenced by BOOST_AUTO_TEST_CASE().

◆ TestIntegral()

void Nektar::UnitTests::TestIntegral ( std::function< void(double *, double *, int, double, double)>  func,
int  o 
)
inline

Test integrals of Jacobi polynomials.

This routine evaluates the integral

\[ \int_{-1}^1 (1-x)^\alpha (1+x)^\beta P_n^{\alpha,\beta} dx = 0 \]

using \( -0.5 \leq \alpha,\beta \leq 5 \) and using \( N \) points where \( N \) lies between NPLOWER and NPUPPER. Tolerance is taken using the EPS value.

Definition at line 83 of file TestPolylib.cpp.

85{
86 double alpha = -0.5;
87 while (alpha <= 5.0)
88 {
89 double beta = -0.5;
90 while (beta <= 5.0)
91 {
92 for (int np = NPLOWER; np <= NPUPPER; ++np)
93 {
94 func(&z[0], &w[0], np, alpha, beta);
95 for (int n = 2; n < 2 * np - 1 - o; ++n)
96 {
97 Polylib::jacobfd(np, &z[0], &p[0], NULL, n, alpha, beta);
98 double sum = ddot(np, &w[0], 1, &p[0], 1);
99 BOOST_CHECK_SMALL(sum, EPS);
100 }
101 }
102
103 beta += 0.5;
104 }
105
106 alpha += 0.5;
107 }
108}
void jacobfd(const int np, const double *z, double *poly_in, double *polyd, const int n, const double alpha, const double beta)
Routine to calculate Jacobi polynomials, , and their first derivative, .
Definition: Polylib.cpp:1206

References Nektar::LibUtilities::beta, ddot(), EPS, Polylib::jacobfd(), NPLOWER, NPUPPER, p(), w(), and z().

Referenced by BOOST_AUTO_TEST_CASE().

◆ TestIntegralMatrix()

void Nektar::UnitTests::TestIntegralMatrix ( std::function< void(double *, double *, int, double, double)>  func,
std::function< void(double *, double *, int)>  funcQ 
)
inline

Definition at line 207 of file TestPolylib.cpp.

210{
211 double alpha = -0.5;
212 while (alpha <= 5.0)
213 {
214 double beta = -0.5;
215 while (beta <= 5.0)
216 {
217 for (int np = NPLOWER; np <= NPUPPER; ++np)
218 {
219 func(&z[0], &w[0], np, alpha, beta);
220 funcQ(&q[0], &z[0], np);
221 for (int n = 2; n < np - 1; ++n)
222 {
223 for (int i = 0; i < np; ++i)
224 {
225 p[i] = pow(z[i], n);
226 }
227
228 double sum = 0.0;
229
230 for (int i = 0; i < np; ++i)
231 {
232 sum += fabs(ddot(np, &q[0] + i * np, 1, &p[0], 1) -
233 pow(z[i], n + 1) / (n + 1));
234 }
235 sum /= np;
236
237 BOOST_CHECK_SMALL(sum, EPS);
238 }
239 }
240 beta += 0.5;
241 }
242 alpha += 0.5;
243 }
244}
std::vector< double > q(NPUPPER *NPUPPER)

References Nektar::LibUtilities::beta, ddot(), EPS, NPLOWER, NPUPPER, p(), q(), w(), and z().

Referenced by BOOST_AUTO_TEST_CASE().

◆ TestInterpolation()

void Nektar::UnitTests::TestInterpolation ( std::function< void(double *, double *, int, double, double)>  func,
std::function< void(double *, double *, double *, int, int, double, double)>  funcI 
)
inline

Evaluate interpolation using Gaussian quadrature.

This routine evaluates the interpolation of \( z^n \) to \( x^n \), where \( z \) are the quadrature zeros and \( x \) are the equispaced points

\[ x_n = \frac{2n}{N-1} - 1, \quad 0\leq n\leq N, \]

using \( -0.5 \leq \alpha,\beta \leq 5 \) and using \( N \) points where \( N \) lies between NPLOWER and NPUPPER. Tolerance is taken using the EPS value.

Definition at line 167 of file TestPolylib.cpp.

171{
172 double alpha = -0.5;
173 while (alpha <= 5.0)
174 {
175 double beta = -0.5;
176 while (beta <= 5.0)
177 {
178 for (int np = NPLOWER; np <= NPUPPER; ++np)
179 {
180 func(&z[0], &w[0], np, alpha, beta);
181 for (int n = 2; n < np - 1; ++n)
182 {
183 for (int i = 0; i < np; ++i)
184 {
185 w[i] = 2.0 * i / (double)(np - 1) - 1.0;
186 p[i] = pow(z[i], n);
187 }
188 funcI(&d[0], &z[0], &w[0], np, np, alpha, beta);
189
190 double sum = 0.0;
191 for (int i = 0; i < np; ++i)
192 {
193 sum += fabs(ddot(np, &d[0] + i, np, &p[0], 1) -
194 pow(w[i], n));
195 }
196 sum /= np;
197
198 BOOST_CHECK_SMALL(sum, EPS);
199 }
200 }
201 beta += 0.5;
202 }
203 alpha += 0.5;
204 }
205}

References Nektar::LibUtilities::beta, d(), ddot(), EPS, NPLOWER, NPUPPER, p(), w(), and z().

Referenced by BOOST_AUTO_TEST_CASE().

◆ w()

std::vector< double > Nektar::UnitTests::w ( NPUPPER  )

Referenced by Nektar::MultiRegions::GlobalLinSysDirectFull::AssembleFullMatrix(), Nektar::VmathSIMDUnitTests::BOOST_AUTO_TEST_CASE(), sha1::calc(), Nektar::SolverUtils::DriverParareal::CopyConvergedCheckPoints(), Cutrepetitions(), Vmath::Ddot(), Nektar::LibUtilities::NekLinSysIterGMRES::DoArnoldi(), Nektar::LibUtilities::NekLinSysIterGMRESLoc::DoArnoldi(), Vmath::Dot(), Vmath::Dot2(), Lapack::Dsbev(), Lapack::Dspev(), Nektar::MultiRegions::DisContField::FindPeriodicTraces(), Nektar::LibUtilities::Basis::GenBasis(), Nektar::NavierStokesImplicitCFE::GetdFlux_dQx_3D(), Nektar::NavierStokesImplicitCFE::GetdFlux_dQy_3D(), Nektar::NavierStokesImplicitCFE::GetdFlux_dQz_3D(), Nektar::NavierStokesImplicitCFE::GetdFlux_dU_3D(), Nektar::LibUtilities::Points< DataT >::GetZW(), Nektar::LibUtilities::Basis::GetZW(), main(), MappingEVids(), Orderfunctionx(), PolyFit(), PolyInterp(), Nektar::LibUtilities::H5::DataSet::Read(), Nektar::FieldUtils::Iso::Smooth(), Nektar::LibUtilities::FractionalInTimeIntegrationScheme::talbotQuadrature(), TestDifferentiation(), TestIntegral(), TestIntegralMatrix(), TestInterpolation(), Nektar::MultiRegions::GlobalLinSysDirectStaticCond::v_AssembleSchurComplement(), Nektar::LibUtilities::NodalPrismElec::v_CalculateWeights(), Nektar::LibUtilities::NodalPrismEvenlySpaced::v_CalculateWeights(), Nektar::LibUtilities::NodalTetElec::v_CalculateWeights(), Nektar::LibUtilities::NodalTetEvenlySpaced::v_CalculateWeights(), Nektar::LibUtilities::NodalTriElec::v_CalculateWeights(), Nektar::LibUtilities::NodalTriEvenlySpaced::v_CalculateWeights(), Nektar::LibUtilities::NodalTriFekete::v_CalculateWeights(), Nektar::LibUtilities::PolyEPoints::v_CalculateWeights(), Nektar::SolverUtils::DriverParareal::v_Execute(), Nektar::SolverUtils::DriverPFASST::v_Execute(), Nektar::StdRegions::StdPointExp::v_IProductWRTBase(), Nektar::StdRegions::StdSegExp::v_IProductWRTBase(), Nektar::StdRegions::StdSegExp::v_IProductWRTBase_SumFac(), Nektar::MultiRegions::ExpList3DHomogeneous1D::v_L2(), Nektar::FentonKarma::v_Update(), Vmath::Vstvpp(), Vmath::SIMD::Vvtvm(), Vmath::Vvtvm(), Vmath::SIMD::Vvtvp(), Vmath::Vvtvp(), Vmath::SIMD::Vvtvvtm(), Vmath::Vvtvvtm(), Vmath::SIMD::Vvtvvtp(), Vmath::Vvtvvtp(), Polylib::zwgj(), Polylib::zwgk(), Polylib::zwglj(), Polylib::zwgrjm(), Polylib::zwgrjp(), Polylib::zwlk(), and Polylib::zwrk().

◆ z()

std::vector< double > Nektar::UnitTests::z ( NPUPPER  )

Referenced by Nektar::MMFAdvection::AdvectionBellPlane(), Nektar::MMFAdvection::AdvectionBellSphere(), Nektar::SolverUtils::UnsteadySystem::AppendOutput1D(), Vmath::Assmb(), Nektar::StdRegions::StdExpansion::BaryEvaluate(), Nektar::VmathSIMDUnitTests::BOOST_AUTO_TEST_CASE(), CheckTetRotation(), Polylib::chri1(), Polylib::Dgj(), Polylib::Dglj(), Polylib::Dgrjm(), Polylib::Dgrjp(), Arpack::Dneupd(), Nektar::MMFDiffusion::DoOdeRhs(), Lapack::Dsbev(), Arpack::Dseupd(), Lapack::Dspev(), Equation_Evaluate2(), Equation_Evaluate3(), Equation_Evaluate4(), Equation_Evaluate5(), Nektar::LibUtilities::Interpreter::ExpressionEvaluator::Evaluate(), Nektar::LibUtilities::Interpreter::Evaluate(), Nektar::LibUtilities::Equation::Evaluate(), Nektar::MMFMaxwell::EvaluateCoriolis(), Nektar::MMFSWE::EvaluateCoriolisForZonalFlow(), Nektar::IsentropicVortexBC::EvaluateIsentropicVortex(), Nektar::CompressibleFlowSystem::EvaluateIsentropicVortex(), Nektar::MMFSWE::EvaluateStandardCoriolis(), Nektar::MMFSWE::EvaluateWaterDepth(), Nektar::MultiRegions::DisContField::FindPeriodicTraces(), Vmath::SIMD::Gathr(), Vmath::Gathr(), Nektar::MMFMaxwell::GaussianPulse(), Nektar::LibUtilities::Basis::GenBasis(), Nektar::MMFMaxwell::GenerateSigmaPML(), Nektar::LocalRegions::PointExp::GetCoords(), Nektar::SpatialDomains::MeshGraph::GetElementsContainingPoint(), Nektar::CompressibleFlowSystem::GetExactRinglebFlow(), Nektar::MultiRegions::ExpList::GetExpIndex(), Nektar::SpatialDomains::TriGeom::GetFaceOrientation(), Nektar::SpatialDomains::QuadGeom::GetFaceOrientation(), Nektar::LibUtilities::Points< DataT >::GetI(), GetNewVertexLocation(), Nektar::StdRegions::StdNodalPrismExp::GetNodalPoints(), Nektar::StdRegions::StdNodalTetExp::GetNodalPoints(), Nektar::LibUtilities::Points< DataT >::GetPoints(), Nektar::SpatialDomains::ZonePrescribe::GetXDeform(), Nektar::SpatialDomains::ZonePrescribe::GetYDeform(), Nektar::SpatialDomains::ZonePrescribe::GetZDeform(), Nektar::LibUtilities::Points< DataT >::GetZW(), Nektar::LibUtilities::Basis::GetZW(), Polylib::hgj(), Polylib::hglj(), Polylib::hgrjm(), Polylib::hgrjp(), Polylib::ImagBesselComp(), Interpreter_Evaluate2(), Interpreter_Evaluate3(), Nektar::MMFSWE::IsolatedMountainFlow(), Polylib::jacobd(), Polylib::jacobfd(), Polylib::Jacobz(), Polylib::JacZeros(), Polylib::laginterp(), Polylib::laginterpderiv(), main(), MappingEVids(), Nektar::FieldUtils::MappingIdealToRef(), Nektar::MMFDiffusion::Morphogenesis(), MoveOutsidePointsfixedxpos(), MoveOutsidePointsNnormpos(), Nektar::LibUtilities::NodalPrismEvenlySpaced::NodalPointReorder3d(), Nektar::LibUtilities::NodalTetEvenlySpaced::NodalPointReorder3d(), OUTPUT(), Nektar::FieldUtils::OutputVtk::OutputFromExpLowOrder(), Nektar::FieldUtils::OutputVtk::OutputFromExpLowOrderMultiBlock(), Nektar::LibUtilities::EulerExponentialTimeIntegrationScheme::phi_function(), Nektar::MMFDiffusion::PlanePhiWave(), Polylib::polycoeffs(), Nektar::MMFMaxwell::Printout_SurfaceCurrent(), Polylib::Qg(), Nektar::MMFSWE::RossbyWave(), Vmath::Scatr(), Nektar::IncNavierStokes::SetUpWomersley(), Nektar::MMFSWE::SteadyZonalFlow(), Vmath::Svtsvtp(), Vmath::Svtvm(), Vmath::Svtvp(), Nektar::MMFDiffusion::TestCubeProblem(), TestDifferentiation(), TestIntegral(), TestIntegralMatrix(), TestInterpolation(), Nektar::MMFMaxwell::TestMaxwellSphere(), Nektar::MMFDiffusion::TestPlaneProblem(), Nektar::MMFSWE::TestVorticityComputation(), Polylib::TriQL(), Nektar::MMFSWE::UnstableJetFlow(), Nektar::MMFSWE::UnsteadyZonalFlow(), Nektar::FilterMovingBody::UpdateForce(), Nektar::IsentropicVortexBC::v_Apply(), Nektar::LibUtilities::NodalPrismEvenlySpaced::v_CalculatePoints(), Nektar::LibUtilities::NodalTetEvenlySpaced::v_CalculatePoints(), Nektar::LibUtilities::PolyEPoints::v_CalculateWeights(), Nektar::MultiRegions::PreconditionerBlock::v_DoPreconditioner(), Nektar::MultiRegions::PreconditionerLowEnergy::v_DoPreconditioner(), Nektar::MMFMaxwell::v_DoSolve(), Nektar::MultiRegions::DisContField3DHomogeneous2D::v_EvaluateBoundaryConditions(), Nektar::SolverUtils::DriverArpack::v_Execute(), Nektar::SpatialDomains::Geometry2D::v_FindDistance(), Nektar::SolverUtils::MMFSystem::v_GenerateSummary(), Nektar::MultiRegions::ExpList2DHomogeneous1D::v_GetCoords(), Nektar::MultiRegions::ExpList2DHomogeneous2D::v_GetCoords(), Nektar::MultiRegions::ExpList3DHomogeneous1D::v_GetCoords(), Nektar::MultiRegions::ExpList3DHomogeneous2D::v_GetCoords(), Nektar::LibUtilities::NodalPrismElec::v_GetI(), Nektar::LibUtilities::NodalPrismEvenlySpaced::v_GetI(), Nektar::LibUtilities::NodalTetElec::v_GetI(), Nektar::LibUtilities::NodalTetEvenlySpaced::v_GetI(), Nektar::FilterElectrogram::v_Initialise(), Nektar::StdRegions::StdSegExp::v_Integral(), Nektar::StdRegions::StdPointExp::v_IProductWRTBase(), Nektar::MMFSWE::v_LinfError(), Nektar::FieldUtils::OutputTecplot::v_OutputFromExp(), Nektar::FieldUtils::ProcessFieldFromString::v_Process(), Nektar::MultiRegions::ExpList2DHomogeneous1D::v_WriteVtkPieceHeader(), Nektar::MultiRegions::ExpList3DHomogeneous1D::v_WriteVtkPieceHeader(), Vmath::SIMD::Vadd(), Vmath::Vadd(), Vmath::Vdiv(), Vmath::SIMD::Vmul(), Vmath::Vmul(), Vmath::Vstvpp(), Vmath::Vsub(), Vmath::SIMD::Vvtvm(), Vmath::Vvtvm(), Vmath::SIMD::Vvtvp(), Vmath::Vvtvp(), Vmath::SIMD::Vvtvvtm(), Vmath::Vvtvvtm(), Vmath::SIMD::Vvtvvtp(), Vmath::Vvtvvtp(), Nektar::NonlinearPeregrine::WallBoundaryContVariables(), Polylib::zwgj(), Polylib::zwgk(), Polylib::zwglj(), Polylib::zwgrjm(), Polylib::zwgrjp(), Polylib::zwlk(), and Polylib::zwrk().