From 365ed9267ad4b4bec3a4275c95f6cf8cc0ff6b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Mon, 14 Oct 2024 17:54:02 +0200 Subject: [PATCH] Allow specification of stencil type for polynomial reconstruction --- src/mesh/StencilBuilder.cpp | 2 +- src/scheme/PolynomialReconstruction.cpp | 4 +- .../PolynomialReconstructionDescriptor.hpp | 14 +-- ...est_PolynomialReconstructionDescriptor.cpp | 85 +++++++++++++++---- 4 files changed, 79 insertions(+), 26 deletions(-) diff --git a/src/mesh/StencilBuilder.cpp b/src/mesh/StencilBuilder.cpp index d20ebbb5a..8af6a76ae 100644 --- a/src/mesh/StencilBuilder.cpp +++ b/src/mesh/StencilBuilder.cpp @@ -119,7 +119,7 @@ StencilBuilder::_build(const ConnectivityType& connectivity, error_msg << "Stencil builder requires" << rang::fgB::yellow << number_of_layers << rang::fg::reset << " layers while parallel number of ghost layer is " << GlobalVariableManager::instance().getNumberOfGhostLayers() << ".\n"; - error_msg << "Increase the number of ghost layers (using '--number-of-ghost-layers' option)."; + error_msg << "Increase the number of ghost layers (using the '--number-of-ghost-layers' option)."; throw NormalError(error_msg.str()); } if (number_of_layers > 2) { diff --git a/src/scheme/PolynomialReconstruction.cpp b/src/scheme/PolynomialReconstruction.cpp index 76d27b500..2af32e157 100644 --- a/src/scheme/PolynomialReconstruction.cpp +++ b/src/scheme/PolynomialReconstruction.cpp @@ -771,9 +771,7 @@ PolynomialReconstruction::_build( DiscreteFunctionDPk<MeshType::Dimension, double>::BasisViewType::dimensionFromDegree(m_descriptor.degree()); const auto& stencil_array = - StencilManager::instance().getCellToCellStencilArray(mesh.connectivity(), - StencilDescriptor{m_descriptor.degree(), - StencilDescriptor::Type::by_nodes}, + StencilManager::instance().getCellToCellStencilArray(mesh.connectivity(), m_descriptor.stencilDescriptor(), m_descriptor.symmetryBoundaryDescriptorList()); auto xr = mesh.xr(); diff --git a/src/scheme/PolynomialReconstructionDescriptor.hpp b/src/scheme/PolynomialReconstructionDescriptor.hpp index ef6c97653..87188f85f 100644 --- a/src/scheme/PolynomialReconstructionDescriptor.hpp +++ b/src/scheme/PolynomialReconstructionDescriptor.hpp @@ -39,6 +39,13 @@ class PolynomialReconstructionDescriptor return m_degree; } + PUGS_INLINE + const StencilDescriptor& + stencilDescriptor() const + { + return m_stencil_descriptor; + } + PUGS_INLINE const BoundaryDescriptorList& symmetryBoundaryDescriptorList() const @@ -60,13 +67,6 @@ class PolynomialReconstructionDescriptor return m_row_weighting; } - PUGS_INLINE - void - setDegree(const size_t degree) - { - m_degree = degree; - } - PUGS_INLINE void setPreconditioning(const bool preconditioning) diff --git a/tests/test_PolynomialReconstructionDescriptor.cpp b/tests/test_PolynomialReconstructionDescriptor.cpp index cadc6aaf4..9fc51a5bf 100644 --- a/tests/test_PolynomialReconstructionDescriptor.cpp +++ b/tests/test_PolynomialReconstructionDescriptor.cpp @@ -2,18 +2,23 @@ #include <catch2/catch_test_macros.hpp> #include <catch2/matchers/catch_matchers_all.hpp> +#include <mesh/NamedBoundaryDescriptor.hpp> +#include <mesh/NumberedBoundaryDescriptor.hpp> #include <scheme/PolynomialReconstructionDescriptor.hpp> // clazy:excludeall=non-pod-global-static TEST_CASE("PolynomialReconstructionDescriptor", "[scheme]") { -#warning tests are not completed SECTION("degree 1") { PolynomialReconstructionDescriptor descriptor{IntegrationMethodType::cell_center, 1}; REQUIRE(descriptor.degree() == 1); + REQUIRE(descriptor.stencilDescriptor().numberOfLayers() == 1); + REQUIRE(descriptor.stencilDescriptor().type() == StencilDescriptor::Type::by_nodes); + REQUIRE(descriptor.symmetryBoundaryDescriptorList().size() == 0); + REQUIRE(descriptor.preconditioning() == true); REQUIRE(descriptor.rowWeighting() == true); } @@ -23,32 +28,82 @@ TEST_CASE("PolynomialReconstructionDescriptor", "[scheme]") PolynomialReconstructionDescriptor descriptor{IntegrationMethodType::cell_center, 4}; REQUIRE(descriptor.degree() == 4); + REQUIRE(descriptor.stencilDescriptor().numberOfLayers() == 4); + REQUIRE(descriptor.stencilDescriptor().type() == StencilDescriptor::Type::by_nodes); + REQUIRE(descriptor.symmetryBoundaryDescriptorList().size() == 0); + REQUIRE(descriptor.preconditioning() == true); REQUIRE(descriptor.rowWeighting() == true); } - SECTION("utlities") + SECTION("degree and stencil") { - PolynomialReconstructionDescriptor descriptor{IntegrationMethodType::cell_center, 3}; + StencilDescriptor sd{2, StencilDescriptor::Type::by_faces}; + + PolynomialReconstructionDescriptor descriptor{IntegrationMethodType::cell_center, 1, sd}; + + REQUIRE(descriptor.degree() == 1); + REQUIRE(descriptor.stencilDescriptor().numberOfLayers() == 2); + REQUIRE(descriptor.stencilDescriptor().type() == StencilDescriptor::Type::by_faces); + REQUIRE(descriptor.symmetryBoundaryDescriptorList().size() == 0); - REQUIRE(descriptor.degree() == 3); REQUIRE(descriptor.preconditioning() == true); REQUIRE(descriptor.rowWeighting() == true); + } - SECTION("set degree") - { - descriptor.setDegree(2); + SECTION("degree and symmetries") + { + std::vector<std::shared_ptr<const IBoundaryDescriptor>> bc_list; + bc_list.push_back(std::make_shared<NamedBoundaryDescriptor>("XMIN")); + bc_list.push_back(std::make_shared<NamedBoundaryDescriptor>("YMIN")); + bc_list.push_back(std::make_shared<NumberedBoundaryDescriptor>(2)); - REQUIRE(descriptor.degree() == 2); - REQUIRE(descriptor.preconditioning() == true); - REQUIRE(descriptor.rowWeighting() == true); + PolynomialReconstructionDescriptor descriptor{IntegrationMethodType::cell_center, 2, bc_list}; - descriptor.setDegree(4); + REQUIRE(descriptor.degree() == 2); + REQUIRE(descriptor.stencilDescriptor().numberOfLayers() == 2); + REQUIRE(descriptor.stencilDescriptor().type() == StencilDescriptor::Type::by_nodes); + REQUIRE(descriptor.symmetryBoundaryDescriptorList().size() == 3); - REQUIRE(descriptor.degree() == 4); - REQUIRE(descriptor.preconditioning() == true); - REQUIRE(descriptor.rowWeighting() == true); - } + REQUIRE(descriptor.symmetryBoundaryDescriptorList()[0]->type() == IBoundaryDescriptor::Type::named); + REQUIRE(descriptor.symmetryBoundaryDescriptorList()[1]->type() == IBoundaryDescriptor::Type::named); + REQUIRE(descriptor.symmetryBoundaryDescriptorList()[2]->type() == IBoundaryDescriptor::Type::numbered); + + REQUIRE(descriptor.preconditioning() == true); + REQUIRE(descriptor.rowWeighting() == true); + } + + SECTION("degree, stencil and symmetries") + { + StencilDescriptor sd{3, StencilDescriptor::Type::by_edges}; + + std::vector<std::shared_ptr<const IBoundaryDescriptor>> bc_list; + bc_list.push_back(std::make_shared<NamedBoundaryDescriptor>("XMIN")); + bc_list.push_back(std::make_shared<NumberedBoundaryDescriptor>(2)); + bc_list.push_back(std::make_shared<NamedBoundaryDescriptor>("YMIN")); + + PolynomialReconstructionDescriptor descriptor{IntegrationMethodType::cell_center, 1, sd, bc_list}; + + REQUIRE(descriptor.degree() == 1); + REQUIRE(descriptor.stencilDescriptor().numberOfLayers() == 3); + REQUIRE(descriptor.stencilDescriptor().type() == StencilDescriptor::Type::by_edges); + REQUIRE(descriptor.symmetryBoundaryDescriptorList().size() == 3); + + REQUIRE(descriptor.symmetryBoundaryDescriptorList()[0]->type() == IBoundaryDescriptor::Type::named); + REQUIRE(descriptor.symmetryBoundaryDescriptorList()[1]->type() == IBoundaryDescriptor::Type::numbered); + REQUIRE(descriptor.symmetryBoundaryDescriptorList()[2]->type() == IBoundaryDescriptor::Type::named); + + REQUIRE(descriptor.preconditioning() == true); + REQUIRE(descriptor.rowWeighting() == true); + } + + SECTION("utlities") + { + PolynomialReconstructionDescriptor descriptor{IntegrationMethodType::cell_center, 3}; + + REQUIRE(descriptor.degree() == 3); + REQUIRE(descriptor.preconditioning() == true); + REQUIRE(descriptor.rowWeighting() == true); SECTION("set preconditioning") { -- GitLab