Skip to content

Commit

Permalink
Expose set original cell index to python (#3504)
Browse files Browse the repository at this point in the history
* Expose set original cell index to python

* Create read-write property
  • Loading branch information
jorgensd authored Nov 12, 2024
1 parent c80ea5f commit f629d4d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions python/dolfinx/wrappers/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ void mesh(nb::module_& m)
nb::rv_policy::reference_internal)
.def_prop_ro("dim", &dolfinx::mesh::Topology::dim,
"Topological dimension")
.def_prop_ro(
.def_prop_rw(
"original_cell_index",
[](const dolfinx::mesh::Topology& self)
{
Expand All @@ -623,7 +623,16 @@ void mesh(nb::module_& m)
return nb::ndarray<const std::int64_t, nb::numpy>(idx[0].data(),
{idx[0].size()});
},
nb::rv_policy::reference_internal)
[](dolfinx::mesh::Topology& self,
const nb::ndarray<const std::int64_t, nb::ndim<1>, nb::c_contig>&
original_cell_indices)
{
self.original_cell_index.resize(1);
self.original_cell_index[0].assign(
original_cell_indices.data(),
original_cell_indices.data() + original_cell_indices.size());
},
nb::arg("original_cell_indices"))
.def("connectivity",
nb::overload_cast<int, int>(&dolfinx::mesh::Topology::connectivity,
nb::const_),
Expand Down

0 comments on commit f629d4d

Please sign in to comment.