From 83a7a4f44e5ec4e4249b2e09aeb9dbfbf2fe7a54 Mon Sep 17 00:00:00 2001
From: Lisa Julia Nebel <lisa_julia.nebel@tu-dresden.de>
Date: Mon, 23 Jan 2023 14:27:41 +0100
Subject: [PATCH] Instead of loading the volume load as a fixed (x,y,z) vector,
 load it as a space-dependent Python function

---
 src/cosserat-continuum.cc | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc
index e2cfb0de..3e5666ae 100644
--- a/src/cosserat-continuum.cc
+++ b/src/cosserat-continuum.cc
@@ -403,15 +403,14 @@ int main (int argc, char *argv[]) try
       return nV;
     };
 
-    FieldVector<double,3> volumeLoadValues {0,0,0};
-    if (parameterSet.hasKey("volumeLoad"))
-        volumeLoadValues = parameterSet.get<FieldVector<double,3> >("volumeLoad");
-
-    auto volumeLoad = [&]( FieldVector<double,dimworld>) {
-      auto vL = volumeLoadValues;
-      vL *= (-homotopyParameter);
-      return vL;
-    };
+    Python::Reference volumeLoadClass = Python::import(parameterSet.get<std::string>("volumeLoadPythonFunction", "zero-volume-load"));
+    Python::Callable volumeLoadCallable = volumeLoadClass.get("VolumeLoad");
+
+    // Call a constructor
+    Python::Reference volumeLoadPythonObject = volumeLoadCallable(homotopyParameter);
+
+    // Extract object member functions as Dune functions
+    auto volumeLoad = Python::make_function<FieldVector<double,3> > (volumeLoadPythonObject.get("volumeLoad"));
 
     if (mpiHelper.rank() == 0) {
         std::cout << "Material parameters:" << std::endl;
-- 
GitLab