From 40fda364b6cbdc3c4eeb221d4f0276bfb7df2ce2 Mon Sep 17 00:00:00 2001
From: Lisa Julia Nebel <lisa_julia.nebel@tu-dresden.de>
Date: Thu, 16 Mar 2023 09:59:14 +0100
Subject: [PATCH] Make GFE_ORDER and LFE_ORDER compiler macros and build the
 necessary combinations of cosserat-continuum-Xd-in-Xd

---
 CHANGELOG.md              |  6 ++++++
 src/CMakeLists.txt        | 26 +++++++++++++++++++-------
 src/cosserat-continuum.cc | 21 ++++++++++++++++++---
 3 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f2f6dd8..861e472b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # Master
 
+- Build cosserat-continuum for different combinations of LFE-orders and
+  GFE-orders, the respective program is called
+  cosserat-continuum-Xd-in-Xd-LFE_ORDER-GFE_ORDER
+  TODO: This is now set during compile time, but shall be changed to be
+  set during runtime.
+
 - Do not scale the density functions  with the thickness to avoid confusion
   since some densities need to be scaled and some do not need to be scaled
   with the thickness depending on the dimension of the grid, their direction
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b0b4eeca..e57f4fd6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,14 +22,26 @@ set_property(TARGET "cosserat-continuum-2d-in-2d" APPEND PROPERTY COMPILE_DEFINI
 set(programs cosserat-continuum-2d-in-2d ${programs})
 
 if (dune-foamgrid_FOUND)
-  add_executable("cosserat-continuum-2d-in-3d" cosserat-continuum.cc)
-  set_property(TARGET "cosserat-continuum-2d-in-3d" APPEND PROPERTY COMPILE_DEFINITIONS "GRID_DIM=2; WORLD_DIM=3")
-  set(programs cosserat-continuum-2d-in-3d ${programs})
+  add_executable("cosserat-continuum-2d-in-3d-2-2" cosserat-continuum.cc)
+  set_property(TARGET "cosserat-continuum-2d-in-3d-2-2" APPEND PROPERTY COMPILE_DEFINITIONS "GRID_DIM=2; WORLD_DIM=3; LFE_ORDER=2; GFE_ORDER=2")
+  set(programs cosserat-continuum-2d-in-3d-2-2 ${programs})
+
+  add_executable("cosserat-continuum-2d-in-3d-2-1" cosserat-continuum.cc)
+  set_property(TARGET "cosserat-continuum-2d-in-3d-2-1" APPEND PROPERTY COMPILE_DEFINITIONS "GRID_DIM=2; WORLD_DIM=3; LFE_ORDER=2; GFE_ORDER=1")
+  set(programs cosserat-continuum-2d-in-3d-2-1 ${programs})
+
+  add_executable("cosserat-continuum-2d-in-3d-1-1" cosserat-continuum.cc)
+  set_property(TARGET "cosserat-continuum-2d-in-3d-1-1" APPEND PROPERTY COMPILE_DEFINITIONS "GRID_DIM=2; WORLD_DIM=3; LFE_ORDER=1; GFE_ORDER=1")
+  set(programs cosserat-continuum-2d-in-3d-1-1 ${programs})
 endif()
 
-add_executable("cosserat-continuum-3d-in-3d" cosserat-continuum.cc)
-set_property(TARGET "cosserat-continuum-3d-in-3d" APPEND PROPERTY COMPILE_DEFINITIONS "GRID_DIM=3; WORLD_DIM=3")
-set(programs cosserat-continuum-3d-in-3d ${programs})
+add_executable("cosserat-continuum-3d-in-3d-2-2" cosserat-continuum.cc)
+set_property(TARGET "cosserat-continuum-3d-in-3d-2-2" APPEND PROPERTY COMPILE_DEFINITIONS "GRID_DIM=3; WORLD_DIM=3; LFE_ORDER=2; GFE_ORDER=2")
+set(programs cosserat-continuum-3d-in-3d-2-2 ${programs})
+
+add_executable("cosserat-continuum-3d-in-3d-2-1" cosserat-continuum.cc)
+set_property(TARGET "cosserat-continuum-3d-in-3d-2-1" APPEND PROPERTY COMPILE_DEFINITIONS "GRID_DIM=3; WORLD_DIM=3; LFE_ORDER=2; GFE_ORDER=1")
+set(programs cosserat-continuum-3d-in-3d-2-1 ${programs})
 
 foreach(_program ${programs})
   target_link_dune_default_libraries(${_program})
@@ -40,4 +52,4 @@ foreach(_program ${programs})
     target_link_libraries(${_program} tinyxml2)
   endif()
 #  target_compile_options(${_program} PRIVATE "-fpermissive")
-endforeach()
\ No newline at end of file
+endforeach()
diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc
index 607b1276..23dddb7f 100644
--- a/src/cosserat-continuum.cc
+++ b/src/cosserat-continuum.cc
@@ -1,4 +1,19 @@
-#define MIXED_SPACE 0
+#ifndef LFE_ORDER
+    #define LFE_ORDER 2
+#endif
+
+#ifndef GFE_ORDER
+    #define GFE_ORDER 1
+#endif
+
+#ifndef MIXED_SPACE
+    #if LFE_ORDER != GFE_ORDER
+    #define MIXED_SPACE 1
+    #else
+    #define MIXED_SPACE 0
+    #endif
+#endif
+
 //#define PROJECTED_INTERPOLATION
 
 #include <config.h>
@@ -70,10 +85,10 @@ const int dim = GRID_DIM;
 const int dimworld = WORLD_DIM;
 
 // Order of the approximation space for the displacement
-const int displacementOrder = 2;
+const int displacementOrder = LFE_ORDER;
 
 // Order of the approximation space for the microrotations
-const int rotationOrder = 2;
+const int rotationOrder = GFE_ORDER;
 
 #if !MIXED_SPACE
 static_assert(displacementOrder==rotationOrder, "displacement and rotation order do not match!");
-- 
GitLab