From 1194fce273aa675a973e967586c691214cf2caa7 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Thu, 4 Oct 2018 14:47:01 +0200 Subject: [PATCH] [App] call code generating Python bindings for STs --- Applications/CLI/ogs_embedded_python.cpp | 2 ++ ProcessLib/SourceTerms/CreateSourceTerm.cpp | 1 + ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp | 6 +++--- ProcessLib/SourceTerms/Python/PythonSourceTerm.h | 2 +- .../Python/PythonSourceTermLocalAssemblerInterface.h | 1 + ProcessLib/SourceTerms/Python/PythonSourceTermModule.cpp | 4 ++-- .../Python/PythonSourceTermPythonSideInterface.h | 9 ++++----- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Applications/CLI/ogs_embedded_python.cpp b/Applications/CLI/ogs_embedded_python.cpp index 39b6e3e2818..b925f02e65e 100644 --- a/Applications/CLI/ogs_embedded_python.cpp +++ b/Applications/CLI/ogs_embedded_python.cpp @@ -13,12 +13,14 @@ #include "ogs_embedded_python.h" #include "ProcessLib/BoundaryCondition/Python/PythonBoundaryConditionModule.h" +#include "ProcessLib/SourceTerms/Python/PythonSourceTermModule.h" PYBIND11_EMBEDDED_MODULE(OpenGeoSys, m) { DBUG("Binding Python module OpenGeoSys."); ProcessLib::pythonBindBoundaryCondition(m); + ProcessLib::SourceTerms::Python::pythonBindSourceTerm(m); } #ifndef OGS_BUILD_SHARED_LIBS diff --git a/ProcessLib/SourceTerms/CreateSourceTerm.cpp b/ProcessLib/SourceTerms/CreateSourceTerm.cpp index 820dff5831b..b33cd640db6 100644 --- a/ProcessLib/SourceTerms/CreateSourceTerm.cpp +++ b/ProcessLib/SourceTerms/CreateSourceTerm.cpp @@ -56,6 +56,7 @@ std::unique_ptr<SourceTerm> createSourceTerm( #endif } + OGS_FATAL("Unknown source term type: `%s'.", type.c_str()); } } // namespace ProcessLib diff --git a/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp b/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp index 491107abba3..896270d789a 100644 --- a/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp +++ b/ProcessLib/SourceTerms/Python/CreatePythonSourceTerm.cpp @@ -31,7 +31,7 @@ std::unique_ptr<SourceTerm> createPythonSourceTerm( config.checkConfigParameter("type", "Python"); auto const source_term_object = - //! \ogs_file_param{prj__process_variables__process_variable__source_term__source_term__Python__source_term_object} + //! \ogs_file_param{prj__process_variables__process_variable__source_term__source_term__Python__source_term_object} config.getConfigParameter<std::string>("source_term_object"); //! \ogs_file_param{prj__process_variables__process_variable__source_term__source_term__Python__flush_stdout} auto const flush_stdout = config.getConfigParameter("flush_stdout", false); @@ -60,8 +60,8 @@ std::unique_ptr<SourceTerm> createPythonSourceTerm( dof_table.getNumberOfVariableComponents(variable_id)); } - // In case of partitioned mesh the source_term could be empty, i.e. there is - // no source_term condition. + // In case of partitioned mesh the source_term could be empty, i.e. there is no + // source_term condition. #ifdef USE_PETSC // This can be extracted to createSourceTerm() but then the config // parameters are not read and will cause an error. diff --git a/ProcessLib/SourceTerms/Python/PythonSourceTerm.h b/ProcessLib/SourceTerms/Python/PythonSourceTerm.h index 512c260d93f..931a5fca0a3 100644 --- a/ProcessLib/SourceTerms/Python/PythonSourceTerm.h +++ b/ProcessLib/SourceTerms/Python/PythonSourceTerm.h @@ -13,8 +13,8 @@ #include "NumLib/IndexValueVector.h" #include "ProcessLib/SourceTerms/SourceTerm.h" -#include "PythonSourceTermLocalAssemblerInterface.h" #include "PythonSourceTermPythonSideInterface.h" +#include "PythonSourceTermLocalAssemblerInterface.h" namespace ProcessLib { diff --git a/ProcessLib/SourceTerms/Python/PythonSourceTermLocalAssemblerInterface.h b/ProcessLib/SourceTerms/Python/PythonSourceTermLocalAssemblerInterface.h index c006156afab..f970bb39e4c 100644 --- a/ProcessLib/SourceTerms/Python/PythonSourceTermLocalAssemblerInterface.h +++ b/ProcessLib/SourceTerms/Python/PythonSourceTermLocalAssemblerInterface.h @@ -16,6 +16,7 @@ namespace SourceTerms { namespace Python { + class PythonSourceTermLocalAssemblerInterface { public: diff --git a/ProcessLib/SourceTerms/Python/PythonSourceTermModule.cpp b/ProcessLib/SourceTerms/Python/PythonSourceTermModule.cpp index d018837ad69..822c48fcb1e 100644 --- a/ProcessLib/SourceTerms/Python/PythonSourceTermModule.cpp +++ b/ProcessLib/SourceTerms/Python/PythonSourceTermModule.cpp @@ -34,8 +34,8 @@ public: std::vector<double> const& primary_variables) const override { using Ret = std::pair<double, std::array<double, 3>>; - PYBIND11_OVERLOAD(Ret, PythonSourceTermPythonSideInterface, getFlux, t, - x, primary_variables); + PYBIND11_OVERLOAD(Ret, PythonSourceTermPythonSideInterface, + getFlux, t, x, primary_variables); } }; diff --git a/ProcessLib/SourceTerms/Python/PythonSourceTermPythonSideInterface.h b/ProcessLib/SourceTerms/Python/PythonSourceTermPythonSideInterface.h index e2bf933785b..754dedfe843 100644 --- a/ProcessLib/SourceTerms/Python/PythonSourceTermPythonSideInterface.h +++ b/ProcessLib/SourceTerms/Python/PythonSourceTermPythonSideInterface.h @@ -38,13 +38,12 @@ public: //! Tells if getFlux() has been overridden in the derived class in Python. //! //! \pre getFlux() must already have been called once. - bool isOverriddenGetFlux() const { return _overridden_get_flux; } + bool isOverriddenGetFlux() const + { + return _overridden_get_flux; + } virtual ~PythonSourceTermPythonSideInterface() = default; - -private: - //! Tells if getFlux() has been overridden in the derived class in Python. - mutable bool _overridden_get_flux = true; }; } // namespace Python } // namespace SourceTerms -- GitLab