SERiF 0.0.1a
3+1D Stellar Structure and Evolution
Loading...
Searching...
No Matches
meshIOTest.cpp
Go to the documentation of this file.
1#include <gtest/gtest.h>
2#include "meshIO.h"
3#include <string>
4#include "mfem.hpp"
5
6std::string EXAMPLE_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/assets/dynamic/mesh/sphere.msh";
7
8double ComputeMeshVolume(mfem::Mesh &mesh)
9{
10 double totalVolume = 0.0;
11 for (int i = 0; i < mesh.GetNE(); i++) // Loop over all elements
12 {
13 totalVolume += mesh.GetElementVolume(i);
14 }
15 return totalVolume;
16}
17
18
19class meshIOTest : public ::testing::Test {};
20
21TEST_F(meshIOTest, DefaultConstructor) {
22 EXPECT_NO_THROW(serif::mesh::MeshIO meshIO(EXAMPLE_FILENAME));
23}
24
25TEST_F(meshIOTest, IsLoaded) {
27 EXPECT_EQ(meshIO.IsLoaded(), true);
28}
29
30TEST_F(meshIOTest, GetMesh) {
32 mfem::Mesh& mesh = meshIO.GetMesh();
33 EXPECT_EQ(mesh.GetNE(), 18351);
34 EXPECT_EQ(mesh.GetNV(), 3768);
35 double volume = ComputeMeshVolume(mesh);
36 EXPECT_DOUBLE_EQ(volume, 4.160516453529322);
37}
38
39TEST_F(meshIOTest, LinearRescale) {
41 mfem::Mesh& mesh = meshIO.GetMesh();
42 double volume = ComputeMeshVolume(mesh);
43 EXPECT_DOUBLE_EQ(volume, 520.06455669116463);
44}
Class for handling mesh input/output operations.
Definition meshIO.h:31
bool IsLoaded() const
Check if the mesh is loaded.
Definition meshIO.cpp:74
mfem::Mesh & GetMesh() const noexcept
Get the mesh object.
Definition meshIO.cpp:79
std::string EXAMPLE_FILENAME
TEST_F(meshIOTest, DefaultConstructor)
double ComputeMeshVolume(mfem::Mesh &mesh)
Definition meshIOTest.cpp:8