]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New tests.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 2 Jun 2005 04:29:26 +0000 (04:29 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 2 Jun 2005 04:29:26 +0000 (04:29 +0000)
git-svn-id: https://svn.dealii.org/trunk@10813 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/symmetric_tensor_17.cc [new file with mode: 0644]
tests/results/i686-pc-linux-gnu+gcc3.2/base/symmetric_tensor_17.output [new file with mode: 0644]

diff --git a/tests/base/symmetric_tensor_17.cc b/tests/base/symmetric_tensor_17.cc
new file mode 100644 (file)
index 0000000..f68704f
--- /dev/null
@@ -0,0 +1,81 @@
+//----------------------------  symmetric_tensor_17.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  symmetric_tensor_17.cc  ---------------------------
+
+// compute the tensor C*unit_symmetric_tensor -- I needed this tensor for an
+// application, so thought I'd make a test out of it
+
+#include "../tests.h"
+#include <base/symmetric_tensor.h>
+#include <base/tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+
+template <int dim>
+void test ()
+{
+  deallog << "dim=" << dim << std::endl;
+  
+  SymmetricTensor<4,dim> t;
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j)
+      for (unsigned int k=0; k<dim; ++k)
+        for (unsigned int l=0; l<dim; ++l)
+          t[i][j][k][l] = 10000*(i==j && k==l ? 1 : 0) +
+                          100 * ((i==k && j==l ? 1 : 0) +
+                                 (i==l && j==k ? 1 : 0));
+
+  deallog << "t=" << std::endl;
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j)
+       for (unsigned int k=0; k<dim; ++k)
+         for (unsigned int l=0; l<dim; ++l)
+            deallog << i << ' ' << j << ' ' << k << ' ' << l << ": "
+                    << (int)t[i][j][k][l] << std::endl;
+
+                                   // multiply t by the unit symmetric tensor
+  const SymmetricTensor<2,dim> t_times_1 = t * unit_symmetric_tensor<dim>();
+  
+  deallog << "t*1=" << std::endl;
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j)
+            deallog << i << ' ' << j << ": "
+                    << (int)(t_times_1[i][j])
+                    << std::endl;
+
+                                   // t_times_1 should be a multiple of the
+                                   // unit tensor, given the structure we have
+                                   // given to it
+  Assert ((t_times_1 - (dim*10000 + 2*100)*unit_symmetric_tensor<dim>()).norm()
+          < 1e-14*t_times_1.norm(),
+          ExcInternalError());
+}
+
+  
+
+
+int main ()
+{
+  std::ofstream logfile("symmetric_tensor_17.output");
+  logfile.precision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test<1> ();
+  test<2> ();
+  test<3> ();
+  
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/base/symmetric_tensor_17.output b/tests/results/i686-pc-linux-gnu+gcc3.2/base/symmetric_tensor_17.output
new file mode 100644 (file)
index 0000000..4770b46
--- /dev/null
@@ -0,0 +1,123 @@
+
+DEAL::dim=1
+DEAL::t=
+DEAL::0 0 0 0: 10200
+DEAL::t*1=
+DEAL::0 0: 10200
+DEAL::dim=2
+DEAL::t=
+DEAL::0 0 0 0: 10200
+DEAL::0 0 0 1: 0
+DEAL::0 0 1 0: 0
+DEAL::0 0 1 1: 10000
+DEAL::0 1 0 0: 0
+DEAL::0 1 0 1: 100
+DEAL::0 1 1 0: 100
+DEAL::0 1 1 1: 0
+DEAL::1 0 0 0: 0
+DEAL::1 0 0 1: 100
+DEAL::1 0 1 0: 100
+DEAL::1 0 1 1: 0
+DEAL::1 1 0 0: 10000
+DEAL::1 1 0 1: 0
+DEAL::1 1 1 0: 0
+DEAL::1 1 1 1: 10200
+DEAL::t*1=
+DEAL::0 0: 20200
+DEAL::0 1: 0
+DEAL::1 0: 0
+DEAL::1 1: 20200
+DEAL::dim=3
+DEAL::t=
+DEAL::0 0 0 0: 10200
+DEAL::0 0 0 1: 0
+DEAL::0 0 0 2: 0
+DEAL::0 0 1 0: 0
+DEAL::0 0 1 1: 10000
+DEAL::0 0 1 2: 0
+DEAL::0 0 2 0: 0
+DEAL::0 0 2 1: 0
+DEAL::0 0 2 2: 10000
+DEAL::0 1 0 0: 0
+DEAL::0 1 0 1: 100
+DEAL::0 1 0 2: 0
+DEAL::0 1 1 0: 100
+DEAL::0 1 1 1: 0
+DEAL::0 1 1 2: 0
+DEAL::0 1 2 0: 0
+DEAL::0 1 2 1: 0
+DEAL::0 1 2 2: 0
+DEAL::0 2 0 0: 0
+DEAL::0 2 0 1: 0
+DEAL::0 2 0 2: 100
+DEAL::0 2 1 0: 0
+DEAL::0 2 1 1: 0
+DEAL::0 2 1 2: 0
+DEAL::0 2 2 0: 100
+DEAL::0 2 2 1: 0
+DEAL::0 2 2 2: 0
+DEAL::1 0 0 0: 0
+DEAL::1 0 0 1: 100
+DEAL::1 0 0 2: 0
+DEAL::1 0 1 0: 100
+DEAL::1 0 1 1: 0
+DEAL::1 0 1 2: 0
+DEAL::1 0 2 0: 0
+DEAL::1 0 2 1: 0
+DEAL::1 0 2 2: 0
+DEAL::1 1 0 0: 10000
+DEAL::1 1 0 1: 0
+DEAL::1 1 0 2: 0
+DEAL::1 1 1 0: 0
+DEAL::1 1 1 1: 10200
+DEAL::1 1 1 2: 0
+DEAL::1 1 2 0: 0
+DEAL::1 1 2 1: 0
+DEAL::1 1 2 2: 10000
+DEAL::1 2 0 0: 0
+DEAL::1 2 0 1: 0
+DEAL::1 2 0 2: 0
+DEAL::1 2 1 0: 0
+DEAL::1 2 1 1: 0
+DEAL::1 2 1 2: 100
+DEAL::1 2 2 0: 0
+DEAL::1 2 2 1: 100
+DEAL::1 2 2 2: 0
+DEAL::2 0 0 0: 0
+DEAL::2 0 0 1: 0
+DEAL::2 0 0 2: 100
+DEAL::2 0 1 0: 0
+DEAL::2 0 1 1: 0
+DEAL::2 0 1 2: 0
+DEAL::2 0 2 0: 100
+DEAL::2 0 2 1: 0
+DEAL::2 0 2 2: 0
+DEAL::2 1 0 0: 0
+DEAL::2 1 0 1: 0
+DEAL::2 1 0 2: 0
+DEAL::2 1 1 0: 0
+DEAL::2 1 1 1: 0
+DEAL::2 1 1 2: 100
+DEAL::2 1 2 0: 0
+DEAL::2 1 2 1: 100
+DEAL::2 1 2 2: 0
+DEAL::2 2 0 0: 10000
+DEAL::2 2 0 1: 0
+DEAL::2 2 0 2: 0
+DEAL::2 2 1 0: 0
+DEAL::2 2 1 1: 10000
+DEAL::2 2 1 2: 0
+DEAL::2 2 2 0: 0
+DEAL::2 2 2 1: 0
+DEAL::2 2 2 2: 10200
+DEAL::t*1=
+DEAL::0 0: 30200
+DEAL::0 1: 0
+DEAL::0 2: 0
+DEAL::1 0: 0
+DEAL::1 1: 30200
+DEAL::1 2: 0
+DEAL::2 0: 0
+DEAL::2 1: 0
+DEAL::2 2: 30200
+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.