From 5ffe154d442fefe91e100b7e3eceaf4e682add29 Mon Sep 17 00:00:00 2001
From: "jonathan.froehlich" <jonathan.froehlich@kit.edu>
Date: Sun, 5 Dec 2021 09:14:54 +0100
Subject: [PATCH] Added volume tests

---
 cardmech/test/CMakeLists.txt                  |  2 +
 cardmech/test/TestVolumeCalculation.cpp       | 45 +++++++++++++++++++
 .../test/elasticity/TestVolumePenalty.cpp     |  5 +++
 3 files changed, 52 insertions(+)
 create mode 100644 cardmech/test/TestVolumeCalculation.cpp

diff --git a/cardmech/test/CMakeLists.txt b/cardmech/test/CMakeLists.txt
index 8829a17bc..2db9d729e 100644
--- a/cardmech/test/CMakeLists.txt
+++ b/cardmech/test/CMakeLists.txt
@@ -1,3 +1,5 @@
+add_mpp_test(TestVolumeCalculation CARDMECH_LIBRARIES)
+
 include_directories(cellmodels)
 add_subdirectory(cellmodels)
 
diff --git a/cardmech/test/TestVolumeCalculation.cpp b/cardmech/test/TestVolumeCalculation.cpp
new file mode 100644
index 000000000..68ea2fbe2
--- /dev/null
+++ b/cardmech/test/TestVolumeCalculation.cpp
@@ -0,0 +1,45 @@
+#include "TestEnvironment.hpp"
+#include "Celltype.hpp"
+#include "CardiacData.hpp"
+
+struct CellParam {
+  CELLTYPE type;
+  std::vector<Point> corners;
+  double volume;
+};
+
+
+class CellVolumeTest : public TestWithParam<CellParam> {
+protected:
+  double volume;
+public:
+  CellVolumeTest() = default;
+};
+
+
+TEST_P(CellVolumeTest, Volumes) {
+  ASSERT_DOUBLE_EQ(Volume(GetParam().type, GetParam().corners), GetParam().volume);
+}
+
+INSTANTIATE_TEST_SUITE_P(TestVolumeFunctions, CellVolumeTest, Values(
+    CellParam{TRIANGLE, {Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0)}, 0.5},
+    CellParam{TRIANGLE, {Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(0.5, 1.0, 0.0)}, 0.5},
+    CellParam{TRIANGLE, {Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(0.0, 2.0, 0.0)}, 1.0},
+    CellParam{TRIANGLE, {Point(0.0, 0.0, 0.0), Point(2.0, 0.0, 0.0), Point(1.0, 1.0, 0.0)}, 1.0},
+    CellParam{QUADRILATERAL, {Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0),
+                              Point(0.0, 1.0, 0.0)}, 1.0},
+    CellParam{QUADRILATERAL, {Point(0.0, 0.0, 0.0), Point(4.0, 0.0, 0.0), Point(3.0, 1.0, 0.0),
+                              Point(1.0, 1.0, 0.0)}, 3.0},
+    CellParam{TETRAHEDRON, {Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(0.0, 1.0, 0.0),
+                            Point(0.0, 0.0, 1.0)}, 1.0 / 6.0},
+    CellParam{TETRAHEDRON, {Point(0.0, 0.0, 0.0), Point(2.0, 0.0, 0.0), Point(1.0, 1.0, 0.0),
+                            Point(0.0, 1.0, 3.0)}, 1.0},
+    CellParam{HEXAHEDRON, {Point(0.0, 0.0, 0.0), Point(1.0, 0.0, 0.0), Point(1.0, 1.0, 0.0),
+                           Point(0.0, 1.0, 0.0), Point(0.0, 0.0, 1.0), Point(1.0, 0.0, 1.0),
+                           Point(1.0, 1.0, 1.0), Point(0.0, 1.0, 1.0)}, 1.0}
+));
+
+int main(int argc, char **argv) {
+  MppTest mppTest = MppTestBuilder(argc, argv).WithScreenLogging();
+  return mppTest.RUN_ALL_MPP_TESTS();
+}
\ No newline at end of file
diff --git a/cardmech/test/elasticity/TestVolumePenalty.cpp b/cardmech/test/elasticity/TestVolumePenalty.cpp
index a9280a597..b474b38bb 100644
--- a/cardmech/test/elasticity/TestVolumePenalty.cpp
+++ b/cardmech/test/elasticity/TestVolumePenalty.cpp
@@ -68,6 +68,11 @@ TEST_P(VolumePenaltyTest, Consistency) {
 
 }
 
+
+TEST_P(VolumePenaltyTest, Compressibility) {
+  mout << "Can't do multiple runs with different volume penalties." << endl;
+}
+
 INSTANTIATE_TEST_SUITE_P(TestVolumeFunctions, VolumePenaltyTest, Values(
     "None", "Ciarlet", "Logarithmic"
 ));
-- 
GitLab