Skip to content

Commit 860219f

Browse files
committed
Merge branch 'develop' of https://github.com/febiosoftware/FEBioStudio into develop
2 parents 505234d + e559655 commit 860219f

7 files changed

Lines changed: 358 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ if(${SET_DEVCOMMIT} AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
432432
endif()
433433
endif()
434434

435-
436435
##### Link Libraries #####
437436

438437
# Link the FEBio libraries
@@ -469,7 +468,6 @@ if(WIN32)
469468
elseif(APPLE)
470469
else()
471470
target_link_libraries(FEBioStudio -static-libstdc++ -static-libgcc)
472-
473471
target_link_libraries(FEBioStudio -Wl,--allow-shlib-undefined -Wl,--start-group)
474472
endif()
475473

@@ -665,3 +663,57 @@ if(BUILD_UPDATER)
665663

666664
target_link_libraries(FEBioStudioUpdater Qt6::Widgets Qt6::Network ${LIBZIP_LIB})
667665
endif()
666+
667+
##### Test Suite #####
668+
option(BUILD_TESTS "Build test suite" OFF)
669+
if(BUILD_TESTS)
670+
find_package(GTest CONFIG REQUIRED)
671+
672+
enable_testing()
673+
674+
add_executable(fbs-test-suite
675+
tests/fbs-test-suite.cpp
676+
tests/primitive_tests.cpp
677+
tests/multiblock_tests.cpp
678+
)
679+
680+
if(NOT WIN32 AND NOT APPLE)
681+
target_link_libraries(fbs-test-suite PRIVATE -static-libstdc++ -static-libgcc)
682+
target_link_libraries(fbs-test-suite PRIVATE -Wl,--allow-shlib-undefined -Wl,--start-group)
683+
endif()
684+
685+
target_link_libraries(fbs-test-suite
686+
PRIVATE
687+
GTest::gtest
688+
FSCore FEMLib FEBioLink GeomLib GLLib MeshLib MeshTools
689+
FEBio::FEBioXML FEBio::FEBioPlot FEBio::FEAMR
690+
)
691+
692+
if(UNIX)
693+
if(${USE_MKL_OMP})
694+
target_link_libraries(fbs-test-suite PRIVATE ${MKL_OMP})
695+
else()
696+
target_link_libraries(fbs-test-suite PRIVATE ${OpenMP_C_LIBRARIES})
697+
endif()
698+
endif()
699+
700+
if(USE_MMG)
701+
target_link_libraries(fbs-test-suite PRIVATE ${MMG_LIBS})
702+
endif()
703+
704+
if(USE_TETGEN)
705+
target_link_libraries(fbs-test-suite PRIVATE ${TETGEN_LIB})
706+
endif()
707+
708+
if(CAD_FEATURES)
709+
target_link_libraries(fbs-test-suite PRIVATE ${NETGEN_LIBS})
710+
target_link_libraries(fbs-test-suite PRIVATE ${OCCT_LIBS})
711+
endif()
712+
713+
if(NOT WIN32 AND NOT APPLE)
714+
target_link_libraries(fbs-test-suite PRIVATE -Wl,--end-group)
715+
endif()
716+
717+
include(GoogleTest)
718+
gtest_discover_tests(fbs-test-suite)
719+
endif()

tests/fbs-test-suite.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <gtest/gtest.h>
2+
#include <MeshLib/FSElementLibrary.h>
3+
4+
int main(int argc, char** argv)
5+
{
6+
FSElementLibrary::InitLibrary();
7+
8+
::testing::InitGoogleTest(&argc, argv);
9+
return RUN_ALL_TESTS();
10+
}

tests/meshing_tests.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <gtest/gtest.h>
2+
#include <GeomLib/GPrimitive.h>
3+
#include <MeshLib/FSMesh.h>
4+
#include <MeshTools/FEBox.h>
5+
#include "tools.h"
6+
7+
TEST(MeshingTests, BoxMesh)
8+
{
9+
GBox o;
10+
FEBoxMesher* mesher = dynamic_cast<FEBoxMesher*>(o.GetFEMesher());
11+
ASSERT_NE(mesher, nullptr);
12+
mesher->SetResolution(5, 5, 5);
13+
14+
FSMesh* m = o.BuildMesh();
15+
EXPECT_NE(m, nullptr);
16+
EXPECT_MESH_TOPO(*m, 216, 150, 125);
17+
}

tests/modifier_tests.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <gtest/gtest.h>
2+
#include <GeomLib/GPrimitive.h>
3+
#include "tools.h"
4+
5+
TEST(ModifierTests, WeldObjects)
6+
{
7+
GBox o1;
8+
GBox o2;
9+
Transform& T = o2.GetTransform();
10+
T.Translate(vec3d(1, 0, 0));
11+
12+
GMultiBox mb1(&o1);
13+
GMultiBox mb2(&o2);
14+
15+
mb1.Merge(mb2);
16+
17+
// Check the properties of the welded object
18+
EXPECT_TOPO(mb1, 12, 20, 11, 2);
19+
}

tests/multiblock_tests.cpp

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#include <gtest/gtest.h>
2+
#include <GeomLib/GPrimitive.h>
3+
#include <GeomLib/GMultiBox.h>
4+
#include "tools.h"
5+
6+
TEST(MultiBlockTests, CreateMultiBoxFromBox)
7+
{
8+
GBox o;
9+
GMultiBox mb(&o);
10+
EXPECT_TOPO(mb, 8, 12, 6, 1);
11+
}
12+
13+
TEST(MultiBlockTests, CreateMultiBoxFromCylinder)
14+
{
15+
GCylinder o;
16+
GMultiBox mb(&o);
17+
EXPECT_TOPO(mb, 34, 73, 52, 12);
18+
}
19+
20+
21+
TEST(MultiBlockTests, CreateMultiBoxFromTube)
22+
{
23+
GTube o;
24+
GMultiBox mb(&o);
25+
EXPECT_TOPO(mb, 16, 32, 20, 4);
26+
}
27+
28+
TEST(MultiBlockTests, CreateMultiBoxFromSphere)
29+
{
30+
GSphere o;
31+
GMultiBox mb(&o);
32+
EXPECT_TOPO(mb, 53, 128, 108, 32);
33+
}
34+
35+
TEST(MultiBlockTests, CreateMultiBoxFromCone)
36+
{
37+
GCone o;
38+
GMultiBox mb(&o);
39+
EXPECT_TOPO(mb, 34, 73, 52, 12);
40+
}
41+
42+
//TEST(MultiBlockTests, CreateMultiBoxFromTruncatedEllipsoid)
43+
//{
44+
// GTruncatedEllipsoid o;
45+
// GMultiBox mb(&o);
46+
// EXPECT_TOPO(12, 20, 12, 1);
47+
//}
48+
49+
TEST(MultiBlockTests, CreateMultiBoxFromTorus)
50+
{
51+
GTorus o;
52+
GMultiBox mb(&o);
53+
EXPECT_TOPO(mb, 68, 180, 160, 48);
54+
}
55+
56+
//TEST(MultiBlockTests, CreateMultiBoxFromSlice)
57+
//{
58+
// GSlice o;
59+
// GMultiBox mb(&o);
60+
// EXPECT_TOPO(mb, 6, 9, 5, 1);
61+
//}
62+
63+
TEST(MultiBlockTests, CreateMultiBoxFromSolidArc)
64+
{
65+
GSolidArc o;
66+
GMultiBox mb(&o);
67+
EXPECT_TOPO(mb, 8, 12, 6, 1);
68+
}
69+
70+
TEST(MultiBlockTests, CreateMultiBoxFromDogBone)
71+
{
72+
GQuartDogBone o;
73+
GMultiBox mb(&o);
74+
EXPECT_TOPO(mb, 28, 49, 30, 6);
75+
}
76+
77+
TEST(MultiBlockTests, CreateMultiBoxFromCylinderInBox)
78+
{
79+
GCylinderInBox o;
80+
GMultiBox mb(&o);
81+
EXPECT_TOPO(mb, 18, 32, 20, 4);
82+
}
83+
84+
TEST(MultiBlockTests, CreateMultiBoxFromSphereInBox)
85+
{
86+
GSphereInBox o;
87+
GMultiBox mb(&o);
88+
EXPECT_TOPO(mb, 53, 122, 96, 24);
89+
}
90+
91+
TEST(MultiBlockTests, CreateMultiBoxFromHollowSphere)
92+
{
93+
GHollowSphere o;
94+
GMultiBox mb(&o);
95+
EXPECT_TOPO(mb, 53, 122, 96, 24);
96+
}
97+
98+
TEST(MultiBlockTests, CreateMultiBoxFromBoxInBox)
99+
{
100+
GBoxInBox o;
101+
GMultiBox mb(&o);
102+
EXPECT_TOPO(mb, 16, 32, 24, 6);
103+
}

tests/primitive_tests.cpp

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#include <gtest/gtest.h>
2+
#include <GeomLib/GPrimitive.h>
3+
#include "tools.h"
4+
5+
TEST(PrimitiveTests, CreateBox)
6+
{
7+
GBox o;
8+
EXPECT_NO_THROW(o.Update());
9+
EXPECT_TOPO(o, 8, 12, 6, 1);
10+
}
11+
12+
TEST(PrimitiveTests, CreateCylinder)
13+
{
14+
GCylinder o;
15+
EXPECT_NO_THROW(o.Update());
16+
EXPECT_TOPO(o, 10, 12, 6, 1);
17+
}
18+
19+
TEST(PrimitiveTests, CreateTube)
20+
{
21+
GTube o;
22+
EXPECT_NO_THROW(o.Update());
23+
EXPECT_TOPO(o, 18, 32, 16, 1);
24+
}
25+
26+
TEST(PrimitiveTests, CreateSphere)
27+
{
28+
GSphere o;
29+
EXPECT_NO_THROW(o.Update());
30+
EXPECT_TOPO(o, 6, 12, 8, 1);
31+
}
32+
33+
TEST(PrimitiveTests, CreateCone)
34+
{
35+
GCone o;
36+
EXPECT_NO_THROW(o.Update());
37+
EXPECT_TOPO(o, 8, 12, 6, 1);
38+
}
39+
40+
TEST(PrimitiveTests, CreateTruncatedEllipsoid)
41+
{
42+
GTruncatedEllipsoid o;
43+
EXPECT_NO_THROW(o.Update());
44+
EXPECT_TOPO(o, 10, 20, 12, 1);
45+
}
46+
47+
TEST(PrimitiveTests, CreateTorus)
48+
{
49+
GTorus o;
50+
EXPECT_NO_THROW(o.Update());
51+
EXPECT_TOPO(o, 20, 32, 16, 1);
52+
}
53+
54+
TEST(PrimitiveTests, CreateSlice)
55+
{
56+
GSlice o;
57+
EXPECT_NO_THROW(o.Update());
58+
EXPECT_TOPO(o, 6, 9, 5, 1);
59+
}
60+
61+
TEST(PrimitiveTests, CreateSolidArc)
62+
{
63+
GSolidArc o;
64+
EXPECT_NO_THROW(o.Update());
65+
EXPECT_TOPO(o, 10, 12, 6, 1);
66+
}
67+
68+
TEST(PrimitiveTests, CreateHexagon)
69+
{
70+
GHexagon o;
71+
EXPECT_NO_THROW(o.Update());
72+
EXPECT_TOPO(o, 12, 18, 8, 1);
73+
}
74+
75+
TEST(PrimitiveTests, CreateDogBone)
76+
{
77+
GQuartDogBone o;
78+
EXPECT_NO_THROW(o.Update());
79+
EXPECT_TOPO(o, 16, 21, 9, 1);
80+
}
81+
82+
TEST(PrimitiveTests, CreateCylinderInBox)
83+
{
84+
GCylinderInBox o;
85+
EXPECT_NO_THROW(o.Update());
86+
EXPECT_TOPO(o, 18, 32, 16, 1);
87+
}
88+
89+
TEST(PrimitiveTests, CreateSphereInBox)
90+
{
91+
GSphereInBox o;
92+
EXPECT_NO_THROW(o.Update());
93+
EXPECT_TOPO(o, 16, 24, 12, 1);
94+
}
95+
96+
TEST(PrimitiveTests, CreateHollowSphere)
97+
{
98+
GHollowSphere o;
99+
EXPECT_NO_THROW(o.Update());
100+
EXPECT_TOPO(o, 12, 24, 16, 1);
101+
}
102+
103+
TEST(PrimitiveTests, CreateBoxInBox)
104+
{
105+
GBoxInBox o;
106+
EXPECT_NO_THROW(o.Update());
107+
EXPECT_TOPO(o, 16, 24, 12, 1);
108+
}
109+
110+
TEST(PrimitiveTests, CreateThinTube)
111+
{
112+
GThinTube o;
113+
EXPECT_NO_THROW(o.Update());
114+
EXPECT_TOPO(o, 10, 12, 4, 1);
115+
}
116+
117+
TEST(PrimitiveTests, CreatePatch)
118+
{
119+
GPatch o;
120+
EXPECT_NO_THROW(o.Update());
121+
EXPECT_TOPO(o, 4, 4, 1, 1);
122+
}
123+
124+
TEST(PrimitiveTests, CreateDisc)
125+
{
126+
GDisc o;
127+
EXPECT_NO_THROW(o.Update());
128+
EXPECT_TOPO(o, 5, 8, 4, 1);
129+
}
130+
131+
TEST(PrimitiveTests, CreateRing)
132+
{
133+
GRing o;
134+
EXPECT_NO_THROW(o.Update());
135+
EXPECT_TOPO(o, 9, 12, 4, 1);
136+
}

tests/tools.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
#include <gtest/gtest.h>
3+
#include <GeomLib/GObject.h>
4+
#include <MeshLib/FSMesh.h>
5+
6+
inline void EXPECT_TOPO(const GObject& mb, int nodes, int edges, int faces, int parts)
7+
{
8+
EXPECT_EQ(mb.Nodes(), nodes);
9+
EXPECT_EQ(mb.Edges(), edges);
10+
EXPECT_EQ(mb.Faces(), faces);
11+
EXPECT_EQ(mb.Parts(), parts);
12+
}
13+
14+
inline void EXPECT_MESH_TOPO(const FSMesh& m, int nodes, int faces, int elems)
15+
{
16+
EXPECT_EQ(m.Nodes(), nodes);
17+
EXPECT_EQ(m.Faces(), faces);
18+
EXPECT_EQ(m.Elements(), elems);
19+
}

0 commit comments

Comments
 (0)