Revision 429e2e3a12530fbb37e7285a0323863244596148 authored by Tom Fischer on 07 October 2021, 18:12:56 UTC, committed by Tom Fischer on 07 October 2021, 18:12:56 UTC
Remove Qt dependency from MoveGeometry and TriangulatePolyline See merge request ogs/ogs!3829
TestFEFLOWInterface.cpp
/**
* \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 <string>
#include "Applications/FileIO/FEFLOW/FEFLOWMeshInterface.h"
#include "InfoLib/TestInfo.h"
#include "MeshLib/Elements/Element.h"
#include "MeshLib/Mesh.h"
#include "MeshLib/Properties.h"
TEST(FileIO, TestFEFLOWMeshInterface)
{
std::string const file_name(TestInfoLib::TestInfo::data_path +
"/FileIO/small_cube_hex.fem");
FileIO::FEFLOWMeshInterface feflowIO;
std::unique_ptr<MeshLib::Mesh const> mesh(
feflowIO.readFEFLOWFile(file_name));
ASSERT_TRUE(static_cast<bool>(mesh));
ASSERT_EQ(144u, mesh->getNumberOfNodes());
ASSERT_EQ(75u, mesh->getNumberOfElements());
auto opt_material_ids(
mesh->getProperties().getPropertyVector<int>("MaterialIDs"));
ASSERT_TRUE(static_cast<bool>(opt_material_ids));
ASSERT_EQ(75u, opt_material_ids->size());
MeshLib::Element const* e = mesh->getElement(0);
ASSERT_EQ(MeshLib::CellType::HEX8, e->getCellType());
ASSERT_EQ(1, (*opt_material_ids)[0]);
ASSERT_EQ(0, (*opt_material_ids)[6]);
}
TEST(FileIO, TestFEFLOWReadHexMesh)
{
std::string const fname(TestInfoLib::TestInfo::data_path +
"/FileIO/FEFLOW/hex.fem");
FileIO::FEFLOWMeshInterface feflowIO;
std::unique_ptr<MeshLib::Mesh const> mesh(feflowIO.readFEFLOWFile(fname));
EXPECT_EQ(12, mesh->getNumberOfNodes());
EXPECT_EQ(2, mesh->getNumberOfElements());
for (std::size_t k(0); k < mesh->getNumberOfElements(); ++k)
{
EXPECT_EQ(MeshLib::MeshElemType::HEXAHEDRON,
mesh->getElement(k)->getGeomType());
}
}
TEST(FileIO, TestFEFLOWReadPrismMesh)
{
std::string const fname(TestInfoLib::TestInfo::data_path +
"/FileIO/FEFLOW/prism.fem");
FileIO::FEFLOWMeshInterface feflowIO;
std::unique_ptr<MeshLib::Mesh const> mesh(feflowIO.readFEFLOWFile(fname));
EXPECT_EQ(12, mesh->getNumberOfNodes());
EXPECT_EQ(4, mesh->getNumberOfElements());
for (std::size_t k(0); k < mesh->getNumberOfElements(); ++k)
{
EXPECT_EQ(MeshLib::MeshElemType::PRISM,
mesh->getElement(k)->getGeomType());
}
}
TEST(FileIO, TestFEFLOWReadHexPrismMesh)
{
std::string const fname(TestInfoLib::TestInfo::data_path +
"/FileIO/FEFLOW/hex_prism.fem");
FileIO::FEFLOWMeshInterface feflowIO;
std::unique_ptr<MeshLib::Mesh const> mesh(feflowIO.readFEFLOWFile(fname));
EXPECT_EQ(12, mesh->getNumberOfNodes());
EXPECT_EQ(3, mesh->getNumberOfElements());
for (std::size_t k(0); k < 2; ++k)
{
EXPECT_EQ(MeshLib::MeshElemType::PRISM,
mesh->getElement(k)->getGeomType());
}
EXPECT_EQ(MeshLib::MeshElemType::HEXAHEDRON,
mesh->getElement(2)->getGeomType());
}
TEST(FileIO, TestFEFLOWReadTetMesh)
{
std::string const fname(TestInfoLib::TestInfo::data_path +
"/FileIO/FEFLOW/tet.fem");
FileIO::FEFLOWMeshInterface feflowIO;
std::unique_ptr<MeshLib::Mesh const> mesh(feflowIO.readFEFLOWFile(fname));
EXPECT_EQ(13, mesh->getNumberOfNodes());
EXPECT_EQ(22, mesh->getNumberOfElements());
for (std::size_t k(0); k < mesh->getNumberOfElements(); ++k)
{
EXPECT_EQ(MeshLib::MeshElemType::TETRAHEDRON,
mesh->getElement(k)->getGeomType());
}
}
TEST(FileIO, TestFEFLOWReadPrismTetMesh)
{
std::string const fname(TestInfoLib::TestInfo::data_path +
"/FileIO/FEFLOW/prism_tet.fem");
FileIO::FEFLOWMeshInterface feflowIO;
std::unique_ptr<MeshLib::Mesh const> mesh(feflowIO.readFEFLOWFile(fname));
EXPECT_EQ(16, mesh->getNumberOfNodes());
EXPECT_EQ(20, mesh->getNumberOfElements());
for (std::size_t k(0); k < 4; ++k)
{
EXPECT_EQ(MeshLib::MeshElemType::PRISM,
mesh->getElement(k)->getGeomType());
}
for (std::size_t k(4); k < mesh->getNumberOfElements(); ++k)
{
EXPECT_EQ(MeshLib::MeshElemType::TETRAHEDRON,
mesh->getElement(k)->getGeomType());
}
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...