Skip to content

Commit 891e9a1

Browse files
authored
Expose subentity types to python for easy creation of elements on entities. (#847)
* Expose subentity types to python for easy creation of elements on entites. * Mypy fixes
1 parent de0bd73 commit 891e9a1

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

python/basix/_basixcpp.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ def restriction(arg0: PolysetType, arg1: CellType, arg2: CellType, /) -> Polyset
481481

482482
def sobolev_space_intersection(arg0: SobolevSpace, arg1: SobolevSpace, /) -> SobolevSpace: ...
483483

484+
def subentity_types(arg: CellType, /) -> list[list[CellType]]: ...
485+
484486
def sub_entity_connectivity(arg: CellType, /) -> list[list[list[list[int]]]]: ...
485487

486488
def sub_entity_geometry(arg0: CellType, arg1: int, arg2: int, /) -> Annotated[ArrayLike, dict(dtype='float64', )]: ...

python/basix/cell.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
from basix._basixcpp import cell_facet_reference_volumes as _frv
1616
from basix._basixcpp import cell_volume as _v
1717
from basix._basixcpp import geometry as _geometry
18+
from basix._basixcpp import subentity_types as _sut
1819
from basix._basixcpp import sub_entity_connectivity as _sec
1920
from basix._basixcpp import topology as _topology
2021

2122
__all__ = [
2223
"sub_entity_connectivity",
24+
"subentity_types",
2325
"volume",
2426
"facet_jacobians",
2527
"facet_normals",
@@ -143,3 +145,15 @@ def topology(celltype: CellType) -> list[list[list[int]]]:
143145
Vertex indices for each sub-entity of the cell.
144146
"""
145147
return _topology(celltype)
148+
149+
150+
def subentity_types(celltype: CellType) -> list[list[CellType]]:
151+
"""Get the types of the subentities of a reference cell.
152+
153+
Args:
154+
celltype: Cell type.
155+
156+
Returns:
157+
Cell types for each sub-entity of the cell. Indices are (tdim, entity).
158+
"""
159+
return _sut(celltype)

python/wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ NB_MODULE(_basixcpp, m)
432432
return as_nbarrayp(
433433
cell::sub_entity_geometry<double>(celltype, dim, index));
434434
});
435-
435+
m.def("subentity_types", &cell::subentity_types);
436436
m.def("sobolev_space_intersection", &sobolev::space_intersection);
437437

438438
nb::enum_<lattice::type>(m, "LatticeType", nb::is_arithmetic(),

0 commit comments

Comments
 (0)