From 69d222a7637f122740f6f7ff4876e1ab7a998374 Mon Sep 17 00:00:00 2001 From: Alexander Grayver Date: Mon, 18 Jan 2021 21:38:52 +0100 Subject: [PATCH] Add ReferenceCell::Type wrapper --- .../python-bindings/include/cell_accessor_wrapper.h | 6 ++++++ contrib/python-bindings/source/CMakeLists.txt | 2 ++ .../python-bindings/source/cell_accessor_wrapper.cc | 12 ++++++++++++ .../python-bindings/source/export_cell_accessor.cc | 10 ++++++++++ contrib/python-bindings/source/wrappers.cc | 4 ++++ 5 files changed, 34 insertions(+) diff --git a/contrib/python-bindings/include/cell_accessor_wrapper.h b/contrib/python-bindings/include/cell_accessor_wrapper.h index bf10570a37..5443ea6099 100644 --- a/contrib/python-bindings/include/cell_accessor_wrapper.h +++ b/contrib/python-bindings/include/cell_accessor_wrapper.h @@ -28,6 +28,7 @@ namespace python { class PointWrapper; class TriangulationWrapper; + class CellTypeWrapper; class CellAccessorWrapper { @@ -184,6 +185,11 @@ namespace python unsigned int vertex_index(const unsigned int i) const; + /*! @copydoc TriaAccessor::reference_cell_type + */ + CellTypeWrapper + reference_cell_type() const; + /*! @copydoc TriaAccessor::n_vertices */ unsigned int diff --git a/contrib/python-bindings/source/CMakeLists.txt b/contrib/python-bindings/source/CMakeLists.txt index c6ab09562f..e0182fb695 100644 --- a/contrib/python-bindings/source/CMakeLists.txt +++ b/contrib/python-bindings/source/CMakeLists.txt @@ -38,6 +38,7 @@ SET(_src export_mapping.cc export_manifold.cc export_quadrature.cc + export_reference_cell.cc cell_accessor_wrapper.cc tria_accessor_wrapper.cc point_wrapper.cc @@ -45,6 +46,7 @@ SET(_src mapping_wrapper.cc manifold_wrapper.cc quadrature_wrapper.cc + reference_cell_wrapper.cc ) FOREACH(_build ${DEAL_II_BUILD_TYPES}) diff --git a/contrib/python-bindings/source/cell_accessor_wrapper.cc b/contrib/python-bindings/source/cell_accessor_wrapper.cc index 4d9dfc7114..50ce261f39 100644 --- a/contrib/python-bindings/source/cell_accessor_wrapper.cc +++ b/contrib/python-bindings/source/cell_accessor_wrapper.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -795,6 +796,17 @@ namespace python return internal::cell_cast<3, 3>(cell_accessor)->n_faces(); } + CellTypeWrapper + CellAccessorWrapper::reference_cell_type() const + { + if ((dim == 2) && (spacedim == 2)) + return internal::cell_cast<2, 2>(cell_accessor)->reference_cell_type(); + else if ((dim == 2) && (spacedim == 3)) + return internal::cell_cast<2, 3>(cell_accessor)->reference_cell_type(); + else + return internal::cell_cast<3, 3>(cell_accessor)->reference_cell_type(); + } + } // namespace python DEAL_II_NAMESPACE_CLOSE diff --git a/contrib/python-bindings/source/export_cell_accessor.cc b/contrib/python-bindings/source/export_cell_accessor.cc index b14b212a60..02b954ffda 100644 --- a/contrib/python-bindings/source/export_cell_accessor.cc +++ b/contrib/python-bindings/source/export_cell_accessor.cc @@ -16,6 +16,7 @@ #include #include +#include #include DEAL_II_NAMESPACE_OPEN @@ -151,6 +152,11 @@ namespace python + const char reference_cell_type_docstring[] = + " Reference cell type of the current cell). \n"; + + + const char n_vertices_docstring[] = " Number of vertices. \n"; @@ -254,6 +260,10 @@ namespace python &CellAccessorWrapper::vertex_index, vertex_index_docstring, boost::python::args("self", "vertex")) + .def("reference_cell_type", + &CellAccessorWrapper::reference_cell_type, + reference_cell_type_docstring, + boost::python::args("self")) .def("n_vertices", &CellAccessorWrapper::n_vertices, n_vertices_docstring, diff --git a/contrib/python-bindings/source/wrappers.cc b/contrib/python-bindings/source/wrappers.cc index 05d0885fd1..fabd0c9625 100644 --- a/contrib/python-bindings/source/wrappers.cc +++ b/contrib/python-bindings/source/wrappers.cc @@ -37,6 +37,8 @@ namespace python export_manifold(); void export_quadrature(); + void + export_reference_cell(); } // namespace python DEAL_II_NAMESPACE_CLOSE @@ -65,6 +67,7 @@ BOOST_PYTHON_MODULE(Debug) // message is printed. dealii::deal_II_exceptions::disable_abort_on_exception(); + dealii::python::export_reference_cell(); dealii::python::export_tria_accessor(); dealii::python::export_cell_accessor(); dealii::python::export_point(); @@ -85,6 +88,7 @@ BOOST_PYTHON_MODULE(Release) doc_options.enable_py_signatures(); doc_options.disable_cpp_signatures(); + dealii::python::export_reference_cell(); dealii::python::export_tria_accessor(); dealii::python::export_cell_accessor(); dealii::python::export_point(); -- 2.39.5