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

Add missing tests for DualMeshManager

parent 08be4530
No related branches found
No related tags found
1 merge request!128Feature/unit tests
...@@ -10,6 +10,24 @@ ...@@ -10,6 +10,24 @@
// clazy:excludeall=non-pod-global-static // clazy:excludeall=non-pod-global-static
TEST_CASE("DualMeshManager", "[mesh]") TEST_CASE("DualMeshManager", "[mesh]")
{
SECTION("same 1D dual connectivities ")
{
using ConnectivityType = Connectivity<1>;
using MeshType = Mesh<ConnectivityType>;
std::shared_ptr<const MeshType> mesh = MeshDataBaseForTests::get().unordered1DMesh();
std::shared_ptr p_diamond_dual_mesh = DualMeshManager::instance().getDiamondDualMesh(*mesh);
std::shared_ptr p_median_dual_mesh = DualMeshManager::instance().getMedianDualMesh(*mesh);
std::shared_ptr p_dual1d_mesh = DualMeshManager::instance().getDual1DMesh(*mesh);
// In 1d all these dual meshes are the same
REQUIRE(p_dual1d_mesh.get() == p_diamond_dual_mesh.get());
REQUIRE(p_dual1d_mesh.get() == p_median_dual_mesh.get());
}
SECTION("2D")
{ {
using ConnectivityType = Connectivity<2>; using ConnectivityType = Connectivity<2>;
using MeshType = Mesh<ConnectivityType>; using MeshType = Mesh<ConnectivityType>;
...@@ -97,3 +115,45 @@ TEST_CASE("DualMeshManager", "[mesh]") ...@@ -97,3 +115,45 @@ TEST_CASE("DualMeshManager", "[mesh]")
REQUIRE(p_diamond_dual_mesh.use_count() == diamond_ref_counter - 1); REQUIRE(p_diamond_dual_mesh.use_count() == diamond_ref_counter - 1);
} }
} }
SECTION("3D")
{
using ConnectivityType = Connectivity<3>;
using MeshType = Mesh<ConnectivityType>;
std::shared_ptr<const MeshType> mesh = MeshDataBaseForTests::get().hybrid3DMesh();
SECTION("diamond dual mesh access")
{
std::shared_ptr p_diamond_dual_mesh = DualMeshManager::instance().getDiamondDualMesh(*mesh);
const auto ref_counter = p_diamond_dual_mesh.use_count();
{
std::shared_ptr p_diamond_dual_mesh2 = DualMeshManager::instance().getDiamondDualMesh(*mesh);
REQUIRE(p_diamond_dual_mesh == p_diamond_dual_mesh2);
REQUIRE(p_diamond_dual_mesh.use_count() == ref_counter + 1);
}
REQUIRE(p_diamond_dual_mesh.use_count() == ref_counter);
DualMeshManager::instance().deleteMesh(mesh.get());
REQUIRE(p_diamond_dual_mesh.use_count() == ref_counter - 1);
// Can delete mesh from the list again. This means that no
// dual mesh associated with it is managed.
REQUIRE_NOTHROW(DualMeshManager::instance().deleteMesh(mesh.get()));
REQUIRE(p_diamond_dual_mesh.use_count() == ref_counter - 1);
// A new dual mesh is built
std::shared_ptr p_diamond_dual_mesh_rebuilt = DualMeshManager::instance().getDiamondDualMesh(*mesh);
REQUIRE(p_diamond_dual_mesh != p_diamond_dual_mesh_rebuilt);
REQUIRE(p_diamond_dual_mesh.get() != p_diamond_dual_mesh_rebuilt.get());
// Exactly two references to the dual mesh. One here and
// one in the manager.
REQUIRE(p_diamond_dual_mesh_rebuilt.use_count() == 2);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment