]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New test.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Mar 2005 23:42:28 +0000 (23:42 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Mar 2005 23:42:28 +0000 (23:42 +0000)
git-svn-id: https://svn.dealii.org/trunk@10313 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/symmetric_tensor_08.cc [new file with mode: 0644]

diff --git a/tests/base/symmetric_tensor_08.cc b/tests/base/symmetric_tensor_08.cc
new file mode 100644 (file)
index 0000000..659db99
--- /dev/null
@@ -0,0 +1,77 @@
+//----------------------------  symmetric_tensor_08.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_08.cc  ---------------------------
+
+// a stress test using repeated multiplication of tensors
+
+#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 ()
+{
+  const double lambda = 1.5,
+              mu     = 1.7;
+  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] = (((i==k) && (j==l) ? mu : 0) +
+                          ((i==l) && (j==k) ? mu : 0) +
+                          ((i==j) && (k==l) ? lambda : 0));
+         
+  SymmetricTensor<2,dim> a, b;
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j)
+      a[i][j] = (1. + (i+1)*(j+1));
+
+                                  // stress test the whole thing many
+                                  // times. normalize in each step to
+                                  // make sure the result remains
+                                  // representable in floating point
+                                  // arithmetic. essentially, this
+                                  // invokes the power method to
+                                  // compute the largest eigenvector
+                                  // (eigentensor in this case)
+  for (unsigned int i=0; i<1000000; ++i)
+    {
+      a = t*a;
+      a /= a.norm();
+    }
+
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j) 
+      deallog << i << ' ' << j << ' ' << a[i][j] << std::endl;
+}
+
+  
+
+
+int main ()
+{
+  std::ofstream logfile("symmetric_tensor_08.output");
+  logfile.precision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test<2> ();
+  test<3> ();
+  
+  deallog << "OK" << std::endl;
+}

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.