]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New test case
authorMartin Kronbichler <martin.kronbichler@rub.de>
Fri, 5 Apr 2024 08:47:09 +0000 (10:47 +0200)
committerMartin Kronbichler <martin.kronbichler@rub.de>
Fri, 5 Apr 2024 08:47:09 +0000 (10:47 +0200)
tests/base/quadrature_initialize.cc [new file with mode: 0644]
tests/base/quadrature_initialize.output [new file with mode: 0644]

diff --git a/tests/base/quadrature_initialize.cc b/tests/base/quadrature_initialize.cc
new file mode 100644 (file)
index 0000000..674f589
--- /dev/null
@@ -0,0 +1,85 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// test various Quadrature::initialize functions
+
+
+#include <deal.II/base/quadrature_lib.h>
+
+#include "../tests.h"
+
+template <int dim>
+void
+compare_quadratures(const Quadrature<dim> &reference,
+                    const Quadrature<dim> &check)
+{
+  AssertDimension(reference.size(), check.size());
+  for (unsigned int i = 0; i < reference.size(); ++i)
+    {
+      // Check for exact equality because data gets copied, so there should be
+      // no roundoff
+      if (reference.point(i).distance(check.point(i)) > 0)
+        deallog << " error point " << i << reference.point(i) << " vs "
+                << check.point(i);
+      if (reference.weight(i) != check.weight(i))
+        deallog << " error weight " << i << reference.weight(i) << " vs "
+                << check.weight(i);
+    }
+  deallog << "OK" << std::endl;
+}
+
+template <int dim>
+void
+test()
+{
+  deallog.push(std::to_string(dim) + "d");
+  Quadrature<dim> quadrature_2;
+  {
+    QGauss<dim> quad(2);
+    quadrature_2.initialize(quad.get_points(), quad.get_weights());
+    deallog << "Testing initialize(vector&, vector&): ";
+    compare_quadratures(quad, quadrature_2);
+  }
+  {
+    QGauss<dim> quad(3);
+    quadrature_2.initialize(quad.get_points(), quad.get_weights());
+    deallog << "Testing initialize(vector&, vector&): ";
+    compare_quadratures(quad, quadrature_2);
+  }
+  {
+    QGauss<dim> quad(2);
+    quadrature_2.initialize(make_array_view(quad.get_points()),
+                            make_array_view(quad.get_weights()));
+    deallog << "Testing initialize(ArrayView, ArrayView): ";
+    compare_quadratures(quad, quadrature_2);
+  }
+  {
+    Quadrature<dim> quad(quadrature_2.get_points());
+    quadrature_2.initialize(make_array_view(quad.get_points()));
+    deallog << "Testing initialize(ArrayView): ";
+    compare_quadratures(quad, quadrature_2);
+  }
+  deallog.pop();
+}
+
+int
+main()
+{
+  initlog();
+
+  test<1>();
+  test<2>();
+}
diff --git a/tests/base/quadrature_initialize.output b/tests/base/quadrature_initialize.output
new file mode 100644 (file)
index 0000000..d7c4de1
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL:1d::Testing initialize(vector&, vector&): OK
+DEAL:1d::Testing initialize(vector&, vector&): OK
+DEAL:1d::Testing initialize(ArrayView, ArrayView): OK
+DEAL:1d::Testing initialize(ArrayView): OK
+DEAL:2d::Testing initialize(vector&, vector&): OK
+DEAL:2d::Testing initialize(vector&, vector&): OK
+DEAL:2d::Testing initialize(ArrayView, ArrayView): OK
+DEAL:2d::Testing initialize(ArrayView): OK

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.