Interface for dolfinx/common
| 48 | |
| 49 | // Interface for dolfinx/common |
| 50 | void common(nb::module_& m) |
| 51 | { |
| 52 | // From dolfinx/common/defines.h |
| 53 | m.attr("git_commit_hash") = dolfinx::git_commit_hash(); |
| 54 | m.attr("has_adios2") = dolfinx::has_adios2(); |
| 55 | m.attr("has_complex_ufcx_kernels") = dolfinx::has_complex_ufcx_kernels(); |
| 56 | m.attr("has_debug") = dolfinx::has_debug(); |
| 57 | m.attr("has_kahip") = dolfinx::has_kahip(); |
| 58 | m.attr("has_parmetis") = dolfinx::has_parmetis(); |
| 59 | m.attr("has_petsc") = dolfinx::has_petsc(); |
| 60 | m.attr("has_petsc4py") = has_petsc4py(); |
| 61 | m.attr("has_ptscotch") = dolfinx::has_ptscotch(); |
| 62 | m.attr("has_superlu_dist") = dolfinx::has_superlu_dist(); |
| 63 | m.attr("has_slepc") = dolfinx::has_slepc(); |
| 64 | m.attr("ufcx_signature") = dolfinx::ufcx_signature(); |
| 65 | m.attr("version") = dolfinx::version(); |
| 66 | |
| 67 | nb::enum_<dolfinx::Table::Reduction>(m, "Reduction") |
| 68 | .value("max", dolfinx::Table::Reduction::max) |
| 69 | .value("min", dolfinx::Table::Reduction::min) |
| 70 | .value("average", dolfinx::Table::Reduction::average); |
| 71 | |
| 72 | auto sc = nb::class_<dolfinx::common::Scatterer<>>(m, "Scatterer") |
| 73 | .def(nb::init<dolfinx::common::IndexMap&, int>(), |
| 74 | nb::arg("index_map"), nb::arg("block_size")); |
| 75 | declare_scatter_functions<std::int64_t>(sc); |
| 76 | declare_scatter_functions<double>(sc); |
| 77 | declare_scatter_functions<float>(sc); |
| 78 | |
| 79 | // dolfinx::common::IndexMap |
| 80 | nb::class_<dolfinx::common::IndexMap>(m, "IndexMap") |
| 81 | .def( |
| 82 | "__init__", |
| 83 | [](dolfinx::common::IndexMap* self, MPICommWrapper comm, |
| 84 | std::int32_t local_size) |
| 85 | { new (self) dolfinx::common::IndexMap(comm.get(), local_size); }, |
| 86 | nb::arg("comm"), nb::arg("local_size")) |
| 87 | .def( |
| 88 | "__init__", |
| 89 | [](dolfinx::common::IndexMap* self, MPICommWrapper comm, |
| 90 | std::int32_t local_size, |
| 91 | nb::ndarray<const std::int64_t, nb::ndim<1>, nb::c_contig> ghosts, |
| 92 | nb::ndarray<const int, nb::ndim<1>, nb::c_contig> ghost_owners, |
| 93 | int tag) |
| 94 | { |
| 95 | new (self) dolfinx::common::IndexMap( |
| 96 | comm.get(), local_size, std::span(ghosts.data(), ghosts.size()), |
| 97 | std::span(ghost_owners.data(), ghost_owners.size()), tag); |
| 98 | }, |
| 99 | nb::arg("comm"), nb::arg("local_size"), nb::arg("ghosts"), |
| 100 | nb::arg("ghost_owners"), nb::arg("tag")) |
| 101 | .def( |
| 102 | "__init__", |
| 103 | [](dolfinx::common::IndexMap* self, MPICommWrapper comm, |
| 104 | std::int32_t local_size, |
| 105 | std::array<nb::ndarray<const int, nb::ndim<1>, nb::c_contig>, 2> |
| 106 | dest_src, |
| 107 | nb::ndarray<const std::int64_t, nb::ndim<1>, nb::c_contig> ghosts, |
no test coverage detected