]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use ReferenceCell::Type to get Info 10692/head
authorPeter Munch <peterrmuench@gmail.com>
Wed, 8 Jul 2020 19:25:21 +0000 (21:25 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Fri, 17 Jul 2020 07:40:35 +0000 (09:40 +0200)
Add additional ReferenceCell::internal::Infos

include/deal.II/grid/reference_cell.h

index 6834c065ec66f632e2d50be374a39e12c21d7987..8832704e63af3542c8453213ed2afef34baea433 100644 (file)
@@ -301,6 +301,68 @@ namespace ReferenceCell
 
 
 
+      /**
+       * Triangle.
+       */
+      struct Tri : public Base
+      {
+        unsigned int
+        n_vertices() const override
+        {
+          return 3;
+        }
+
+        unsigned int
+        n_lines() const override
+        {
+          return 3;
+        }
+
+        unsigned int
+        n_faces() const override
+        {
+          return this->n_lines();
+        }
+
+        std::array<unsigned int, 2>
+        standard_vertex_to_face_and_vertex_index(
+          const unsigned int vertex) const override
+        {
+          AssertIndexRange(vertex, 3);
+
+          static const std::array<std::array<unsigned int, 2>, 3> table = {
+            {{0, 0}, {0, 1}, {1, 1}}};
+
+          return table[vertex];
+        }
+
+        unsigned int
+        standard_to_real_face_vertex(
+          const unsigned int  vertex,
+          const unsigned int  face,
+          const unsigned char line_orientation) const override
+        {
+          (void)face;
+
+          static const std::array<std::array<unsigned int, 2>, 2> table = {
+            {{1, 0}, {0, 1}}};
+
+          return table[line_orientation][vertex];
+        }
+
+        ReferenceCell::Type
+        face_reference_cell_type(const unsigned int face_no) const override
+        {
+          (void)face_no;
+
+          AssertIndexRange(face_no, n_faces());
+
+          return ReferenceCell::Type::Line;
+        }
+      };
+
+
+
       /**
        * Quad.
        */
@@ -336,6 +398,337 @@ namespace ReferenceCell
 
 
 
+      /**
+       * Tet.
+       */
+      struct Tet : public TensorProductBase<3>
+      {
+        unsigned int
+        n_vertices() const override
+        {
+          return 4;
+        }
+
+        unsigned int
+        n_lines() const override
+        {
+          return 6;
+        }
+
+        unsigned int
+        n_faces() const override
+        {
+          return 4;
+        }
+
+        std::array<unsigned int, 2>
+        standard_line_to_face_and_line_index(
+          const unsigned int line) const override
+        {
+          static const std::array<unsigned int, 2> table[6] = {
+            {0, 0}, {0, 1}, {0, 2}, {1, 1}, {1, 2}, {2, 1}};
+
+          return table[line];
+        }
+
+        unsigned int
+        standard_to_real_face_line(
+          const unsigned int  line,
+          const unsigned int  face,
+          const unsigned char face_orientation) const override
+        {
+          (void)face;
+
+          static const std::array<std::array<unsigned int, 3>, 6> table = {
+            {{2, 1, 0}, {0, 1, 2}, {1, 2, 0}, {0, 2, 1}, {1, 0, 2}, {2, 0, 1}}};
+
+          return table[face_orientation][line];
+        }
+
+        bool
+        combine_face_and_line_orientation(
+          const unsigned int  line,
+          const unsigned char face_orientation_raw,
+          const unsigned char line_orientation) const override
+        {
+          (void)line;
+          (void)face_orientation_raw;
+
+          return line_orientation;
+        }
+
+        std::array<unsigned int, 2>
+        standard_vertex_to_face_and_vertex_index(
+          const unsigned int vertex) const override
+        {
+          AssertIndexRange(vertex, 4);
+
+          static const std::array<unsigned int, 2> table[4] = {{0, 0},
+                                                               {0, 1},
+                                                               {0, 2},
+                                                               {1, 2}};
+
+          return table[vertex];
+        }
+
+        unsigned int
+        standard_to_real_face_vertex(
+          const unsigned int  vertex,
+          const unsigned int  face,
+          const unsigned char face_orientation) const override
+        {
+          AssertIndexRange(face_orientation, 6);
+          (void)face;
+
+          static const std::array<std::array<unsigned int, 3>, 6> table = {
+            {{0, 2, 1}, {0, 1, 2}, {1, 2, 0}, {1, 0, 2}, {2, 1, 0}, {2, 0, 1}}};
+
+          return table[face_orientation][vertex];
+        }
+
+        ReferenceCell::Type
+        face_reference_cell_type(const unsigned int face_no) const override
+        {
+          (void)face_no;
+
+          AssertIndexRange(face_no, n_faces());
+
+          return ReferenceCell::Type::Tri;
+        }
+      };
+
+
+
+      /**
+       * Pyramid.
+       */
+      struct Pyramid : public TensorProductBase<3>
+      {
+        unsigned int
+        n_vertices() const override
+        {
+          return 5;
+        }
+
+        unsigned int
+        n_lines() const override
+        {
+          return 8;
+        }
+
+        unsigned int
+        n_faces() const override
+        {
+          return 5;
+        }
+
+        std::array<unsigned int, 2>
+        standard_line_to_face_and_line_index(
+          const unsigned int line) const override
+        {
+          Assert(false, ExcNotImplemented());
+
+          static const std::array<unsigned int, 2> table[6] = {
+            {0, 0}, {0, 1}, {0, 2}, {1, 1}, {1, 2}, {2, 1}};
+
+          return table[line];
+        }
+
+        unsigned int
+        standard_to_real_face_line(
+          const unsigned int  line,
+          const unsigned int  face,
+          const unsigned char face_orientation) const override
+        {
+          Assert(false, ExcNotImplemented());
+
+          (void)face;
+
+          static const std::array<std::array<unsigned int, 3>, 6> table = {
+            {{2, 1, 0}, {0, 1, 2}, {1, 2, 0}, {0, 2, 1}, {1, 0, 2}, {2, 0, 1}}};
+
+          return table[face_orientation][line];
+        }
+
+        bool
+        combine_face_and_line_orientation(
+          const unsigned int  line,
+          const unsigned char face_orientation_raw,
+          const unsigned char line_orientation) const override
+        {
+          (void)line;
+          (void)face_orientation_raw;
+
+          return line_orientation;
+        }
+
+        std::array<unsigned int, 2>
+        standard_vertex_to_face_and_vertex_index(
+          const unsigned int vertex) const override
+        {
+          static const std::array<unsigned int, 2> table[5] = {
+            {0, 0}, {0, 1}, {0, 2}, {0, 3}, {1, 2}};
+
+          return table[vertex];
+        }
+
+        unsigned int
+        standard_to_real_face_vertex(
+          const unsigned int  vertex,
+          const unsigned int  face,
+          const unsigned char face_orientation) const override
+        {
+          if (face == 0) // Quad
+            {
+              return GeometryInfo<3>::standard_to_real_face_vertex(
+                vertex,
+                get_bit(face_orientation, 0),
+                get_bit(face_orientation, 2),
+                get_bit(face_orientation, 1));
+            }
+          else // Tri
+            {
+              static const std::array<std::array<unsigned int, 3>, 6> table = {
+                {{0, 2, 1},
+                 {0, 1, 2},
+                 {1, 2, 0},
+                 {1, 0, 2},
+                 {2, 1, 0},
+                 {2, 0, 1}}};
+
+              return table[face_orientation][vertex];
+            }
+        }
+
+        ReferenceCell::Type
+        face_reference_cell_type(const unsigned int face_no) const override
+        {
+          AssertIndexRange(face_no, n_faces());
+
+          if (face_no == 1)
+            return ReferenceCell::Type::Quad;
+          else
+            return ReferenceCell::Type::Tri;
+        }
+      };
+
+
+
+      /**
+       * Wedge.
+       */
+      struct Wedge : public TensorProductBase<3>
+      {
+        unsigned int
+        n_vertices() const override
+        {
+          return 6;
+        }
+
+        unsigned int
+        n_lines() const override
+        {
+          return 9;
+        }
+
+        unsigned int
+        n_faces() const override
+        {
+          return 6;
+        }
+
+        std::array<unsigned int, 2>
+        standard_line_to_face_and_line_index(
+          const unsigned int line) const override
+        {
+          Assert(false, ExcNotImplemented());
+
+          static const std::array<unsigned int, 2> table[6] = {
+            {0, 0}, {0, 1}, {0, 2}, {1, 1}, {1, 2}, {2, 1}};
+
+          return table[line];
+        }
+
+        unsigned int
+        standard_to_real_face_line(
+          const unsigned int  line,
+          const unsigned int  face,
+          const unsigned char face_orientation) const override
+        {
+          Assert(false, ExcNotImplemented());
+
+          (void)face;
+
+          static const std::array<std::array<unsigned int, 3>, 6> table = {
+            {{2, 1, 0}, {0, 1, 2}, {1, 2, 0}, {0, 2, 1}, {1, 0, 2}, {2, 0, 1}}};
+
+          return table[face_orientation][line];
+        }
+
+        bool
+        combine_face_and_line_orientation(
+          const unsigned int  line,
+          const unsigned char face_orientation_raw,
+          const unsigned char line_orientation) const override
+        {
+          (void)line;
+          (void)face_orientation_raw;
+
+          return line_orientation;
+        }
+
+        std::array<unsigned int, 2>
+        standard_vertex_to_face_and_vertex_index(
+          const unsigned int vertex) const override
+        {
+          static const std::array<std::array<unsigned int, 2>, 6> table = {
+            {{0, 1}, {0, 0}, {0, 2}, {1, 0}, {1, 1}, {1, 2}}};
+
+          return table[vertex];
+        }
+
+        unsigned int
+        standard_to_real_face_vertex(
+          const unsigned int  vertex,
+          const unsigned int  face,
+          const unsigned char face_orientation) const override
+        {
+          if (face > 1) // QUAD
+            {
+              return GeometryInfo<3>::standard_to_real_face_vertex(
+                vertex,
+                get_bit(face_orientation, 0),
+                get_bit(face_orientation, 2),
+                get_bit(face_orientation, 1));
+            }
+          else // TRI
+            {
+              static const std::array<std::array<unsigned int, 3>, 6> table = {
+                {{0, 2, 1},
+                 {0, 1, 2},
+                 {1, 2, 0},
+                 {1, 0, 2},
+                 {2, 1, 0},
+                 {2, 0, 1}}};
+
+              return table[face_orientation][vertex];
+            }
+        }
+
+        ReferenceCell::Type
+        face_reference_cell_type(const unsigned int face_no) const override
+        {
+          AssertIndexRange(face_no, n_faces());
+
+          if (face_no > 1)
+            return ReferenceCell::Type::Quad;
+          else
+            return ReferenceCell::Type::Tri;
+        }
+      };
+
+
+
       /**
        * Hex.
        */
@@ -429,11 +822,15 @@ namespace ReferenceCell
       inline const ReferenceCell::internal::Info::Base &
       get_cell(const ReferenceCell::Type &type)
       {
-        static ReferenceCell::internal::Info::Base   gei_invalid;
-        static ReferenceCell::internal::Info::Vertex gei_vertex;
-        static ReferenceCell::internal::Info::Line   gei_line;
-        static ReferenceCell::internal::Info::Quad   gei_quad;
-        static ReferenceCell::internal::Info::Hex    gei_hex;
+        static ReferenceCell::internal::Info::Base    gei_invalid;
+        static ReferenceCell::internal::Info::Vertex  gei_vertex;
+        static ReferenceCell::internal::Info::Line    gei_line;
+        static ReferenceCell::internal::Info::Tri     gei_tri;
+        static ReferenceCell::internal::Info::Quad    gei_quad;
+        static ReferenceCell::internal::Info::Tet     gei_tet;
+        static ReferenceCell::internal::Info::Pyramid gei_pyramid;
+        static ReferenceCell::internal::Info::Wedge   gei_wedge;
+        static ReferenceCell::internal::Info::Hex     gei_hex;
 
         switch (type)
           {
@@ -441,8 +838,16 @@ namespace ReferenceCell
               return gei_vertex;
             case ReferenceCell::Type::Line:
               return gei_line;
+            case ReferenceCell::Type::Tri:
+              return gei_tri;
             case ReferenceCell::Type::Quad:
               return gei_quad;
+            case ReferenceCell::Type::Tet:
+              return gei_tet;
+            case ReferenceCell::Type::Pyramid:
+              return gei_pyramid;
+            case ReferenceCell::Type::Wedge:
+              return gei_wedge;
             case ReferenceCell::Type::Hex:
               return gei_hex;
             default:

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.