]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test.
authorWolfgang Bangerth <bangerth@colostate.edu>
Sat, 27 Jun 2020 12:29:53 +0000 (06:29 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 27 Jun 2020 12:30:44 +0000 (06:30 -0600)
tests/tensors/tensor_32.cc [new file with mode: 0644]
tests/tensors/tensor_32.output [new file with mode: 0644]

diff --git a/tests/tensors/tensor_32.cc b/tests/tensors/tensor_32.cc
new file mode 100644 (file)
index 0000000..ba684d8
--- /dev/null
@@ -0,0 +1,54 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 - 2020 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 that we can initialize a Tensor from ArrayView
+
+#include <deal.II/base/symmetric_tensor.h>
+#include <deal.II/base/tensor.h>
+
+#include "../tests.h"
+
+
+template <int dim>
+void
+test()
+{
+  const std::vector<double> values = {1, 2, 3, 4, 5, 6, 7, 8, 9};
+
+  // Check for Tensor<1,dim>
+  deallog << Tensor<1, dim>(
+               make_array_view(values.begin(), values.begin() + dim))
+          << std::endl;
+
+  // Check for Tensor<2,dim>
+  deallog << Tensor<2, dim>(
+               make_array_view(values.begin(), values.begin() + dim * dim))
+          << std::endl;
+}
+
+int
+main(int argc, char *argv[])
+{
+  initlog();
+
+  test<1>();
+  test<2>();
+  test<3>();
+
+  deallog << "OK" << std::endl;
+
+  return 0;
+}
diff --git a/tests/tensors/tensor_32.output b/tests/tensors/tensor_32.output
new file mode 100644 (file)
index 0000000..81470f7
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL::1.00000
+DEAL::1.00000
+DEAL::1.00000 2.00000
+DEAL::1.00000 2.00000 3.00000 4.00000
+DEAL::1.00000 2.00000 3.00000
+DEAL::1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000
+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.