From d368d37fb76eaf856f82a3ad98f1e9f62ec90204 Mon Sep 17 00:00:00 2001 From: David Wells Date: Wed, 25 Jun 2025 23:24:13 -0400 Subject: [PATCH] MappingFE + ReferenceCell: make tangent vectors work in 1d. --- include/deal.II/fe/mapping_fe.h | 2 +- include/deal.II/grid/reference_cell.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/deal.II/fe/mapping_fe.h b/include/deal.II/fe/mapping_fe.h index 4171d5f1a6..5b8366b5f0 100644 --- a/include/deal.II/fe/mapping_fe.h +++ b/include/deal.II/fe/mapping_fe.h @@ -323,7 +323,7 @@ public: * Filled once. */ std::array>, - GeometryInfo::faces_per_cell *(dim - 1)> + ReferenceCells::max_n_faces() * 2> unit_tangentials; /** diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 9546a4930f..2ae54ea495 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -3261,12 +3261,21 @@ inline Tensor<1, dim> ReferenceCell::face_tangent_vector(const unsigned int face_no, const unsigned int i) const { + AssertIndexRange(face_no, n_faces()); Assert(dim == get_dimension(), ExcMessage("You can only call this function with arguments for " "which 'dim' equals the dimension of the space in which " "the current reference cell lives. You have dim=" + std::to_string(dim) + " but the reference cell is " + std::to_string(get_dimension()) + " dimensional.")); + + // Simplify the 1d case by setting tangents (which are used for boundary forms + // and thus Jacobians) equal to the unit vector + if constexpr (dim == 1) + { + return Tensor<1, dim>{{1.0}}; + } + AssertIndexRange(i, dim - 1); switch (this->kind) -- 2.39.5