]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 11 Aug 2016 17:07:21 +0000 (12:07 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 11 Aug 2016 17:15:10 +0000 (12:15 -0500)
tests/base/symmetric_tensor_34.cc [new file with mode: 0644]
tests/base/symmetric_tensor_34.output [new file with mode: 0644]

diff --git a/tests/base/symmetric_tensor_34.cc b/tests/base/symmetric_tensor_34.cc
new file mode 100644 (file)
index 0000000..68cce6e
--- /dev/null
@@ -0,0 +1,78 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Test that we can convert a SymmetricTensor<4,dim> to a Tensor<4,dim>
+
+#include "../tests.h"
+#include <deal.II/base/symmetric_tensor.h>
+#include <deal.II/base/logstream.h>
+
+
+template <int dim>
+void initialize (SymmetricTensor<2,dim> &st)
+{
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=i; j<dim; ++j)
+      st[i][j] = (i+1)*dim + (j-i);
+}
+
+
+template <int dim>
+void initialize (SymmetricTensor<4,dim> &st)
+{
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=i; j<dim; ++j)
+      for (unsigned int k=0; k<dim; ++k)
+        for (unsigned int l=k; l<dim; ++l)
+          st[i][j][k][l] = (i+1)*dim + (j-i)  +  (k+1)*dim + (l-k);
+}
+
+
+
+template <int rank, int dim>
+void check ()
+{
+  // build a regular tensor
+  SymmetricTensor<rank,dim> st;
+  initialize (st);
+  deallog << "st=" << st << std::endl;
+
+  Tensor<rank,dim>          t (st);   // check conversion constructor
+  deallog << "t =" << t << std::endl;
+
+  t = st;                             // check assignment operator
+  deallog << "t =" << t << std::endl;
+}
+
+
+int main ()
+{
+  std::ofstream logfile("output");
+  deallog << std::setprecision(3);
+  deallog.attach(logfile);
+  deallog.threshold_double(1.e-10);
+
+  deallog << "checking rank 2 tensors" << std::endl;
+  check<2,1>();
+  check<2,2>();
+  check<2,3>();
+
+  deallog << "checking rank 4 tensors" << std::endl;
+  check<4,1>();
+  check<4,2>();
+  check<4,3>();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/base/symmetric_tensor_34.output b/tests/base/symmetric_tensor_34.output
new file mode 100644 (file)
index 0000000..f84ec18
--- /dev/null
@@ -0,0 +1,22 @@
+
+DEAL::checking rank 2 tensors
+DEAL::st=1.00
+DEAL::t =1.00
+DEAL::t =1.00
+DEAL::st=2.00 3.00 3.00 4.00
+DEAL::t =2.00 3.00 3.00 4.00
+DEAL::t =2.00 3.00 3.00 4.00
+DEAL::st=3.00 4.00 5.00 4.00 6.00 7.00 5.00 7.00 9.00
+DEAL::t =3.00 4.00 5.00 4.00 6.00 7.00 5.00 7.00 9.00
+DEAL::t =3.00 4.00 5.00 4.00 6.00 7.00 5.00 7.00 9.00
+DEAL::checking rank 4 tensors
+DEAL::st=2.00
+DEAL::t =2.00
+DEAL::t =2.00
+DEAL::st=4.00 5.00 5.00 6.00 5.00 6.00 6.00 7.00 5.00 6.00 6.00 7.00 6.00 7.00 7.00 8.00
+DEAL::t =4.00 5.00 5.00 6.00 5.00 6.00 6.00 7.00 5.00 6.00 6.00 7.00 6.00 7.00 7.00 8.00
+DEAL::t =4.00 5.00 5.00 6.00 5.00 6.00 6.00 7.00 5.00 6.00 6.00 7.00 6.00 7.00 7.00 8.00
+DEAL::st=6.00 7.00 8.00 7.00 9.00 10.0 8.00 10.0 12.0 7.00 8.00 9.00 8.00 10.0 11.0 9.00 11.0 13.0 8.00 9.00 10.0 9.00 11.0 12.0 10.0 12.0 14.0 7.00 8.00 9.00 8.00 10.0 11.0 9.00 11.0 13.0 9.00 10.0 11.0 10.0 12.0 13.0 11.0 13.0 15.0 10.0 11.0 12.0 11.0 13.0 14.0 12.0 14.0 16.0 8.00 9.00 10.0 9.00 11.0 12.0 10.0 12.0 14.0 10.0 11.0 12.0 11.0 13.0 14.0 12.0 14.0 16.0 12.0 13.0 14.0 13.0 15.0 16.0 14.0 16.0 18.0
+DEAL::t =6.00 7.00 8.00 7.00 9.00 10.0 8.00 10.0 12.0 7.00 8.00 9.00 8.00 10.0 11.0 9.00 11.0 13.0 8.00 9.00 10.0 9.00 11.0 12.0 10.0 12.0 14.0 7.00 8.00 9.00 8.00 10.0 11.0 9.00 11.0 13.0 9.00 10.0 11.0 10.0 12.0 13.0 11.0 13.0 15.0 10.0 11.0 12.0 11.0 13.0 14.0 12.0 14.0 16.0 8.00 9.00 10.0 9.00 11.0 12.0 10.0 12.0 14.0 10.0 11.0 12.0 11.0 13.0 14.0 12.0 14.0 16.0 12.0 13.0 14.0 13.0 15.0 16.0 14.0 16.0 18.0
+DEAL::t =6.00 7.00 8.00 7.00 9.00 10.0 8.00 10.0 12.0 7.00 8.00 9.00 8.00 10.0 11.0 9.00 11.0 13.0 8.00 9.00 10.0 9.00 11.0 12.0 10.0 12.0 14.0 7.00 8.00 9.00 8.00 10.0 11.0 9.00 11.0 13.0 9.00 10.0 11.0 10.0 12.0 13.0 11.0 13.0 15.0 10.0 11.0 12.0 11.0 13.0 14.0 12.0 14.0 16.0 8.00 9.00 10.0 9.00 11.0 12.0 10.0 12.0 14.0 10.0 11.0 12.0 11.0 13.0 14.0 12.0 14.0 16.0 12.0 13.0 14.0 13.0 15.0 16.0 14.0 16.0 18.0
+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.