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

Add tests for PolynomialReconstruction using element quadrature

parent e6bb5bed
No related branches found
No related tags found
1 merge request!205High-order polynomial reconstruction
...@@ -24,8 +24,14 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -24,8 +24,14 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
{ {
SECTION("degree 1") SECTION("degree 1")
{ {
PolynomialReconstructionDescriptor descriptor{IntegrationMethodType::cell_center, 1}; std::vector<PolynomialReconstructionDescriptor> descriptor_list = {
PolynomialReconstructionDescriptor{IntegrationMethodType::cell_center, 1},
PolynomialReconstructionDescriptor{IntegrationMethodType::element, 1},
};
for (auto descriptor : descriptor_list) {
SECTION(name(descriptor.integrationMethodType()))
{
SECTION("1D") SECTION("1D")
{ {
using R1 = TinyVector<1>; using R1 = TinyVector<1>;
...@@ -224,8 +230,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -224,8 +230,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) { for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) {
for (size_t i = 0; i < slope.dimension(); ++i) { for (size_t i = 0; i < slope.dimension(); ++i) {
const double reconstructed_slope = const double reconstructed_slope = (1 / 0.2) * (dpk_Vh(cell_id, i)(R1{0.1} + xj[cell_id]) -
(1 / 0.2) * (dpk_Vh(cell_id, i)(R1{0.1} + xj[cell_id]) - dpk_Vh(cell_id, i)(xj[cell_id] - R1{0.1})); dpk_Vh(cell_id, i)(xj[cell_id] - R1{0.1}));
max_slope_error = std::max(max_slope_error, std::abs(reconstructed_slope - slope[i])); max_slope_error = std::max(max_slope_error, std::abs(reconstructed_slope - slope[i]));
} }
...@@ -385,8 +391,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -385,8 +391,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) { for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) {
for (size_t i = 0; i < slope.dimension(); ++i) { for (size_t i = 0; i < slope.dimension(); ++i) {
const double reconstructed_slope = const double reconstructed_slope = (1 / 0.2) * (dpk_Vh(cell_id, i)(R1{0.1} + xj[cell_id]) -
(1 / 0.2) * (dpk_Vh(cell_id, i)(R1{0.1} + xj[cell_id]) - dpk_Vh(cell_id, i)(xj[cell_id] - R1{0.1})); dpk_Vh(cell_id, i)(xj[cell_id] - R1{0.1}));
max_slope_error = std::max(max_slope_error, std::abs(reconstructed_slope - slope[i])); max_slope_error = std::max(max_slope_error, std::abs(reconstructed_slope - slope[i]));
} }
...@@ -494,8 +500,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -494,8 +500,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
{ {
double max_x_slope_error = 0; double max_x_slope_error = 0;
for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) { for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) {
const R3 reconstructed_slope = const R3 reconstructed_slope = (1 / 0.2) * (dpk_uh[cell_id](R2{0.1, 0} + xj[cell_id]) -
(1 / 0.2) * (dpk_uh[cell_id](R2{0.1, 0} + xj[cell_id]) - dpk_uh[cell_id](xj[cell_id] - R2{0.1, 0})); dpk_uh[cell_id](xj[cell_id] - R2{0.1, 0}));
max_x_slope_error = std::max(max_x_slope_error, l2Norm(reconstructed_slope - R3{1.7, -0.6, 3.1})); max_x_slope_error = std::max(max_x_slope_error, l2Norm(reconstructed_slope - R3{1.7, -0.6, 3.1}));
} }
...@@ -505,8 +511,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -505,8 +511,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
{ {
double max_y_slope_error = 0; double max_y_slope_error = 0;
for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) { for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) {
const R3 reconstructed_slope = const R3 reconstructed_slope = (1 / 0.2) * (dpk_uh[cell_id](R2{0, 0.1} + xj[cell_id]) -
(1 / 0.2) * (dpk_uh[cell_id](R2{0, 0.1} + xj[cell_id]) - dpk_uh[cell_id](xj[cell_id] - R2{0, 0.1})); dpk_uh[cell_id](xj[cell_id] - R2{0, 0.1}));
max_y_slope_error = std::max(max_y_slope_error, l2Norm(reconstructed_slope - R3{-2.2, 1.3, -1.1})); max_y_slope_error = std::max(max_y_slope_error, l2Norm(reconstructed_slope - R3{-2.2, 1.3, -1.1}));
} }
...@@ -553,8 +559,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -553,8 +559,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
{ {
double max_x_slope_error = 0; double max_x_slope_error = 0;
for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) { for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) {
const R2x2 reconstructed_slope = const R2x2 reconstructed_slope = (1 / 0.2) * (dpk_Ah[cell_id](R2{0.1, 0} + xj[cell_id]) -
(1 / 0.2) * (dpk_Ah[cell_id](R2{0.1, 0} + xj[cell_id]) - dpk_Ah[cell_id](xj[cell_id] - R2{0.1, 0})); dpk_Ah[cell_id](xj[cell_id] - R2{0.1, 0}));
max_x_slope_error = max_x_slope_error =
std::max(max_x_slope_error, frobeniusNorm(reconstructed_slope - R2x2{+1.7, +2.1, // std::max(max_x_slope_error, frobeniusNorm(reconstructed_slope - R2x2{+1.7, +2.1, //
...@@ -566,8 +572,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -566,8 +572,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
{ {
double max_y_slope_error = 0; double max_y_slope_error = 0;
for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) { for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) {
const R2x2 reconstructed_slope = const R2x2 reconstructed_slope = (1 / 0.2) * (dpk_Ah[cell_id](R2{0, 0.1} + xj[cell_id]) -
(1 / 0.2) * (dpk_Ah[cell_id](R2{0, 0.1} + xj[cell_id]) - dpk_Ah[cell_id](xj[cell_id] - R2{0, 0.1})); dpk_Ah[cell_id](xj[cell_id] - R2{0, 0.1}));
max_y_slope_error = max_y_slope_error =
std::max(max_y_slope_error, frobeniusNorm(reconstructed_slope - R2x2{+1.2, -2.2, // std::max(max_y_slope_error, frobeniusNorm(reconstructed_slope - R2x2{+1.2, -2.2, //
...@@ -689,7 +695,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -689,7 +695,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
double max_x_slope_error = 0; double max_x_slope_error = 0;
for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) { for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) {
const double reconstructed_slope = const double reconstructed_slope =
(dpk_fh[cell_id](R3{0.1, 0, 0} + xj[cell_id]) - dpk_fh[cell_id](xj[cell_id] - R3{0.1, 0, 0})) / 0.2; (dpk_fh[cell_id](R3{0.1, 0, 0} + xj[cell_id]) - dpk_fh[cell_id](xj[cell_id] - R3{0.1, 0, 0})) /
0.2;
max_x_slope_error = std::max(max_x_slope_error, std::abs(reconstructed_slope - 1.7)); max_x_slope_error = std::max(max_x_slope_error, std::abs(reconstructed_slope - 1.7));
} }
...@@ -700,7 +707,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -700,7 +707,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
double max_y_slope_error = 0; double max_y_slope_error = 0;
for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) { for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) {
const double reconstructed_slope = const double reconstructed_slope =
(dpk_fh[cell_id](R3{0, 0.1, 0} + xj[cell_id]) - dpk_fh[cell_id](xj[cell_id] - R3{0, 0.1, 0})) / 0.2; (dpk_fh[cell_id](R3{0, 0.1, 0} + xj[cell_id]) - dpk_fh[cell_id](xj[cell_id] - R3{0, 0.1, 0})) /
0.2;
max_y_slope_error = std::max(max_y_slope_error, std::abs(reconstructed_slope - (-1.3))); max_y_slope_error = std::max(max_y_slope_error, std::abs(reconstructed_slope - (-1.3)));
} }
...@@ -711,7 +719,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -711,7 +719,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
double max_z_slope_error = 0; double max_z_slope_error = 0;
for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) { for (CellId cell_id = 0; cell_id < mesh.numberOfCells(); ++cell_id) {
const double reconstructed_slope = const double reconstructed_slope =
(dpk_fh[cell_id](R3{0, 0, 0.1} + xj[cell_id]) - dpk_fh[cell_id](xj[cell_id] - R3{0, 0, 0.1})) / 0.2; (dpk_fh[cell_id](R3{0, 0, 0.1} + xj[cell_id]) - dpk_fh[cell_id](xj[cell_id] - R3{0, 0, 0.1})) /
0.2;
max_z_slope_error = std::max(max_z_slope_error, std::abs(reconstructed_slope - 2.1)); max_z_slope_error = std::max(max_z_slope_error, std::abs(reconstructed_slope - 2.1));
} }
...@@ -832,7 +841,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -832,7 +841,8 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
const R2x2 reconstructed_slope = (1 / 0.2) * (dpk_Ah[cell_id](R3{0.1, 0, 0} + xj[cell_id]) - const R2x2 reconstructed_slope = (1 / 0.2) * (dpk_Ah[cell_id](R3{0.1, 0, 0} + xj[cell_id]) -
dpk_Ah[cell_id](xj[cell_id] - R3{0.1, 0, 0})); dpk_Ah[cell_id](xj[cell_id] - R3{0.1, 0, 0}));
max_x_slope_error = std::max(max_x_slope_error, frobeniusNorm(reconstructed_slope - R2x2{+1.7, 2.1, // max_x_slope_error =
std::max(max_x_slope_error, frobeniusNorm(reconstructed_slope - R2x2{+1.7, 2.1, //
-2.3, +3.1})); -2.3, +3.1}));
} }
REQUIRE(parallel::allReduceMax(max_x_slope_error) == Catch::Approx(0).margin(1E-13)); REQUIRE(parallel::allReduceMax(max_x_slope_error) == Catch::Approx(0).margin(1E-13));
...@@ -969,3 +979,5 @@ TEST_CASE("PolynomialReconstruction", "[scheme]") ...@@ -969,3 +979,5 @@ TEST_CASE("PolynomialReconstruction", "[scheme]")
} }
} }
} }
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment