Revision 8922b830d3464b1b6ac3e906460c1b12f45c543b authored by Dmitri Naumov on 10 October 2021, 10:45:14 UTC, committed by Dmitri Naumov on 10 October 2021, 11:11:53 UTC
1 parent bd05703
TestRemove.cpp
/**
* \file
* \author Karsten Rink
* \date 2013-03-25
* \brief Tests for Duplicate functions
*
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*/
#include <gtest/gtest.h>
#include <memory>
#include "MathLib/MathTools.h"
#include "MeshLib/Elements/Element.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/MeshEditing/RemoveMeshComponents.h"
#include "MeshLib/MeshGenerators/MeshGenerator.h"
#include "MeshLib/MeshQuality/MeshValidation.h"
#include "MeshLib/Node.h"
TEST(MeshLib, RemoveNodes)
{
auto mesh = std::unique_ptr<MeshLib::Mesh>{
MeshLib::MeshGenerator::generateLineMesh(1.0, 9)};
std::vector<std::size_t> removed_node_ids;
for (std::size_t i = 0; i < 5; i++)
{
removed_node_ids.push_back(i);
}
auto new_mesh = std::unique_ptr<MeshLib::Mesh>{
MeshLib::removeNodes(*mesh, removed_node_ids, "")};
ASSERT_EQ(5u, new_mesh->getNumberOfNodes());
ASSERT_EQ(5u, new_mesh->getNumberOfBaseNodes());
ASSERT_EQ(4u, new_mesh->getNumberOfElements());
for (std::size_t i = 0; i < new_mesh->getNumberOfNodes(); i++)
{
ASSERT_TRUE(*mesh->getNode(5 + i) == *new_mesh->getNode(i));
}
}
TEST(MeshLib, RemoveElements)
{
auto mesh = std::unique_ptr<MeshLib::Mesh>{
MeshLib::MeshGenerator::generateLineMesh(1.0, 9)};
std::vector<std::size_t> removed_ele_ids;
for (std::size_t i = 0; i < 5; i++)
{
removed_ele_ids.push_back(i);
}
auto new_mesh = std::unique_ptr<MeshLib::Mesh>{
MeshLib::removeElements(*mesh, removed_ele_ids, "")};
ASSERT_EQ(5u, new_mesh->getNumberOfNodes());
ASSERT_EQ(5u, new_mesh->getNumberOfBaseNodes());
ASSERT_EQ(4u, new_mesh->getNumberOfElements());
for (std::size_t i = 0; i < new_mesh->getNumberOfNodes(); i++)
{
ASSERT_TRUE(*mesh->getNode(5 + i) == *new_mesh->getNode(i));
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...