]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make unit_normal_vectors() a member of ReferenceCell::Type. 11662/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 2 Feb 2021 20:45:43 +0000 (13:45 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 2 Feb 2021 20:45:43 +0000 (13:45 -0700)
include/deal.II/grid/reference_cell.h
include/deal.II/meshworker/mesh_loop.h
tests/simplex/unit_tangential_vectors_01.cc

index 96af506c05ef817ca84540a5ac816db440a09c47..892fec8364f245441de5235c3a55f09673f9f8c5 100644 (file)
@@ -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 <int dim>
+    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 <int dim>
   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<dim>())
+    if (is_hyper_cube())
       {
         AssertIndexRange(face_no, GeometryInfo<dim>::faces_per_cell);
         return GeometryInfo<dim>::unit_normal_vector[face_no];
       }
     else if (dim == 2)
       {
-        const auto tangential =
-          reference_cell.unit_tangential_vectors<dim>(face_no, 0);
+        Assert(*this == Tri, ExcInternalError());
 
-        Tensor<1, dim> result;
+        const auto tangential = unit_tangential_vectors<dim>(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<dim>(face_no, 0),
-          reference_cell.unit_tangential_vectors<dim>(face_no, 1));
+        return cross_product_3d(unit_tangential_vectors<dim>(face_no, 0),
+                                unit_tangential_vectors<dim>(face_no, 1));
       }
 
     Assert(false, ExcNotImplemented());
index 807fdcca7c60033428172ae21ed791e0e0e64709..f9a73ca29a66cbdca01de439dce38cfb581f706a 100644 (file)
@@ -20,6 +20,7 @@
 #include <deal.II/base/config.h>
 
 #include <deal.II/base/template_constraints.h>
+#include <deal.II/base/types.h>
 #include <deal.II/base/work_stream.h>
 
 #include <deal.II/grid/filtered_iterator.h>
index 6b705a6dacc4bf6978131cea34576f2b6146e69b..3fe2753fa5df73a48ec28dcadef5cfad1692aae9 100644 (file)
@@ -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<dim>(reference_cell,
-                                                         face_no)
+      deallog << reference_cell.template unit_normal_vectors<dim>(face_no)
               << std::endl;
 
       for (unsigned int i = 0; i < dim - 1; ++i)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.