Skip to content

Commit

Permalink
Expose subentity types to python for easy creation of elements on ent…
Browse files Browse the repository at this point in the history
…ities. (#847)

* Expose subentity types to python for easy creation of elements on entites.

* Mypy fixes
  • Loading branch information
jorgensd authored Sep 2, 2024
1 parent de0bd73 commit 891e9a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/basix/_basixcpp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ def restriction(arg0: PolysetType, arg1: CellType, arg2: CellType, /) -> Polyset

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

def subentity_types(arg: CellType, /) -> list[list[CellType]]: ...

def sub_entity_connectivity(arg: CellType, /) -> list[list[list[list[int]]]]: ...

def sub_entity_geometry(arg0: CellType, arg1: int, arg2: int, /) -> Annotated[ArrayLike, dict(dtype='float64', )]: ...
Expand Down
14 changes: 14 additions & 0 deletions python/basix/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
from basix._basixcpp import cell_facet_reference_volumes as _frv
from basix._basixcpp import cell_volume as _v
from basix._basixcpp import geometry as _geometry
from basix._basixcpp import subentity_types as _sut
from basix._basixcpp import sub_entity_connectivity as _sec
from basix._basixcpp import topology as _topology

__all__ = [
"sub_entity_connectivity",
"subentity_types",
"volume",
"facet_jacobians",
"facet_normals",
Expand Down Expand Up @@ -143,3 +145,15 @@ def topology(celltype: CellType) -> list[list[list[int]]]:
Vertex indices for each sub-entity of the cell.
"""
return _topology(celltype)


def subentity_types(celltype: CellType) -> list[list[CellType]]:
"""Get the types of the subentities of a reference cell.
Args:
celltype: Cell type.
Returns:
Cell types for each sub-entity of the cell. Indices are (tdim, entity).
"""
return _sut(celltype)
2 changes: 1 addition & 1 deletion python/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ NB_MODULE(_basixcpp, m)
return as_nbarrayp(
cell::sub_entity_geometry<double>(celltype, dim, index));
});

m.def("subentity_types", &cell::subentity_types);
m.def("sobolev_space_intersection", &sobolev::space_intersection);

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

0 comments on commit 891e9a1

Please sign in to comment.