OGS
ogs_mesh_python_module.cpp File Reference
#include <pybind11/eigen.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <algorithm>
#include <numeric>
#include "BaseLib/ExportSymbol.h"
#include "BaseLib/Logging.h"
#include "InfoLib/GitInfo.h"
#include "OGSMesh.h"
Include dependency graph for ogs_mesh_python_module.cpp:

Go to the source code of this file.

Functions

 PYBIND11_MODULE (OGSMesh, m)
 python module name is OpenGeoSys

Function Documentation

◆ PYBIND11_MODULE()

PYBIND11_MODULE ( OGSMesh ,
m  )

python module name is OpenGeoSys

Definition at line 17 of file ogs_mesh_python_module.cpp.

18{
19#ifndef NDEBUG
21#else // NDEBUG
23#endif // NDEBUG
24 m.attr("__name__") = "ogs.mesh";
25 m.doc() = "pybind11 ogs mesh example plugin";
26
27 pybind11::enum_<MeshLib::MeshItemType>(m, "MeshItemType")
28 .value("Node", MeshLib::MeshItemType::Node)
29 .value("Edge", MeshLib::MeshItemType::Edge)
30 .value("Face", MeshLib::MeshItemType::Face)
31 .value("Cell", MeshLib::MeshItemType::Cell)
32 .value("IntegrationPoint", MeshLib::MeshItemType::IntegrationPoint)
33 .export_values()
34 // Add nice string conversion
35 .def("__str__",
36 [](MeshLib::MeshItemType t) { return std::string(toString(t)); });
37
38 pybind11::class_<OGSMesh>(m, "OGSMesh")
39 .def("points", &OGSMesh::getPointCoordinates, "get node coordinates")
40 .def("cells", &OGSMesh::getCells, pybind11::return_value_policy::copy,
41 "get cells")
42 .def("data_array_names", &OGSMesh::getDataArrayNames,
43 "get names of all data arrays / property "
44 "vectors stored in the mesh")
45 .def("mesh_item_type", &OGSMesh::meshItemType, pybind11::arg("name"),
46 "returns MeshItemType")
47 .def("data_array", &OGSMesh::dataArray_dispatch,
48 pybind11::return_value_policy::reference, pybind11::arg("name"),
49 pybind11::arg("dtype"),
50 "Access a data array / property vector (accesses OGS memory "
51 "directly using numpy array with appropriate shape)");
52}
MeshLib::MeshItemType meshItemType(std::string_view const name) const
Definition OGSMesh.cpp:48
std::vector< double > getPointCoordinates() const
Definition OGSMesh.cpp:23
pybind11::object dataArray_dispatch(std::string const &name, std::string const &dtype)
Definition OGSMesh.h:109
std::vector< std::string > getDataArrayNames() const
Definition OGSMesh.cpp:43
std::pair< std::vector< int >, std::vector< int > > getCells() const
Definition OGSMesh.cpp:29
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:56
const char * toString(mgis::behaviour::Behaviour::Kinematic kin)

References MeshLib::Cell, OGSMesh::dataArray_dispatch(), MeshLib::Edge, MeshLib::Face, OGSMesh::getCells(), OGSMesh::getDataArrayNames(), OGSMesh::getPointCoordinates(), BaseLib::initOGSLogger(), MeshLib::IntegrationPoint, OGSMesh::meshItemType(), and MeshLib::Node.