Skip to content
Snippets Groups Projects
Commit bbd6e30b authored by Tom Fischer's avatar Tom Fischer
Browse files

[App/Python] Add bindings to OGSMesh::setCellDataArray

parent e9a88526
No related branches found
No related tags found
No related merge requests found
...@@ -79,3 +79,18 @@ std::vector<double> OGSMesh::getPointDataArray(std::string const& name) const ...@@ -79,3 +79,18 @@ std::vector<double> OGSMesh::getPointDataArray(std::string const& name) const
return data_array; return data_array;
} }
void OGSMesh::setCellDataArray(std::string const& name,
std::vector<double> const& values)
{
auto* pv = MeshLib::getOrCreateMeshProperty<double>(
*_mesh, name, MeshLib::MeshItemType::Cell, 1);
if (pv == nullptr)
{
OGS_FATAL("Couldn't access cell/element property '{}'.", name);
}
for (int i = 0; i < pv->getNumberOfTuples(); ++i)
{
pv->getComponent(i, 0) = values[i];
}
}
...@@ -37,7 +37,9 @@ public: ...@@ -37,7 +37,9 @@ public:
explicit OGSMesh(MeshLib::Mesh* mesh); explicit OGSMesh(MeshLib::Mesh* mesh);
std::vector<double> getPointCoordinates() const; std::vector<double> getPointCoordinates() const;
std::vector<double> getPointDataArray(std::string const& name); std::vector<double> getPointDataArray(std::string const& name) const;
void setCellDataArray(std::string const& name,
std::vector<double> const& values);
private: private:
MeshLib::Mesh* _mesh = nullptr; MeshLib::Mesh* _mesh = nullptr;
......
...@@ -37,6 +37,6 @@ PYBIND11_MODULE(mesh, m) ...@@ -37,6 +37,6 @@ PYBIND11_MODULE(mesh, m)
pybind11::class_<OGSMesh>(m, "OGSMesh") pybind11::class_<OGSMesh>(m, "OGSMesh")
.def("getPointCoordinates", &OGSMesh::getPointCoordinates, .def("getPointCoordinates", &OGSMesh::getPointCoordinates,
"get node coordinates") "get node coordinates")
.def("getPointDataArray", &OGSMesh::getPointDataArray, .def("getPointDataArray", &OGSMesh::getPointDataArray, "get point data")
"get point data"); .def("setCellDataArray", &OGSMesh::setCellDataArray, "set cell data");
} }
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