]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce ReferenceCell::Type 10645/head
authorPeter Munch <peterrmuench@gmail.com>
Tue, 30 Jun 2020 19:23:12 +0000 (21:23 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Thu, 16 Jul 2020 06:29:15 +0000 (08:29 +0200)
include/deal.II/fe/fe_base.h
include/deal.II/grid/reference_cell.h
source/fe/fe_data.cc

index 653dc07b4754e05b016f0d2892a55ac6780b0593..ee51ceb64e4b01091fdf62c6c8a3948694db6483 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <deal.II/base/exceptions.h>
 
+#include <deal.II/grid/reference_cell.h>
+
 #include <deal.II/lac/block_indices.h>
 
 #include <vector>
@@ -351,6 +353,17 @@ public:
                     const Conformity                 conformity = unknown,
                     const BlockIndices &block_indices = BlockIndices());
 
+  /**
+   * The same as above but with the difference that also the type of the
+   * underlying geometric entity can be specified.
+   */
+  FiniteElementData(const std::vector<unsigned int> &dofs_per_object,
+                    const ReferenceCell::Type        cell_type,
+                    const unsigned int               n_components,
+                    const unsigned int               degree,
+                    const Conformity                 conformity = unknown,
+                    const BlockIndices &block_indices = BlockIndices());
+
   /**
    * Number of dofs per vertex.
    */
index 49e2033ccdfe8f149329a894c70da2b41d2f02e1..7c2a57ce7bae36937aba98901805fca69d5a3e18 100644 (file)
@@ -229,6 +229,18 @@ namespace ReferenceCell
 
           return true;
         }
+
+        /**
+         * Return reference-cell type of face @p face_no.
+         */
+        virtual ReferenceCell::Type
+        face_reference_cell_type(const unsigned int face_no) const
+        {
+          Assert(false, ExcNotImplemented());
+          (void)face_no;
+
+          return ReferenceCell::Type::Invalid;
+        }
       };
 
 
@@ -263,7 +275,14 @@ namespace ReferenceCell
        * Vertex.
        */
       struct Vertex : public TensorProductBase<0>
-      {};
+      {
+        ReferenceCell::Type
+        face_reference_cell_type(const unsigned int face_no) const override
+        {
+          (void)face_no;
+          return ReferenceCell::Type::Invalid;
+        }
+      };
 
 
 
@@ -271,7 +290,14 @@ namespace ReferenceCell
        * Line.
        */
       struct Line : public TensorProductBase<1>
-      {};
+      {
+        ReferenceCell::Type
+        face_reference_cell_type(const unsigned int face_no) const override
+        {
+          (void)face_no;
+          return ReferenceCell::Type::Vertex;
+        }
+      };
 
 
 
@@ -299,6 +325,13 @@ namespace ReferenceCell
           return GeometryInfo<2>::standard_to_real_line_vertex(
             vertex, line_orientation);
         }
+
+        ReferenceCell::Type
+        face_reference_cell_type(const unsigned int face_no) const override
+        {
+          (void)face_no;
+          return ReferenceCell::Type::Line;
+        }
       };
 
 
@@ -381,8 +414,53 @@ namespace ReferenceCell
             get_bit(face_orientation, 2),
             get_bit(face_orientation, 1));
         }
+
+        ReferenceCell::Type
+        face_reference_cell_type(const unsigned int face_no) const override
+        {
+          (void)face_no;
+          return ReferenceCell::Type::Quad;
+        }
       };
 
+      /**
+       * Return for a given reference-cell type @p the right Info.
+       */
+      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;
+
+        switch (type)
+          {
+            case ReferenceCell::Type::Vertex:
+              return gei_vertex;
+            case ReferenceCell::Type::Line:
+              return gei_line;
+            case ReferenceCell::Type::Quad:
+              return gei_quad;
+            case ReferenceCell::Type::Hex:
+              return gei_hex;
+            default:
+              Assert(false, StandardExceptions::ExcNotImplemented());
+              return gei_invalid;
+          }
+      }
+
+      /**
+       * Return for a given reference-cell type @p and face number @p face_no the
+       * right Info of the @p face_no-th face.
+       */
+      inline const ReferenceCell::internal::Info::Base &
+      get_face(const ReferenceCell::Type &type, const unsigned int face_no)
+      {
+        return get_cell(get_cell(type).face_reference_cell_type(face_no));
+      }
+
     } // namespace Info
   }   // namespace internal
 } // namespace ReferenceCell
index 4ae2482afda820b981c2a9afec0a4faac98f718d..ad587ad12d319fd37db12c5629a79f9fb9379248 100644 (file)
@@ -26,28 +26,74 @@ FiniteElementData<dim>::FiniteElementData(
   const unsigned int               degree,
   const Conformity                 conformity,
   const BlockIndices &             block_indices)
+  : FiniteElementData(dofs_per_object,
+                      dim == 0 ?
+                        ReferenceCell::Type::Vertex :
+                        (dim == 1 ? ReferenceCell::Type::Line :
+                                    (dim == 2 ? ReferenceCell::Type::Quad :
+                                                ReferenceCell::Type::Hex)),
+                      n_components,
+                      degree,
+                      conformity,
+                      block_indices)
+{}
+
+template <int dim>
+FiniteElementData<dim>::FiniteElementData(
+  const std::vector<unsigned int> &dofs_per_object,
+  const ReferenceCell::Type        cell_type,
+  const unsigned int               n_components,
+  const unsigned int               degree,
+  const Conformity                 conformity,
+  const BlockIndices &             block_indices)
   : dofs_per_vertex(dofs_per_object[0])
   , dofs_per_line(dofs_per_object[1])
   , dofs_per_quad(dim > 1 ? dofs_per_object[2] : 0)
   , dofs_per_hex(dim > 2 ? dofs_per_object[3] : 0)
-  , first_line_index(GeometryInfo<dim>::vertices_per_cell * dofs_per_vertex)
-  , first_quad_index(first_line_index +
-                     GeometryInfo<dim>::lines_per_cell * dofs_per_line)
-  , first_hex_index(first_quad_index +
-                    GeometryInfo<dim>::quads_per_cell * dofs_per_quad)
-  , first_face_line_index(GeometryInfo<dim - 1>::vertices_per_cell *
-                          dofs_per_vertex)
+  , first_line_index(
+      ReferenceCell::internal::Info::get_cell(cell_type).n_vertices() *
+      dofs_per_vertex)
+  , first_quad_index(
+      first_line_index +
+      ReferenceCell::internal::Info::get_cell(cell_type).n_lines() *
+        dofs_per_line)
+  , first_hex_index(
+      first_quad_index +
+      (dim == 2 ?
+         1 :
+         (dim == 3 ?
+            ReferenceCell::internal::Info::get_cell(cell_type).n_faces() :
+            0)) *
+        dofs_per_quad)
+  , first_face_line_index(
+      ReferenceCell::internal::Info::get_face(cell_type, 0).n_vertices() *
+      dofs_per_vertex)
   , first_face_quad_index(
-      (dim == 3 ? GeometryInfo<dim - 1>::vertices_per_cell * dofs_per_vertex :
-                  GeometryInfo<dim>::vertices_per_cell * dofs_per_vertex) +
-      GeometryInfo<dim - 1>::lines_per_cell * dofs_per_line)
-  , dofs_per_face(GeometryInfo<dim>::vertices_per_face * dofs_per_vertex +
-                  GeometryInfo<dim>::lines_per_face * dofs_per_line +
-                  GeometryInfo<dim>::quads_per_face * dofs_per_quad)
-  , dofs_per_cell(GeometryInfo<dim>::vertices_per_cell * dofs_per_vertex +
-                  GeometryInfo<dim>::lines_per_cell * dofs_per_line +
-                  GeometryInfo<dim>::quads_per_cell * dofs_per_quad +
-                  GeometryInfo<dim>::hexes_per_cell * dofs_per_hex)
+      (dim == 3 ?
+         ReferenceCell::internal::Info::get_face(cell_type, 0).n_vertices() *
+           dofs_per_vertex :
+         ReferenceCell::internal::Info::get_cell(cell_type).n_vertices() *
+           dofs_per_vertex) +
+      ReferenceCell::internal::Info::get_face(cell_type, 0).n_lines() *
+        dofs_per_line)
+  , dofs_per_face(
+      ReferenceCell::internal::Info::get_face(cell_type, 0).n_vertices() *
+        dofs_per_vertex +
+      ReferenceCell::internal::Info::get_face(cell_type, 0).n_lines() *
+        dofs_per_line +
+      (dim == 3 ? 1 : 0) * dofs_per_quad)
+  , dofs_per_cell(
+      ReferenceCell::internal::Info::get_cell(cell_type).n_vertices() *
+        dofs_per_vertex +
+      ReferenceCell::internal::Info::get_cell(cell_type).n_lines() *
+        dofs_per_line +
+      (dim == 2 ?
+         1 :
+         (dim == 3 ?
+            ReferenceCell::internal::Info::get_cell(cell_type).n_faces() :
+            0)) *
+        dofs_per_quad +
+      (dim == 3 ? 1 : 0) * dofs_per_hex)
   , components(n_components)
   , degree(degree)
   , conforming_space(conformity)

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.