From 94b8dedcea58a7da9907e24929d9b0318639eadb Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 2 Feb 2021 13:45:43 -0700 Subject: [PATCH] Make unit_normal_vectors() a member of ReferenceCell::Type. --- include/deal.II/grid/reference_cell.h | 29 ++++++++++++--------- include/deal.II/meshworker/mesh_loop.h | 1 + tests/simplex/unit_tangential_vectors_01.cc | 3 +-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 96af506c05..892fec8364 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -156,6 +156,13 @@ namespace ReferenceCell unit_tangential_vectors(const unsigned int face_no, const unsigned int i) const; + /** + * Return the unit normal vector of a face of the reference cell. + */ + template + Tensor<1, dim> + unit_normal_vectors(const unsigned int face_no) const; + /** * Determine the orientation of the current entity described by its * vertices @p var_1 relative to an entity described by @p var_0. @@ -674,27 +681,26 @@ namespace ReferenceCell return {}; } - /** - * Return the unit normal vector of a face of the reference cell. - */ + + template inline Tensor<1, dim> - unit_normal_vectors(const Type &reference_cell, const unsigned int face_no) + Type::unit_normal_vectors(const unsigned int face_no) const { - AssertDimension(dim, reference_cell.get_dimension()); + AssertDimension(dim, this->get_dimension()); - if (reference_cell == Type::get_hypercube()) + if (is_hyper_cube()) { AssertIndexRange(face_no, GeometryInfo::faces_per_cell); return GeometryInfo::unit_normal_vector[face_no]; } else if (dim == 2) { - const auto tangential = - reference_cell.unit_tangential_vectors(face_no, 0); + Assert(*this == Tri, ExcInternalError()); - Tensor<1, dim> result; + const auto tangential = unit_tangential_vectors(face_no, 0); + Tensor<1, dim> result; result[0] = tangential[1]; result[1] = -tangential[0]; @@ -702,9 +708,8 @@ namespace ReferenceCell } else if (dim == 3) { - return cross_product_3d( - reference_cell.unit_tangential_vectors(face_no, 0), - reference_cell.unit_tangential_vectors(face_no, 1)); + return cross_product_3d(unit_tangential_vectors(face_no, 0), + unit_tangential_vectors(face_no, 1)); } Assert(false, ExcNotImplemented()); diff --git a/include/deal.II/meshworker/mesh_loop.h b/include/deal.II/meshworker/mesh_loop.h index 807fdcca7c..f9a73ca29a 100644 --- a/include/deal.II/meshworker/mesh_loop.h +++ b/include/deal.II/meshworker/mesh_loop.h @@ -20,6 +20,7 @@ #include #include +#include #include #include diff --git a/tests/simplex/unit_tangential_vectors_01.cc b/tests/simplex/unit_tangential_vectors_01.cc index 6b705a6dac..3fe2753fa5 100644 --- a/tests/simplex/unit_tangential_vectors_01.cc +++ b/tests/simplex/unit_tangential_vectors_01.cc @@ -33,8 +33,7 @@ test(const ReferenceCell::Type &reference_cell) for (const auto face_no : ReferenceCell::internal::Info::get_cell(reference_cell).face_indices()) { - deallog << ReferenceCell::unit_normal_vectors(reference_cell, - face_no) + deallog << reference_cell.template unit_normal_vectors(face_no) << std::endl; for (unsigned int i = 0; i < dim - 1; ++i) -- 2.39.5