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 324 of file TestPolylib.cpp.

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

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 264 of file TestPolylib.cpp.

265{
267}
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:653
void zwgj(double *z, double *w, const int np, const double alpha, const double beta)
Gauss-Jacobi zeros and weights.
Definition: Polylib.cpp:152

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

◆ BOOST_AUTO_TEST_CASE() [3/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussInt  )

Definition at line 244 of file TestPolylib.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [4/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussInterp  )

Definition at line 284 of file TestPolylib.cpp.

285{
287}
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:1054

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

◆ BOOST_AUTO_TEST_CASE() [5/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussIntMatrix  )

Definition at line 304 of file TestPolylib.cpp.

305{
307}
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:611

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

◆ BOOST_AUTO_TEST_CASE() [6/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussLobatto  )

Definition at line 259 of file TestPolylib.cpp.

260{
262}
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:266

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

◆ BOOST_AUTO_TEST_CASE() [7/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussLobattoDiff  )

Definition at line 279 of file TestPolylib.cpp.

280{
282}
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:833

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

◆ BOOST_AUTO_TEST_CASE() [8/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussLobattoInterp  )

Definition at line 299 of file TestPolylib.cpp.

300{
302}
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:1147

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 249 of file TestPolylib.cpp.

250{
252}
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 269 of file TestPolylib.cpp.

270{
272}
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:704

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

◆ BOOST_AUTO_TEST_CASE() [12/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauMInterp  )

Definition at line 289 of file TestPolylib.cpp.

290{
292}
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:1085

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 254 of file TestPolylib.cpp.

255{
257}
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:225

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

◆ BOOST_AUTO_TEST_CASE() [15/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauPDiff  )

Definition at line 274 of file TestPolylib.cpp.

275{
277}
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:768

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

◆ BOOST_AUTO_TEST_CASE() [16/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestGaussRadauPInterp  )

Definition at line 294 of file TestPolylib.cpp.

295{
297}
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:1116

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 189 of file testNekVector.cpp.

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

104{
105 using namespace Nektar;
106
107 // Test the constructors on a numeric type.
108 {
110 BOOST_CHECK(p1.x() == 0.0);
111 BOOST_CHECK(p1.y() == 0.0);
112 BOOST_CHECK(p1.z() == 0.0);
113
114 NekPoint<double> p3(p1);
115 BOOST_CHECK(p1 == p3);
116 }
117
118 // Now test it on an arbitrary type.
119 {
121 BOOST_CHECK(p1.x() == PointTestClass(0));
122 BOOST_CHECK(p1.y() == PointTestClass(0));
123 BOOST_CHECK(p1.z() == PointTestClass(0));
124
125 BOOST_CHECK(p1.x() == PointTestClass());
126 BOOST_CHECK(p1.y() == PointTestClass());
127 BOOST_CHECK(p1.z() == PointTestClass());
128
130 BOOST_CHECK(p1 == p3);
131 }
132}
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

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 174 of file testNekVector.cpp.

175{
176}

◆ BOOST_AUTO_TEST_CASE() [23/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestNekVectorConstruction  )

Definition at line 94 of file testNekVector.cpp.

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

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

◆ BOOST_AUTO_TEST_CASE() [24/26]

Nektar::UnitTests::BOOST_AUTO_TEST_CASE ( TestNekVectorOperators  )

Definition at line 128 of file testNekVector.cpp.

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

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 178 of file testNekVector.cpp.

179{
180 double vals[] = {1, -2, 3};
181 NekVector<double> v(3, vals);
182
183 double epsilon = 1e-11;
184 BOOST_CHECK_EQUAL(v.L1Norm(), 1.0 + 2.0 + 3.0);
185 BOOST_CHECK_CLOSE(v.L2Norm(), sqrt(1.0 + 4.0 + 9.0), epsilon);
186 BOOST_CHECK_EQUAL(v.InfinityNorm(), 3);
187}
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 335 of file testNekVector.cpp.

336{
337 {
338 double buf[] = {1.0, 2.0, 3.0, 4.0};
339 Array<OneD, double> a(4, buf);
340 NekVector<double> b(3, a);
341
342 BOOST_CHECK_EQUAL(b.GetRows(), 3u);
343 BOOST_CHECK_EQUAL(b.GetDimension(), 3u);
344 BOOST_CHECK_EQUAL(b[0], 1.0);
345 BOOST_CHECK_EQUAL(b[1], 2.0);
346 BOOST_CHECK_EQUAL(b[2], 3.0);
347
348 NekVector<double>::iterator iter = b.begin();
349 BOOST_CHECK_EQUAL(*iter, 1.0);
350 ++iter;
351 BOOST_CHECK_EQUAL(*iter, 2.0);
352 ++iter;
353 BOOST_CHECK_EQUAL(*iter, 3.0);
354 ++iter;
355 BOOST_CHECK(iter == b.end());
356 }
357
358 {
359 double buf[] = {1.0, 2.0, 3.0, 4.0};
360 Array<OneD, const double> a(4, buf);
361 NekVector<double> b(3, a);
362
363 BOOST_CHECK_EQUAL(b.GetRows(), 3u);
364 BOOST_CHECK_EQUAL(b.GetDimension(), 3u);
365 BOOST_CHECK_EQUAL(b[0], 1.0);
366 BOOST_CHECK_EQUAL(b[1], 2.0);
367 BOOST_CHECK_EQUAL(b[2], 3.0);
368
369 NekVector<double>::iterator iter = b.begin();
370 BOOST_CHECK_EQUAL(*iter, 1.0);
371 ++iter;
372 BOOST_CHECK_EQUAL(*iter, 2.0);
373 ++iter;
374 BOOST_CHECK_EQUAL(*iter, 3.0);
375 ++iter;
376 BOOST_CHECK(iter == b.end());
377 }
378
379 {
380 double buf[] = {1.0, 2.0, 3.0, 4.0};
381 Array<OneD, double> a(4, buf);
382 NekVector<double> b(3, a, eWrapper);
383
384 BOOST_CHECK_EQUAL(b.GetRows(), 3u);
385 BOOST_CHECK_EQUAL(b.GetDimension(), 3u);
386 BOOST_CHECK_EQUAL(b[0], 1.0);
387 BOOST_CHECK_EQUAL(b[1], 2.0);
388 BOOST_CHECK_EQUAL(b[2], 3.0);
389
390 NekVector<double>::iterator iter = b.begin();
391 BOOST_CHECK_EQUAL(*iter, 1.0);
392 ++iter;
393 BOOST_CHECK_EQUAL(*iter, 2.0);
394 ++iter;
395 BOOST_CHECK_EQUAL(*iter, 3.0);
396 ++iter;
397 BOOST_CHECK(iter == b.end());
398
399 b[0] = 5.0;
400 BOOST_CHECK_EQUAL(b[0], a[0]);
401 }
402}
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::PulseWaveSystem::GetCommArray(), Nektar::NavierStokesCFE::GetDivCurlSquared(), Nektar::SpatialDomains::MeshGraph::GetElementsFromEdge(), Nektar::LibUtilities::FieldIO::GetFileType(), Nektar::UnsteadyDiffusion::GetFluxVector(), Nektar::CompressibleFlowSystem::GetFluxVector(), GetInterfaces_wrapper(), Nektar::VariableConverter::GetInternalEnergy(), Nektar::SolverUtils::FilterLagrangianPoints::GetPhysicsData(), 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::SolverUtils::FilterLagrangianPoints::OutputSamplePoints(), Nektar::SolverUtils::EvaluatePoints::Pack2Int(), Nektar::SolverUtils::EvaluatePoints::Pack3Int(), Nektar::LibUtilities::SessionReader::ParseCommandLineArguments(), 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::SolverUtils::StatLagrangianPoints::StatLagrangianPoints(), Nektar::LocalRegions::Expansion::StdDerivBaseOnTraceMat(), TestDifferentiation(), TestInterpolation(), Polylib::TriQL(), Nektar::SolverUtils::EvaluatePoints::unPack2Int(), Nektar::SolverUtils::EvaluatePoints::unPack3Int(), Nektar::SolverUtils::StatLagrangianPoints::v_AssignPoint(), 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::SolverUtils::StatLagrangianPoints::v_GetCoords(), 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::MultiRegions::ExpList::v_GetNormals(), Nektar::SolverUtils::StatLagrangianPoints::v_GetPhysics(), Nektar::SolverUtils::FilterLagrangianPoints::v_Initialise(), Nektar::PulseWaveSystem::v_InitObject(), Nektar::SolverUtils::StatLagrangianPoints::v_OutputData(), Nektar::FieldUtils::InputFld::v_Process(), Nektar::FieldUtils::ProcessCreateExp::v_Process(), Nektar::SolverUtils::StatLagrangianPoints::v_ReSize(), Nektar::SolverUtils::StatLagrangianPoints::v_SetCoords(), Nektar::SolverUtils::StatLagrangianPoints::v_SetPhysics(), Nektar::NekMatrix< DataType, StandardMatrixTag >::v_SetValue(), and Nektar::SolverUtils::StatLagrangianPoints::v_TimeAdvance().

◆ ddot()

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

Dot product two vectors.

Definition at line 55 of file TestPolylib.cpp.

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

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

◆ operator!=() [1/2]

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

Definition at line 76 of file testNekPoint.cpp.

77{
78 return !(lhs == rhs);
79}

◆ operator!=() [2/2]

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

Definition at line 84 of file testNekVector.cpp.

85{
86 return !(lhs == rhs);
87}

◆ operator==() [1/2]

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

Definition at line 71 of file testNekPoint.cpp.

72{
73 return lhs.value() == rhs.value();
74}

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

◆ operator==() [2/2]

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

Definition at line 79 of file testNekVector.cpp.

80{
81 return lhs.value() == rhs.value();
82}

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::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::LibUtilities::FractionalInTimeIntegrationScheme::integralClassInitialize(), Nektar::LibUtilities::FractionalInTimeIntegrationScheme::integralContribution(), main(), MappingEVids(), Nektar::FieldUtils::MatSymEVals(), Nektar::LibUtilities::SessionReader::MergeDoc(), Nektar::SolverUtils::EvaluatePoints::Pack3Int(), Nektar::LibUtilities::FractionalInTimeIntegrationScheme::talbotQuadrature(), TestIntegralMatrix(), Nektar::LibUtilities::FractionalInTimeIntegrationScheme::timeAdvance(), Nektar::SolverUtils::EvaluatePoints::unPack3Int(), 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 116 of file TestPolylib.cpp.

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

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 81 of file TestPolylib.cpp.

83{
84 double alpha = -0.5;
85 while (alpha <= 5.0)
86 {
87 double beta = -0.5;
88 while (beta <= 5.0)
89 {
90 for (int np = NPLOWER; np <= NPUPPER; ++np)
91 {
92 func(&z[0], &w[0], np, alpha, beta);
93 for (int n = 2; n < 2 * np - 1 - o; ++n)
94 {
95 Polylib::jacobfd(np, &z[0], &p[0], nullptr, n, alpha, beta);
96 double sum = ddot(np, &w[0], 1, &p[0], 1);
97 BOOST_CHECK_SMALL(sum, EPS);
98 }
99 }
100
101 beta += 0.5;
102 }
103
104 alpha += 0.5;
105 }
106}
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:1248

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 205 of file TestPolylib.cpp.

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

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

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::SolverUtils::DriverParareal::ApplyWindowing(), 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(), Nektar::LibUtilities::NekLinSysIterGMRES::DoGmresRestart(), Nektar::LibUtilities::NekLinSysIterGMRESLoc::DoGmresRestart(), 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::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::SolverUtils::EvaluatePoints::GetDefaultValue(), 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::ExpList3DHomogeneous1D::v_GetCoords(), Nektar::MultiRegions::ExpList3DHomogeneous2D::v_GetCoords(), Nektar::MultiRegions::ExpList2DHomogeneous1D::v_GetCoords(), Nektar::MultiRegions::ExpList2DHomogeneous2D::v_GetCoords(), Nektar::LibUtilities::NodalPrismElec::v_GetI(), Nektar::LibUtilities::NodalPrismEvenlySpaced::v_GetI(), Nektar::LibUtilities::NodalTetElec::v_GetI(), Nektar::LibUtilities::NodalTetEvenlySpaced::v_GetI(), Nektar::SolverUtils::FilterLagrangianPoints::v_Initialise(), 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(), Nektar::SpatialDomains::Movement::WriteMovement(), Polylib::zwgj(), Polylib::zwgk(), Polylib::zwglj(), Polylib::zwgrjm(), Polylib::zwgrjp(), Polylib::zwlk(), and Polylib::zwrk().