Skip to content
Snippets Groups Projects
Commit dee4c33d authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add tests for integration along 2d and 3d lines

parent 1fb2ac94
Branches
Tags
1 merge request!124Add files for high order integration with quadratures
#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));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment