]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test. 14754/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 7 Feb 2023 16:59:05 +0000 (09:59 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 7 Feb 2023 20:34:55 +0000 (13:34 -0700)
tests/base/derivative_form_initialization.cc [new file with mode: 0644]
tests/base/derivative_form_initialization.output [new file with mode: 0644]

diff --git a/tests/base/derivative_form_initialization.cc b/tests/base/derivative_form_initialization.cc
new file mode 100644 (file)
index 0000000..be3a409
--- /dev/null
@@ -0,0 +1,60 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Verify that DerivativeForm can be initialized from a
+// Tensor<1,dim,Tensor<order,spacedim>. We used to have a bug where the
+// copy constructor offered Tensor<order,dim,Tensor<1,spacedim> instead,
+// but that was just wrong.
+
+#include <deal.II/base/derivative_form.h>
+
+#include <boost/type_traits.hpp>
+
+#include <complex>
+
+#include "../tests.h"
+
+template <typename Number>
+void
+test()
+{
+  // Choose orders and dimensions so that they are all not equal:
+  constexpr int order    = 2;
+  constexpr int dim      = 1;
+  constexpr int spacedim = 3;
+
+
+  Tensor<order, dim, Number> inner;
+  inner[0][0] = 1;
+  Tensor<1, spacedim, Tensor<order, dim, Number>> t;
+  t[0] = t[1] = t[2] = inner;
+
+  const DerivativeForm<order, dim, spacedim, Number> d(t);
+
+  deallog << "norm: " << d.norm() << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  deallog << "testing float" << std::endl;
+  test<float>();
+
+  deallog << "testing double" << std::endl;
+  test<double>();
+}
diff --git a/tests/base/derivative_form_initialization.output b/tests/base/derivative_form_initialization.output
new file mode 100644 (file)
index 0000000..5a0d6b8
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::testing float
+DEAL::norm: 1.73205
+DEAL::testing double
+DEAL::norm: 1.73205

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.