From 44bea8ef1c5fa3840868b15dbba68c4ef71b272f Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Mon, 17 Oct 2022 13:02:24 +0200
Subject: [PATCH] [App] Added ogs.callbacks Python module

... currently contains Python BCs and STs
---
 Applications/Python/CMakeLists.txt            |  1 +
 .../Python/ogs.callbacks/CMakeLists.txt       | 18 +++++++++++++++
 .../ogs.callbacks/ogs_callbacks_module.cpp    | 22 +++++++++++++++++++
 3 files changed, 41 insertions(+)
 create mode 100644 Applications/Python/ogs.callbacks/CMakeLists.txt
 create mode 100644 Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp

diff --git a/Applications/Python/CMakeLists.txt b/Applications/Python/CMakeLists.txt
index 667d1aff703..0d09ceb00e7 100644
--- a/Applications/Python/CMakeLists.txt
+++ b/Applications/Python/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory(ogs.simulator)
+add_subdirectory(ogs.callbacks)
diff --git a/Applications/Python/ogs.callbacks/CMakeLists.txt b/Applications/Python/ogs.callbacks/CMakeLists.txt
new file mode 100644
index 00000000000..6b81612a5a8
--- /dev/null
+++ b/Applications/Python/ogs.callbacks/CMakeLists.txt
@@ -0,0 +1,18 @@
+pybind11_add_module(
+    callbacks MODULE ogs_callbacks_module.cpp
+)
+
+# lld linker strips out PyInit_OpenGeoSys symbol. Use standard linker.
+get_target_property(_link_options callbacks LINK_OPTIONS)
+if(_link_options)
+    list(REMOVE_ITEM _link_options -fuse-ld=lld)
+    set_target_properties(callbacks PROPERTIES LINK_OPTIONS "${_link_options}")
+endif()
+
+target_link_libraries(
+    callbacks
+    PRIVATE ProcessLibBoundaryConditionAndSourceTermPythonModule
+)
+
+# Install into root dir (in Python module, enables 'import ogs.callbacks')
+install(TARGETS callbacks LIBRARY DESTINATION .)
diff --git a/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp b/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp
new file mode 100644
index 00000000000..4fe341651a8
--- /dev/null
+++ b/Applications/Python/ogs.callbacks/ogs_callbacks_module.cpp
@@ -0,0 +1,22 @@
+/**
+ * \copyright
+ * Copyright (c) 2012-2022, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+
+#include <pybind11/pybind11.h>
+
+#include "ProcessLib/BoundaryConditionAndSourceTerm/Python/BHEInflowPythonBoundaryConditionModule.h"
+#include "ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonBoundaryConditionModule.h"
+#include "ProcessLib/BoundaryConditionAndSourceTerm/Python/PythonSourceTermModule.h"
+
+PYBIND11_MODULE(callbacks, m)
+{
+    m.attr("__name__") = "ogs.callbacks";
+    ProcessLib::pythonBindBoundaryCondition(m);
+    ProcessLib::bheInflowpythonBindBoundaryCondition(m);
+    ProcessLib::SourceTerms::Python::pythonBindSourceTerm(m);
+}
-- 
GitLab