]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix nodal and Gauss-type quadratures for dim = 0. 14999/head
authorDavid Wells <drwells@email.unc.edu>
Thu, 30 Mar 2023 18:41:09 +0000 (14:41 -0400)
committerDavid Wells <drwells@email.unc.edu>
Thu, 30 Mar 2023 18:46:36 +0000 (14:46 -0400)
include/deal.II/grid/reference_cell.h
source/base/quadrature_lib.cc
source/grid/reference_cell.cc
tests/grid/reference_cell_type_03_q.cc
tests/grid/reference_cell_type_03_q.output
tests/simplex/nodal_type_quadrature_01.cc [new file with mode: 0644]
tests/simplex/nodal_type_quadrature_01.output [new file with mode: 0644]

index 8392edacb14ae0487cbde2f50b216be96c33f52e..2a70b4d5a01ab33f9eb5332ec77f70aae058040f 100644 (file)
@@ -1226,7 +1226,7 @@ ReferenceCell::vertex(const unsigned int v) const
       case 0:
         {
           if (*this == ReferenceCells::Vertex)
-            return Point<dim>(0);
+            return Point<dim>();
           break;
         }
       case 1:
index 3e28a1e9a0003c8333bf75258fc10ac22e35d732..9218b04ef056ca9409fc728efa25063fefb83c4b 100644 (file)
@@ -2228,9 +2228,11 @@ template class QGaussSimplex<0>;
 template class QGaussSimplex<1>;
 template class QGaussSimplex<2>;
 template class QGaussSimplex<3>;
+template class QGaussWedge<0>;
 template class QGaussWedge<1>;
 template class QGaussWedge<2>;
 template class QGaussWedge<3>;
+template class QGaussPyramid<0>;
 template class QGaussPyramid<1>;
 template class QGaussPyramid<2>;
 template class QGaussPyramid<3>;
index d7e7b0e9b3ad5644e0866d481308d6581774fd0d..2eb2aa2d5192aa881a50f94eac7dadfb092c5c8c 100644 (file)
@@ -848,7 +848,12 @@ operator>>(std::istream &in, ReferenceCell &reference_cell)
   return in;
 }
 
-
+// explicitly instantiate dimension 0 quadrature in addition to the standard
+// dimensions
+template Quadrature<0>
+ReferenceCell::get_gauss_type_quadrature(const unsigned n_points_1D) const;
+template const Quadrature<0> &
+ReferenceCell::get_nodal_type_quadrature() const;
 
 #include "reference_cell.inst"
 
index 755f4cd225f696515984c606e8eca8bfa156c8d1..d4975490f17e893ef07289d3ee876f519408562d 100644 (file)
@@ -66,6 +66,16 @@ main()
 {
   initlog();
 
+  {
+    deallog.push("0D");
+    // It doesn't make sense to integrate in 0D, but make sure that
+    // get_gauss_type_quadrature() still works
+    deallog << "0D quadrature size: "
+            << ReferenceCells::Vertex.get_gauss_type_quadrature<0>(1).size()
+            << std::endl;
+    deallog.pop();
+  }
+
   {
     deallog.push("1D");
     test<1>(ReferenceCells::Line);
index 42bbf999680a60a5007aa604b01ccb10769e8a32..dd920473ba18173e4615721a3d44dc712609184f 100644 (file)
@@ -1,4 +1,5 @@
 
+DEAL:0D::0D quadrature size: 1
 DEAL:1D::ReferenceCell: Line
 DEAL:1D::  computed barycenter = 0.500000
 DEAL:1D::  self-reported barycenter = 0.500000
diff --git a/tests/simplex/nodal_type_quadrature_01.cc b/tests/simplex/nodal_type_quadrature_01.cc
new file mode 100644 (file)
index 0000000..d6c09a6
--- /dev/null
@@ -0,0 +1,87 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2023 - 2023 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// Test ReferenceCell::get_nodal_type_quadrature()
+
+#include <deal.II/base/quadrature.h>
+
+#include <deal.II/grid/reference_cell.h>
+
+#include "../tests.h"
+
+using namespace dealii;
+
+template <int dim>
+void
+test(const ReferenceCell reference_cell)
+{
+  const Quadrature<dim> &quad =
+    reference_cell.template get_nodal_type_quadrature<dim>();
+
+  for (unsigned int q = 0; q < quad.size(); ++q)
+    {
+      // There is nothing to print for dim = 0 in the point
+      if (dim > 0)
+        deallog << quad.point(q) << ' ';
+      deallog << quad.weight(q) << ' ';
+      deallog << std::endl;
+    }
+}
+
+int
+main()
+{
+  initlog();
+
+  {
+    deallog.push("0d");
+    deallog.pop();
+  }
+  {
+    deallog.push("1d");
+    test<1>(ReferenceCells::Line);
+    deallog.pop();
+  }
+  {
+    deallog.push("2d-1");
+    test<2>(ReferenceCells::Triangle);
+    deallog.pop();
+  }
+  {
+    deallog.push("2d-2");
+    test<2>(ReferenceCells::Quadrilateral);
+    deallog.pop();
+  }
+  {
+    deallog.push("3d-1");
+    test<3>(ReferenceCells::Tetrahedron);
+    deallog.pop();
+  }
+  {
+    deallog.push("3d-2");
+    test<3>(ReferenceCells::Pyramid);
+    deallog.pop();
+  }
+  {
+    deallog.push("3d-2");
+    test<3>(ReferenceCells::Wedge);
+    deallog.pop();
+  }
+  {
+    deallog.push("3d-3");
+    test<3>(ReferenceCells::Hexahedron);
+    deallog.pop();
+  }
+}
diff --git a/tests/simplex/nodal_type_quadrature_01.output b/tests/simplex/nodal_type_quadrature_01.output
new file mode 100644 (file)
index 0000000..82bb892
--- /dev/null
@@ -0,0 +1,33 @@
+
+DEAL:1d::0.00000 inf 
+DEAL:1d::1.00000 inf 
+DEAL:2d-1::0.00000 0.00000 inf 
+DEAL:2d-1::1.00000 0.00000 inf 
+DEAL:2d-1::0.00000 1.00000 inf 
+DEAL:2d-2::0.00000 0.00000 inf 
+DEAL:2d-2::1.00000 0.00000 inf 
+DEAL:2d-2::0.00000 1.00000 inf 
+DEAL:2d-2::1.00000 1.00000 inf 
+DEAL:3d-1::0.00000 0.00000 0.00000 inf 
+DEAL:3d-1::1.00000 0.00000 0.00000 inf 
+DEAL:3d-1::0.00000 1.00000 0.00000 inf 
+DEAL:3d-1::0.00000 0.00000 1.00000 inf 
+DEAL:3d-2::-1.00000 -1.00000 0.00000 inf 
+DEAL:3d-2::1.00000 -1.00000 0.00000 inf 
+DEAL:3d-2::-1.00000 1.00000 0.00000 inf 
+DEAL:3d-2::1.00000 1.00000 0.00000 inf 
+DEAL:3d-2::0.00000 0.00000 1.00000 inf 
+DEAL:3d-2::0.00000 0.00000 0.00000 inf 
+DEAL:3d-2::1.00000 0.00000 0.00000 inf 
+DEAL:3d-2::0.00000 1.00000 0.00000 inf 
+DEAL:3d-2::0.00000 0.00000 1.00000 inf 
+DEAL:3d-2::1.00000 0.00000 1.00000 inf 
+DEAL:3d-2::0.00000 1.00000 1.00000 inf 
+DEAL:3d-3::0.00000 0.00000 0.00000 inf 
+DEAL:3d-3::1.00000 0.00000 0.00000 inf 
+DEAL:3d-3::0.00000 1.00000 0.00000 inf 
+DEAL:3d-3::1.00000 1.00000 0.00000 inf 
+DEAL:3d-3::0.00000 0.00000 1.00000 inf 
+DEAL:3d-3::1.00000 0.00000 1.00000 inf 
+DEAL:3d-3::0.00000 1.00000 1.00000 inf 
+DEAL:3d-3::1.00000 1.00000 1.00000 inf 

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.