diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc index e2cfb0de190ade4e94b2e2101ea4d027b25755a3..3e5666ae9a5fc498aa0cb19eab33654eb2476db7 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;