]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 1 Jun 2005 00:25:57 +0000 (00:25 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 1 Jun 2005 00:25:57 +0000 (00:25 +0000)
git-svn-id: https://svn.dealii.org/trunk@10799 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/base/symmetric_tensor_15.cc b/tests/base/symmetric_tensor_15.cc
new file mode 100644 (file)
index 0000000..80104c3
--- /dev/null
@@ -0,0 +1,86 @@
+//----------------------------  symmetric_tensor_15.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_15.cc  ---------------------------
+
+// test outer_product
+
+#include "../tests.h"
+#include <base/symmetric_tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+
+template <int dim>
+void test ()
+{
+  deallog << "dim=" << dim << std::endl;
+  
+  SymmetricTensor<2,dim> t;
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=i; j<dim; ++j)
+      t[i][j] = (1.+(i+1)*(j*2));
+
+                                   // test 1: check trace-like operator
+  {
+    const SymmetricTensor<4,dim> T
+      = outer_product<dim> (unit_symmetric_tensor<dim>(),
+                            unit_symmetric_tensor<dim>());
+
+                                     // T*t should yield a diagonal tensor
+                                     // where the diagonal elements are the
+                                     // traces of t
+    SymmetricTensor<2,dim> x = T * t;
+    Assert ((x-trace(t)*unit_symmetric_tensor<dim>()).norm()
+            < 1e-15*t.norm(), ExcInternalError());
+
+    deallog << "x=" << std::endl;
+    for (unsigned int i=0; i<dim; ++i)
+      for (unsigned int j=0; j<dim; ++j)
+        deallog << i << ' ' << j << ' ' << x[i][j] << std::endl;
+  }
+
+                                   // test 2: check outer product of t with
+                                   // itself
+  {
+    const SymmetricTensor<4,dim> T = outer_product<dim> (t,t);
+
+                                     // T*t should yield norm(t)^2*t
+    SymmetricTensor<2,dim> x = T * t;
+    Assert ((x-(t*t)*t).norm()
+            < 1e-15*t.norm(), ExcInternalError());
+
+    deallog << "x=" << std::endl;
+    for (unsigned int i=0; i<dim; ++i)
+      for (unsigned int j=0; j<dim; ++j)
+        deallog << i << ' ' << j << ' ' << x[i][j] << std::endl;
+  }
+  
+}
+
+  
+
+
+int main ()
+{
+  std::ofstream logfile("symmetric_tensor_15.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/base/symmetric_tensor_16.cc b/tests/base/symmetric_tensor_16.cc
new file mode 100644 (file)
index 0000000..2191d96
--- /dev/null
@@ -0,0 +1,53 @@
+//----------------------------  symmetric_tensor_16.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_16.cc  ---------------------------
+
+// compute the deviator tensor as stated in the documentation of outer_product
+
+#include "../tests.h"
+#include <base/symmetric_tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+
+template <int dim>
+void test ()
+{
+  deallog << "dim=" << dim << std::endl;
+
+  const SymmetricTensor<4,dim>
+    T = (identity_tensor<dim>()
+         - 1./dim * outer_product(unit_symmetric_tensor<dim>(),
+                                  unit_symmetric_tensor<dim>()));
+
+  Assert ((T-deviator_tensor<dim>()).norm()
+          <= 1e-15*T.norm(), ExcInternalError());
+}
+
+  
+
+
+int main ()
+{
+  std::ofstream logfile("symmetric_tensor_16.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_15.output b/tests/results/i686-pc-linux-gnu+gcc3.2/base/symmetric_tensor_15.output
new file mode 100644 (file)
index 0000000..6efb219
--- /dev/null
@@ -0,0 +1,39 @@
+
+DEAL::dim=1
+DEAL::x=
+DEAL::0 0 1.00
+DEAL::x=
+DEAL::0 0 1.00
+DEAL::dim=2
+DEAL::x=
+DEAL::0 0 6.00
+DEAL::0 1 0
+DEAL::1 0 0
+DEAL::1 1 6.00
+DEAL::x=
+DEAL::0 0 44.0
+DEAL::0 1 132.
+DEAL::1 0 132.
+DEAL::1 1 220.
+DEAL::dim=3
+DEAL::x=
+DEAL::0 0 19.0
+DEAL::0 1 0
+DEAL::0 2 0
+DEAL::1 0 0
+DEAL::1 1 19.0
+DEAL::1 2 0
+DEAL::2 0 0
+DEAL::2 1 0
+DEAL::2 2 19.0
+DEAL::x=
+DEAL::0 0 425.
+DEAL::0 1 1.28e+03
+DEAL::0 2 2.12e+03
+DEAL::1 0 1.28e+03
+DEAL::1 1 2.12e+03
+DEAL::1 2 3.82e+03
+DEAL::2 0 2.12e+03
+DEAL::2 1 3.82e+03
+DEAL::2 2 5.52e+03
+DEAL::OK
diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/base/symmetric_tensor_16.output b/tests/results/i686-pc-linux-gnu+gcc3.2/base/symmetric_tensor_16.output
new file mode 100644 (file)
index 0000000..fe42c7c
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::dim=1
+DEAL::dim=2
+DEAL::dim=3
+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.