Commit c30c6267 authored by Dmitry Yu. Naumov's avatar Dmitry Yu. Naumov Committed by Dmitry Yu. Naumov
Browse files

[T] Quadratic mesh generation. Update and test Q9.

parent a8267844
......@@ -30,7 +30,8 @@ public:
{
linear_mesh.reset(
MeshGenerator::generateRegularHexMesh(1.0, mesh_size));
quadratic_mesh = createQuadraticOrderMesh(*linear_mesh);
quadratic_mesh =
createQuadraticOrderMesh(*linear_mesh, false /* add centre node*/);
}
static constexpr int mesh_size = 5;
......
......@@ -270,7 +270,8 @@ TEST_F(MeshLibBoundaryElementSearchInSimpleHexMesh, SurfaceSearch)
TEST_F(MeshLibBoundaryElementSearchInSimpleHexMesh, QuadElementsSurfaceSearch)
{
ASSERT_TRUE(_hex_mesh != nullptr);
auto mesh = MeshLib::createQuadraticOrderMesh(*_hex_mesh);
auto mesh = MeshLib::createQuadraticOrderMesh(*_hex_mesh,
false /* add centre node*/);
const std::size_t& s = _number_of_subdivisions_per_direction;
const std::size_t n_nodes_2d = (s + 1) * (3 * s + 1);
......
......@@ -27,7 +27,8 @@ TEST(MeshLib, QuadraticOrderMesh_Line)
std::unique_ptr<Mesh> linear_mesh(MeshGenerator::generateLineMesh(
1, std::size_t(2)));
std::unique_ptr<Mesh> mesh(createQuadraticOrderMesh(*linear_mesh));
std::unique_ptr<Mesh> mesh(
createQuadraticOrderMesh(*linear_mesh, false /* add centre node*/));
ASSERT_EQ(5u, mesh->getNumberOfNodes());
ASSERT_EQ(3u, mesh->getNumberOfBaseNodes());
ASSERT_EQ(2u, mesh->getNumberOfElements());
......@@ -64,13 +65,14 @@ TEST(MeshLib, QuadraticOrderMesh_Line)
}
}
TEST(MeshLib, QuadraticOrderMesh_Quad)
TEST(MeshLib, QuadraticOrderMesh_Quad8)
{
using namespace MeshLib;
std::unique_ptr<Mesh> linear_mesh(MeshGenerator::generateRegularQuadMesh(
1, 1, std::size_t(2), std::size_t(2)));
std::unique_ptr<Mesh> mesh(createQuadraticOrderMesh(*linear_mesh));
std::unique_ptr<Mesh> mesh(
createQuadraticOrderMesh(*linear_mesh, false /* add centre node*/));
ASSERT_EQ(21u, mesh->getNumberOfNodes());
ASSERT_EQ(9u, mesh->getNumberOfBaseNodes());
ASSERT_EQ(4u, mesh->getNumberOfElements());
......@@ -119,6 +121,63 @@ TEST(MeshLib, QuadraticOrderMesh_Quad)
}));
}
TEST(MeshLib, QuadraticOrderMesh_Quad9)
{
using namespace MeshLib;
std::unique_ptr<Mesh> linear_mesh(MeshGenerator::generateRegularQuadMesh(
1, 1, std::size_t(2), std::size_t(2)));
std::unique_ptr<Mesh> mesh(
createQuadraticOrderMesh(*linear_mesh, true /* add centre node*/));
ASSERT_EQ(21u + 4u, mesh->getNumberOfNodes());
ASSERT_EQ(9u, mesh->getNumberOfBaseNodes());
ASSERT_EQ(4u, mesh->getNumberOfElements());
for (MeshLib::Element const* e : mesh->getElements())
{
ASSERT_EQ(MeshLib::CellType::QUAD9, e->getCellType());
ASSERT_EQ(4u, e->getNumberOfBaseNodes());
ASSERT_EQ(9u, e->getNumberOfNodes());
for (unsigned i = 0; i < e->getNumberOfBaseNodes(); i++)
{
ASSERT_TRUE(mesh->isBaseNode(e->getNodeIndex(i)));
}
for (unsigned i = e->getNumberOfBaseNodes(); i < e->getNumberOfNodes();
i++)
{
ASSERT_FALSE(mesh->isBaseNode(e->getNodeIndex(i)));
}
}
auto const& mesh_nodes = mesh->getNodes();
// Count nodes shared by four elements and also connected to all 25 other
// nodes.
ASSERT_EQ(1, std::count_if(
mesh_nodes.begin(), mesh_nodes.end(), [](Node* const n) {
return (n->getElements().size() == 4) &&
(n->getConnectedNodes().size() == 21 + 4);
}));
// Count nodes belonging to one element and also connected to all 9 other
// nodes of that corner element---three corners and the centre node.
ASSERT_EQ(
12 + 4,
std::count_if(mesh_nodes.begin(), mesh_nodes.end(), [](Node* const n) {
return (n->getElements().size() == 1) &&
(n->getConnectedNodes().size() == 9);
}));
// Count nodes shared by two elements and also connected to the 15 other
// nodes of the two elements.
ASSERT_EQ(8, std::count_if(
mesh_nodes.begin(), mesh_nodes.end(), [](Node* const n) {
return (n->getElements().size() == 2) &&
(n->getConnectedNodes().size() == 13 + 2);
}));
}
TEST(MeshLib, QuadraticOrderMesh_LineQuad)
{
using namespace MeshLib;
......@@ -148,7 +207,8 @@ TEST(MeshLib, QuadraticOrderMesh_LineQuad)
}
ASSERT_EQ(6u, linear_mesh->getNumberOfElements());
std::unique_ptr<Mesh> mesh(createQuadraticOrderMesh(*linear_mesh));
std::unique_ptr<Mesh> mesh(
createQuadraticOrderMesh(*linear_mesh, false /* add centre node*/));
ASSERT_EQ(21u, mesh->getNumberOfNodes());
ASSERT_EQ(9u, mesh->getNumberOfBaseNodes());
ASSERT_EQ(6u, mesh->getNumberOfElements());
......
......@@ -52,8 +52,8 @@ TEST(NumLib_SparsityPattern, DISABLED_SingleComponentQuadraticMesh)
{
std::unique_ptr<MeshLib::Mesh> linear_mesh(
MeshLib::MeshGenerator::generateLineMesh(3u, 1.));
std::unique_ptr<MeshLib::Mesh> mesh(
MeshLib::createQuadraticOrderMesh(*linear_mesh));
std::unique_ptr<MeshLib::Mesh> mesh(MeshLib::createQuadraticOrderMesh(
*linear_mesh, false /* add centre node */));
MeshLib::MeshSubset nodesSubset{*mesh, mesh->getNodes()};
std::vector<MeshLib::MeshSubset> components{nodesSubset};
......@@ -110,8 +110,8 @@ TEST(NumLib_SparsityPattern, DISABLED_MultipleComponentsLinearQuadraticMesh)
{
std::unique_ptr<MeshLib::Mesh> linear_mesh(
MeshLib::MeshGenerator::generateLineMesh(3u, 1.));
std::unique_ptr<MeshLib::Mesh> mesh(
MeshLib::createQuadraticOrderMesh(*linear_mesh));
std::unique_ptr<MeshLib::Mesh> mesh(MeshLib::createQuadraticOrderMesh(
*linear_mesh, false /* add centre node */));
auto base_nodes = MeshLib::getBaseNodes(mesh->getElements());
auto baseNodesSubset =
std::make_unique<MeshLib::MeshSubset const>(*mesh, base_nodes);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment