]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make FE_SimplexP work better in 1D.
authorDavid Wells <drwells@email.unc.edu>
Sat, 3 Jul 2021 15:04:21 +0000 (11:04 -0400)
committerDavid Wells <drwells@email.unc.edu>
Sat, 3 Jul 2021 15:13:46 +0000 (11:13 -0400)
This is useful when initializing face info.

include/deal.II/grid/reference_cell.h
source/fe/fe_simplex_p.cc

index 1b25b65c7293b562f9211d7520a3b267fb0adfad..41d53d6c64efac872dd47b63432cd1f459c42423 100644 (file)
@@ -656,7 +656,7 @@ namespace ReferenceCells
   /**
    * Return the correct simplex reference cell type for the given dimension
    * `dim`. Depending on the template argument `dim`, this function returns a
-   * reference to either Vertex, Triangle, or Tetrahedron.
+   * reference to either Vertex, Line, Triangle, or Tetrahedron.
    */
   template <int dim>
   constexpr const ReferenceCell &
index a41434af2952d5cb94f03311c4b688a5d6378294..4d559e5363d26b119175bc6a435d5018b2251652 100644 (file)
@@ -84,6 +84,12 @@ namespace
   unit_support_points_fe_p(const unsigned int degree)
   {
     std::vector<Point<dim>> unit_points;
+    // If we do dim - 1 we can get here in dim = 0:
+    if (dim == 0)
+      {
+        unit_points.emplace_back();
+        return unit_points;
+      }
 
     // Piecewise constants are a special case: use a support point at the
     // centroid and only the centroid
@@ -178,9 +184,7 @@ namespace
     std::vector<std::vector<Point<dim - 1>>> unit_face_points;
 
     // all faces have the same support points
-    for (auto face_n :
-         (dim == 2 ? ReferenceCells::Triangle : ReferenceCells::Tetrahedron)
-           .face_indices())
+    for (auto face_n : ReferenceCells::get_simplex<dim>().face_indices())
       {
         (void)face_n;
         unit_face_points.emplace_back(
@@ -610,8 +614,7 @@ FE_SimplexP<dim, spacedim>::FE_SimplexP(const unsigned int degree)
   : FE_SimplexPoly<dim, spacedim>(
       BarycentricPolynomials<dim>::get_fe_p_basis(degree),
       FiniteElementData<dim>(get_dpo_vector_fe_p(dim, degree),
-                             dim == 2 ? ReferenceCells::Triangle :
-                                        ReferenceCells::Tetrahedron,
+                             ReferenceCells::get_simplex<dim>(),
                              1,
                              degree,
                              FiniteElementData<dim>::H1),
@@ -838,8 +841,7 @@ FE_SimplexDGP<dim, spacedim>::FE_SimplexDGP(const unsigned int degree)
   : FE_SimplexPoly<dim, spacedim>(
       BarycentricPolynomials<dim>::get_fe_p_basis(degree),
       FiniteElementData<dim>(get_dpo_vector_fe_dgp(dim, degree),
-                             dim == 2 ? ReferenceCells::Triangle :
-                                        ReferenceCells::Tetrahedron,
+                             ReferenceCells::get_simplex<dim>(),
                              1,
                              degree,
                              FiniteElementData<dim>::L2),

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.