Skip to content
Snippets Groups Projects
Commit 1194fce2 authored by Christoph Lehmann's avatar Christoph Lehmann Committed by Tom Fischer
Browse files

[App] call code generating Python bindings for STs

parent 2ab2a851
No related branches found
No related tags found
No related merge requests found
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
#include "ogs_embedded_python.h" #include "ogs_embedded_python.h"
#include "ProcessLib/BoundaryCondition/Python/PythonBoundaryConditionModule.h" #include "ProcessLib/BoundaryCondition/Python/PythonBoundaryConditionModule.h"
#include "ProcessLib/SourceTerms/Python/PythonSourceTermModule.h"
PYBIND11_EMBEDDED_MODULE(OpenGeoSys, m) PYBIND11_EMBEDDED_MODULE(OpenGeoSys, m)
{ {
DBUG("Binding Python module OpenGeoSys."); DBUG("Binding Python module OpenGeoSys.");
ProcessLib::pythonBindBoundaryCondition(m); ProcessLib::pythonBindBoundaryCondition(m);
ProcessLib::SourceTerms::Python::pythonBindSourceTerm(m);
} }
#ifndef OGS_BUILD_SHARED_LIBS #ifndef OGS_BUILD_SHARED_LIBS
......
...@@ -56,6 +56,7 @@ std::unique_ptr<SourceTerm> createSourceTerm( ...@@ -56,6 +56,7 @@ std::unique_ptr<SourceTerm> createSourceTerm(
#endif #endif
} }
OGS_FATAL("Unknown source term type: `%s'.", type.c_str()); OGS_FATAL("Unknown source term type: `%s'.", type.c_str());
} }
} // namespace ProcessLib } // namespace ProcessLib
...@@ -31,7 +31,7 @@ std::unique_ptr<SourceTerm> createPythonSourceTerm( ...@@ -31,7 +31,7 @@ std::unique_ptr<SourceTerm> createPythonSourceTerm(
config.checkConfigParameter("type", "Python"); config.checkConfigParameter("type", "Python");
auto const source_term_object = 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"); config.getConfigParameter<std::string>("source_term_object");
//! \ogs_file_param{prj__process_variables__process_variable__source_term__source_term__Python__flush_stdout} //! \ogs_file_param{prj__process_variables__process_variable__source_term__source_term__Python__flush_stdout}
auto const flush_stdout = config.getConfigParameter("flush_stdout", false); auto const flush_stdout = config.getConfigParameter("flush_stdout", false);
...@@ -60,8 +60,8 @@ std::unique_ptr<SourceTerm> createPythonSourceTerm( ...@@ -60,8 +60,8 @@ std::unique_ptr<SourceTerm> createPythonSourceTerm(
dof_table.getNumberOfVariableComponents(variable_id)); dof_table.getNumberOfVariableComponents(variable_id));
} }
// In case of partitioned mesh the source_term could be empty, i.e. there is // In case of partitioned mesh the source_term could be empty, i.e. there is no
// no source_term condition. // source_term condition.
#ifdef USE_PETSC #ifdef USE_PETSC
// This can be extracted to createSourceTerm() but then the config // This can be extracted to createSourceTerm() but then the config
// parameters are not read and will cause an error. // parameters are not read and will cause an error.
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include "NumLib/IndexValueVector.h" #include "NumLib/IndexValueVector.h"
#include "ProcessLib/SourceTerms/SourceTerm.h" #include "ProcessLib/SourceTerms/SourceTerm.h"
#include "PythonSourceTermLocalAssemblerInterface.h"
#include "PythonSourceTermPythonSideInterface.h" #include "PythonSourceTermPythonSideInterface.h"
#include "PythonSourceTermLocalAssemblerInterface.h"
namespace ProcessLib namespace ProcessLib
{ {
......
...@@ -16,6 +16,7 @@ namespace SourceTerms ...@@ -16,6 +16,7 @@ namespace SourceTerms
{ {
namespace Python namespace Python
{ {
class PythonSourceTermLocalAssemblerInterface class PythonSourceTermLocalAssemblerInterface
{ {
public: public:
......
...@@ -34,8 +34,8 @@ public: ...@@ -34,8 +34,8 @@ public:
std::vector<double> const& primary_variables) const override std::vector<double> const& primary_variables) const override
{ {
using Ret = std::pair<double, std::array<double, 3>>; using Ret = std::pair<double, std::array<double, 3>>;
PYBIND11_OVERLOAD(Ret, PythonSourceTermPythonSideInterface, getFlux, t, PYBIND11_OVERLOAD(Ret, PythonSourceTermPythonSideInterface,
x, primary_variables); getFlux, t, x, primary_variables);
} }
}; };
......
...@@ -38,13 +38,12 @@ public: ...@@ -38,13 +38,12 @@ public:
//! Tells if getFlux() has been overridden in the derived class in Python. //! Tells if getFlux() has been overridden in the derived class in Python.
//! //!
//! \pre getFlux() must already have been called once. //! \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; 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 Python
} // namespace SourceTerms } // namespace SourceTerms
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment