diff --git a/tests/test_LineTransformation.cpp b/tests/test_LineTransformation.cpp index f7acac50fdb409bc2738d156fc1b9833e8ffff0e..764a842b8fdc0d817955d4d0e4e1c7ef4b5e2e48 100644 --- a/tests/test_LineTransformation.cpp +++ b/tests/test_LineTransformation.cpp @@ -1,6 +1,8 @@ #include <catch2/catch_approx.hpp> #include <catch2/catch_test_macros.hpp> +#include <analysis/GaussQuadratureDescriptor.hpp> +#include <analysis/QuadratureManager.hpp> #include <geometry/LineTransformation.hpp> // clazy:excludeall=non-pod-global-static @@ -40,6 +42,21 @@ TEST_CASE("LineTransformation", "[geometry]") REQUIRE(t(1)[1] == Catch::Approx(0.7)); REQUIRE(t.velocityNorm() == Catch::Approx(l2Norm(0.5 * (b - a)))); + + auto p = [](const R2& X) { + const double x = X[0]; + const double y = X[1]; + return 2 * x * x + 3 * x - 3 * y * y + y + 2; + }; + + QuadratureFormula<1> qf = QuadratureManager::instance().getLineFormula(GaussQuadratureDescriptor(2)); + + double sum = 0; + for (size_t i = 0; i < qf.numberOfPoints(); ++i) { + sum += qf.weight(i) * t.velocityNorm() * p(t(qf.point(i))); + } + + REQUIRE(sum == Catch::Approx(24.8585155630822)); } SECTION("3D") @@ -62,5 +79,21 @@ TEST_CASE("LineTransformation", "[geometry]") REQUIRE(t(1)[2] == Catch::Approx(0.3)); REQUIRE(t.velocityNorm() == Catch::Approx(l2Norm(0.5 * (b - a)))); + + auto p = [](const R3& X) { + const double x = X[0]; + const double y = X[1]; + const double z = X[2]; + return 2 * x * x + 3 * x - 3 * y * y + y + 2 * z * z - 0.5 * z + 2; + }; + + QuadratureFormula<1> qf = QuadratureManager::instance().getLineFormula(GaussQuadratureDescriptor(2)); + + double sum = 0; + for (size_t i = 0; i < qf.numberOfPoints(); ++i) { + sum += qf.weight(i) * t.velocityNorm() * p(t(qf.point(i))); + } + + REQUIRE(sum == Catch::Approx(30.08440406681767)); } }