]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test. 18571/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 19 Jun 2025 00:18:25 +0000 (18:18 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 19 Jun 2025 00:32:35 +0000 (18:32 -0600)
tests/base/functions_16.cc [new file with mode: 0644]
tests/base/functions_16.output [new file with mode: 0644]

diff --git a/tests/base/functions_16.cc b/tests/base/functions_16.cc
new file mode 100644 (file)
index 0000000..23ea12b
--- /dev/null
@@ -0,0 +1,79 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2011 - 2018 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 VectorFunctionFromTensorFunctionObject
+
+#include <deal.II/base/function.h>
+#include <deal.II/base/tensor_function.h>
+
+#include <deal.II/lac/vector.h>
+
+#include "../tests.h"
+
+
+
+template <int dim>
+void
+check1()
+{
+  const auto x = [](const Point<dim> &p) -> Tensor<1, dim> { return p; };
+
+  VectorFunctionFromTensorFunctionObject<dim> object(x, 1, dim + 2);
+
+  AssertThrow(object.n_components == dim + 2, ExcInternalError());
+
+  for (unsigned int i = 0; i < 10; ++i)
+    {
+      Point<dim> p;
+      for (unsigned int d = 0; d < dim; ++d)
+        p[d] = i + d;
+
+      for (unsigned int c = 0; c < dim + 2; ++c)
+        if (c == 0 || c == dim + 1)
+          {
+            AssertThrow(object.value(p, c) == 0, ExcInternalError());
+          }
+        else
+          {
+            AssertThrow(object.value(p, c) == p[c - 1], ExcInternalError());
+          }
+
+      Vector<double> v(dim + 2);
+      object.vector_value(p, v);
+      for (unsigned int c = 0; c < dim + 2; ++c)
+        if (c == 0 || c == dim + 1)
+          {
+            AssertThrow(v(c) == 0, ExcInternalError());
+          }
+        else
+          {
+            AssertThrow(v(c) == p[c - 1], ExcInternalError());
+          }
+    }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int
+main()
+{
+  initlog();
+
+  check1<1>();
+  check1<2>();
+  check1<3>();
+}
diff --git a/tests/base/functions_16.output b/tests/base/functions_16.output
new file mode 100644 (file)
index 0000000..fb71de2
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::OK
+DEAL::OK
+DEAL::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.