]> https://gitweb.dealii.org/ - dealii.git/commitdiff
ReferenceCell: port line_to_cell_vertices() over
authorDavid Wells <drwells@email.unc.edu>
Sat, 17 Dec 2022 00:19:01 +0000 (19:19 -0500)
committerDavid Wells <drwells@email.unc.edu>
Wed, 11 Jan 2023 22:17:34 +0000 (17:17 -0500)
include/deal.II/grid/reference_cell.h
source/fe/mapping_q.cc

index b149d0dc646f79341e0173896b6135c53147d607..c44a65188c8b3c447dda3230cf391708144c8d5a 100644 (file)
@@ -423,6 +423,18 @@ public:
   std::array<unsigned int, 2>
   standard_line_to_face_and_line_index(const unsigned int line) const;
 
+  /**
+   * Map line vertex number to cell vertex number, i.e., return the cell vertex
+   * number of the <tt>vertex</tt>th vertex of line <tt>line</tt>.
+   *
+   * The order of the lines, as well as their direction (which in turn
+   * determines which vertices are first and second on a line) is the canonical
+   * one in deal.II, as described in the general documentation of this class.
+   */
+  unsigned int
+  line_to_cell_vertices(const unsigned int line,
+                        const unsigned int vertex) const;
+
   /**
    * Map face line number to cell line number.
    */
@@ -1491,6 +1503,82 @@ ReferenceCell::standard_line_to_face_and_line_index(
 }
 
 
+inline unsigned int
+ReferenceCell::line_to_cell_vertices(const unsigned int line,
+                                     const unsigned int vertex) const
+{
+  AssertIndexRange(vertex, 2);
+  AssertIndexRange(line, n_lines());
+
+  if (*this == ReferenceCells::Vertex)
+    return vertex;
+  else if (*this == ReferenceCells::Line)
+    return vertex;
+  else if (*this == ReferenceCells::Quadrilateral)
+    {
+      static constexpr ndarray<unsigned int, 4, 2> table = {
+        {{{0, 2}}, {{1, 3}}, {{0, 1}}, {{2, 3}}}};
+      return table[line][vertex];
+    }
+  else if (*this == ReferenceCells::Hexahedron)
+    {
+      // first four lines comprise the bottom face, next four are the top,
+      // and the last four are 'bottom to top'
+      static constexpr ndarray<unsigned int, 12, 2> table = {{{{0, 2}},
+                                                              {{1, 3}},
+                                                              {{0, 1}},
+                                                              {{2, 3}},
+                                                              {{4, 6}},
+                                                              {{5, 7}},
+                                                              {{4, 5}},
+                                                              {{6, 7}},
+                                                              {{0, 4}},
+                                                              {{1, 5}},
+                                                              {{2, 6}},
+                                                              {{3, 7}}}};
+      return table[line][vertex];
+    }
+  else if (*this == ReferenceCells::Triangle)
+    {
+      static constexpr ndarray<unsigned int, 3, 2> table = {
+        {{{0, 1}}, {{1, 2}}, {{2, 0}}}};
+      return table[line][vertex];
+    }
+  else if (*this == ReferenceCells::Tetrahedron)
+    {
+      static constexpr ndarray<unsigned int, 6, 2> table = {
+        {{{0, 1}}, {{1, 2}}, {{2, 0}}, {{0, 3}}, {{1, 3}}, {{2, 3}}}};
+      return table[line][vertex];
+    }
+  else if (*this == ReferenceCells::Pyramid)
+    {
+      static constexpr ndarray<unsigned int, 8, 2> table = {{{{0, 2}},
+                                                             {{1, 3}},
+                                                             {{0, 1}},
+                                                             {{2, 3}},
+                                                             {{4, 0}},
+                                                             {{1, 4}},
+                                                             {{2, 4}},
+                                                             {{4, 3}}}};
+      return table[line][vertex];
+    }
+  else if (*this == ReferenceCells::Wedge)
+    {
+      static constexpr ndarray<unsigned int, 9, 2> table = {{{{1, 0}},
+                                                             {{2, 1}},
+                                                             {{0, 2}},
+                                                             {{3, 4}},
+                                                             {{4, 5}},
+                                                             {{5, 3}},
+                                                             {{0, 3}},
+                                                             {{1, 4}},
+                                                             {{2, 5}}}};
+      return table[line][vertex];
+    }
+  Assert(false, ExcInternalError());
+  return numbers::invalid_unsigned_int;
+}
+
 
 inline unsigned int
 ReferenceCell::face_to_cell_lines(const unsigned int  face,
index 9760fb508d3ee0dbde20e117cd12a368e6563443..bfb4089a7aab7a15363e6bdc26eb92976c0b98f0 100644 (file)
@@ -1680,10 +1680,10 @@ MappingQ<dim, spacedim>::add_line_support_points(
                cell->get_manifold() :
                line->get_manifold());
 
+          const auto reference_cell = ReferenceCells::get_hypercube<dim>();
           const std::array<Point<spacedim>, 2> vertices{
-            {cell->vertex(GeometryInfo<dim>::line_to_cell_vertices(line_no, 0)),
-             cell->vertex(
-               GeometryInfo<dim>::line_to_cell_vertices(line_no, 1))}};
+            {cell->vertex(reference_cell.line_to_cell_vertices(line_no, 0)),
+             cell->vertex(reference_cell.line_to_cell_vertices(line_no, 1))}};
 
           const std::size_t n_rows =
             support_point_weights_perimeter_to_interior[0].size(0);

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.