]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New testcase comparing symmetric tensors and asymmetric ones.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Mar 2005 21:46:16 +0000 (21:46 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Mar 2005 21:46:16 +0000 (21:46 +0000)
git-svn-id: https://svn.dealii.org/trunk@10303 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/base/symmetric_tensor_06.cc b/tests/base/symmetric_tensor_06.cc
new file mode 100644 (file)
index 0000000..2426bc5
--- /dev/null
@@ -0,0 +1,87 @@
+//----------------------------  symmetric_tensor_06.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_06.cc  ---------------------------
+
+// make sure a tensor similar to the elasticity tensor for the
+// isotropic case works as expected by comparing with a full tensor
+
+#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 = 5,
+              mu     = 7;
+  SymmetricTensor<4,dim> ts;
+  Tensor<4,dim>          ta;
+  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)
+         ts[i][j][k][l] = ta[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> as, bs;
+  Tensor<2,dim>          aa, ba;
+
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j)
+      as[i][j] = aa[i][j] = (1. + (i+1)*(j+1));
+      
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j)
+      {
+       double tmp_ij = 0;
+       for (unsigned int k=0; k<dim; ++k)
+         for (unsigned int l=0; l<dim; ++l)
+           {
+             deallog << i << ' ' << j << ' ' << k << ' ' << l << ": "
+                     << ta[i][j][k][l] << ' ' << ts[i][j][k][l] << ' '
+                     << aa[k][l] << ' ' << as[k][l]
+                     << std::endl;
+             tmp_ij += ts[i][j][k][l] * as[k][l];
+           }
+       bs[i][j] = tmp_ij;
+      }
+  double_contract (ba, ta, aa);
+  
+  for (unsigned int i=0; i<dim; ++i)
+    for (unsigned int j=0; j<dim; ++j) 
+      {
+       Assert (as[i][j] == aa[i][j], ExcInternalError());
+       Assert (bs[i][j] == ba[i][j], ExcInternalError());
+      }
+  
+}
+
+  
+
+
+int main ()
+{
+  std::ofstream logfile("symmetric_tensor_06.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.