Revision e4f8d4750fabdc04dc44f48598a6ab25e9f01d83 authored by Tobias Meisel on 05 January 2021, 20:24:18 UTC, committed by Dmitry Yu. Naumov on 27 April 2021, 07:47:51 UTC
1 parent 2950ca3
ogs_embedded_python.cpp
/**
* \copyright
* Copyright (c) 2012-2021, 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 "ogs_embedded_python.h"
#include <pybind11/embed.h>
#include "BaseLib/Logging.h"
#include "ProcessLib/BoundaryCondition/Python/BHEInflowPythonBoundaryConditionModule.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::bheInflowpythonBindBoundaryCondition(m);
ProcessLib::SourceTerms::Python::pythonBindSourceTerm(m);
}
#ifndef OGS_BUILD_SHARED_LIBS
// Hackish trick that hopefully ensures that the linker won't strip the symbol
// pointed to by p from the library being built.
template <typename T>
void mark_used(T p)
{
volatile T vp = p;
vp = vp;
}
#endif // OGS_BUILD_SHARED_LIBS
namespace ApplicationsLib
{
pybind11::scoped_interpreter setupEmbeddedPython()
{
#ifndef OGS_BUILD_SHARED_LIBS
// pybind11_init_impl_OpenGeoSys is the function initializing the embedded
// OpenGeoSys Python module. The name is generated by pybind11. If it is not
// obvious that this symbol is actually used, the linker might remove it
// under certain circumstances.
mark_used(&pybind11_init_impl_OpenGeoSys);
#endif
return pybind11::scoped_interpreter{};
}
} // namespace ApplicationsLib
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...