@@ -608,33 +608,62 @@ std::vector<std::vector<cell::type>> cell::subentity_types(cell::type cell_type)
608608// -----------------------------------------------------------------------------
609609template <std::floating_point T>
610610std::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);
669698template 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// -----------------------------------------------------------------------------
0 commit comments