Skip to content

Commit f72a2dd

Browse files
authored
Merge branch 'main' into dependabot/github_actions/pypa/cibuildwheel-2.22.0
2 parents ac291b3 + d7bb763 commit f72a2dd

File tree

12 files changed

+269
-88
lines changed

12 files changed

+269
-88
lines changed

.github/workflows/pythonapp.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ on:
1717
branches:
1818
- main
1919
workflow_dispatch:
20-
20+
# Weekly build on Mondays at 8 am
21+
schedule:
22+
- cron: "0 8 * * 1"
2123
jobs:
2224
lint:
2325
name: Lint code
@@ -26,7 +28,7 @@ jobs:
2628
- name: Set up Python
2729
uses: actions/setup-python@v5
2830
with:
29-
python-version: '3.12'
31+
python-version: "3.12"
3032
- uses: actions/checkout@v4
3133
- name: Ruff check
3234
run: |
@@ -144,7 +146,7 @@ jobs:
144146
- name: Set up Python
145147
uses: actions/setup-python@v5
146148
with:
147-
python-version: '3.12'
149+
python-version: "3.12"
148150
- name: Install dependencies
149151
run: sudo apt-get install -y libopenblas-dev liblapack-dev ninja-build
150152
- name: Install Python dependencies
@@ -160,7 +162,7 @@ jobs:
160162
- name: Set up Python
161163
uses: actions/setup-python@v5
162164
with:
163-
python-version: '3.12'
165+
python-version: "3.12"
164166
- name: Install dependencies
165167
run: sudo apt-get install -y libopenblas-dev liblapack-dev
166168
- name: Install Basix C++ library

basix/_basixcpp.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ class SobolevSpace(enum.IntEnum):
414414

415415
def cell_facet_jacobians(arg: CellType, /) -> Annotated[ArrayLike, dict(dtype='float64', )]: ...
416416

417+
def cell_edge_jacobians(arg: CellType, /) -> Annotated[ArrayLike, dict(dtype='float64', )]: ...
418+
417419
def cell_facet_normals(arg: CellType, /) -> Annotated[ArrayLike, dict(dtype='float64', )]: ...
418420

419421
def cell_facet_orientations(arg: CellType, /) -> list[int]: ...
@@ -459,6 +461,8 @@ def restriction(arg0: PolysetType, arg1: CellType, arg2: CellType, /) -> Polyset
459461

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

464+
def sub_entity_type(arg: CellType, dim: int, index: int, /) -> CellType: ...
465+
462466
def sub_entity_connectivity(arg: CellType, /) -> list[list[list[list[int]]]]: ...
463467

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

cpp/basix/cell.cpp

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -608,33 +608,62 @@ std::vector<std::vector<cell::type>> cell::subentity_types(cell::type cell_type)
608608
//-----------------------------------------------------------------------------
609609
template <std::floating_point T>
610610
std::pair<std::vector<T>, std::array<std::size_t, 3>>
611-
cell::facet_jacobians(cell::type cell_type)
611+
cell::entity_jacobians(cell::type cell_type, std::size_t e_dim)
612612
{
613613
std::size_t tdim = cell::topological_dimension(cell_type);
614-
if (tdim != 2 and tdim != 3)
614+
if ((e_dim >= tdim))
615615
{
616616
throw std::runtime_error(
617-
"Facet jacobians not supported for this cell type.");
617+
"Entity jacobians supported for entity of dimension "
618+
+ std::to_string(e_dim) + "for cell of dimension "
619+
+ std::to_string(tdim));
618620
}
619621

620622
const auto [_x, xshape] = cell::geometry<T>(cell_type);
621623
mdspan_t<const T, 2> x(_x.data(), xshape);
622-
std::vector<std::vector<int>> facets = topology(cell_type)[tdim - 1];
624+
std::vector<std::vector<int>> entities = topology(cell_type)[e_dim];
623625

624-
std::array<std::size_t, 3> shape = {facets.size(), tdim, tdim - 1};
626+
std::array<std::size_t, 3> shape = {entities.size(), tdim, e_dim};
625627
std::vector<T> jacobians(shape[0] * shape[1] * shape[2]);
626628
mdspan_t<T, 3> J(jacobians.data(), shape);
627-
for (std::size_t f = 0; f < facets.size(); ++f)
629+
for (std::size_t e = 0; e < entities.size(); ++e)
628630
{
629-
const std::vector<int>& facet = facets[f];
630-
for (std::size_t j = 0; j < tdim - 1; ++j)
631+
const std::vector<int>& entity = entities[e];
632+
for (std::size_t j = 0; j < e_dim; ++j)
631633
for (std::size_t k = 0; k < J.extent(1); ++k)
632-
J(f, k, j) = x(facet[1 + j], k) - x(facet[0], k);
634+
J(e, k, j) = x(entity[1 + j], k) - x(entity[0], k);
633635
}
634636

635637
return {std::move(jacobians), std::move(shape)};
636638
}
637639
//-----------------------------------------------------------------------------
640+
template <std::floating_point T>
641+
std::pair<std::vector<T>, std::array<std::size_t, 3>>
642+
cell::facet_jacobians(cell::type cell_type)
643+
{
644+
std::size_t tdim = cell::topological_dimension(cell_type);
645+
if (tdim != 2 and tdim != 3)
646+
{
647+
throw std::runtime_error(
648+
"Facet jacobians not supported for this cell type.");
649+
}
650+
651+
return entity_jacobians<T>(cell_type, tdim - 1);
652+
}
653+
//-----------------------------------------------------------------------------
654+
template <std::floating_point T>
655+
std::pair<std::vector<T>, std::array<std::size_t, 3>>
656+
cell::edge_jacobians(cell::type cell_type)
657+
{
658+
std::size_t tdim = cell::topological_dimension(cell_type);
659+
if (tdim != 3)
660+
{
661+
throw std::runtime_error(
662+
"Edge jacobians not supported for this cell type.");
663+
}
664+
return entity_jacobians<T>(cell_type, 1);
665+
}
666+
//-----------------------------------------------------------------------------
638667

639668
/// @cond
640669
// Explicit instantiation for double and float
@@ -668,6 +697,10 @@ template std::pair<std::vector<float>, std::array<std::size_t, 3>>
668697
cell::facet_jacobians(cell::type);
669698
template std::pair<std::vector<double>, std::array<std::size_t, 3>>
670699
cell::facet_jacobians(cell::type);
700+
template std::pair<std::vector<float>, std::array<std::size_t, 3>>
701+
cell::edge_jacobians(cell::type);
702+
template std::pair<std::vector<double>, std::array<std::size_t, 3>>
703+
cell::edge_jacobians(cell::type);
671704
/// @endcond
672705

673706
//-----------------------------------------------------------------------------

cpp/basix/cell.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,29 @@ std::vector<T> facet_reference_volumes(cell::type cell_type);
121121
/// @return The subentity types. Indices are (tdim, entity)
122122
std::vector<std::vector<cell::type>> subentity_types(cell::type cell_type);
123123

124+
/// Get the jacobians of a set of entities of a reference cell
125+
/// @param cell_type Type of cell
126+
/// @param e_dim Dimension of entities
127+
/// @return The jacobians of the facets (flattened) and the shape (nfacets,
128+
/// tdim, tdim - 1).
129+
template <std::floating_point T>
130+
std::pair<std::vector<T>, std::array<std::size_t, 3>>
131+
entity_jacobians(cell::type cell_type, std::size_t e_dim);
132+
124133
/// Get the jacobians of the facets of a reference cell
125134
/// @param cell_type Type of cell
126-
/// @return The jacobians of the facets. Shape is (nfacets, gdim, gdim - 1)
135+
/// @return The jacobians of the facets (flattened) and the shape (nfacets,
136+
/// tdim, tdim - 1).
127137
template <std::floating_point T>
128138
std::pair<std::vector<T>, std::array<std::size_t, 3>>
129139
facet_jacobians(cell::type cell_type);
130140

141+
/// Get the jacobians of the edegs of a reference cell
142+
/// @param cell_type Type of cell
143+
/// @return The jacobians of the edges (flattened) and the shape (nedges, tdim,
144+
/// tdim-2).
145+
template <std::floating_point T>
146+
std::pair<std::vector<T>, std::array<std::size_t, 3>>
147+
edge_jacobians(cell::type cell_type);
148+
131149
} // namespace basix::cell

cpp/basix/mdspan.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6177,7 +6177,7 @@ layout_stride::mapping<Extents>::submdspan_mapping_impl(
61776177
(defined(__NVCC__) && \
61786178
(__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__ * 10) < 1120)
61796179
MDSPAN_IMPL_STANDARD_NAMESPACE::detail::tuple<decltype(detail::stride_of(slices))...>(
6180-
detail::stride_of(slices)...).values)),
6180+
detail::stride_of(slices)...)).values),
61816181
#else
61826182
MDSPAN_IMPL_STANDARD_NAMESPACE::detail::tuple(detail::stride_of(slices)...)).values),
61836183
#endif

demo/python/demo_create_and_tabulate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
# is 1 as we are only tabulating the function values; it would be higher if we
4747
# had asked for derivatives too. The second dimension (5) is the number of points.
4848
# The third dimension (25) is the number of DOFs. The fourth dimension (1) is the
49-
# value size of the element: this will be greater than 1 for vector-values elements.
49+
# value size of the element: this will be greater than 1 for vector-valued elements.
5050
#
5151
# C++ demo
5252
# ========

0 commit comments

Comments
 (0)