]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a second testcase.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 28 Mar 2005 22:17:28 +0000 (22:17 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 28 Mar 2005 22:17:28 +0000 (22:17 +0000)
git-svn-id: https://svn.dealii.org/trunk@10263 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/base/symmetric_tensor_02.cc b/tests/base/symmetric_tensor_02.cc
new file mode 100644 (file)
index 0000000..72c71a2
--- /dev/null
@@ -0,0 +1,60 @@
+//----------------------------  symmetric_tensor_02.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_02.cc  ---------------------------
+
+// test symmetric 3x3 tensors
+
+#include "../tests.h"
+#include <base/symmetric_tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+int main ()
+{
+  std::ofstream logfile("symmetric_tensor_02.output");
+  logfile.precision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  
+  SymmetricTensor<2,3> t3;
+  t3[0][0] = 1;
+  t3[1][1] = 2;
+  t3[2][2] = 3;
+  t3[0][1] = 4;
+  t3[0][2] = 5;
+  t3[1][2] = 6;
+
+  Assert (t3[0][1] == t3[1][0], ExcInternalError());
+
+                                   // check that if a single element is
+                                   // accessed, its transpose element gets the
+                                   // same value
+  t3[1][0] = 14;
+  Assert (t3[0][1] == 14, ExcInternalError());
+
+                                   // make sure transposition doesn't change
+                                   // anything
+  Assert (t3 == transpose(t3), ExcInternalError());
+
+                                   // check norm of tensor
+  Assert (std::fabs(t3.norm() - std::sqrt(1.*1+2*2+3*3+2*14*14+2*5*5+2*6*6))
+          < 1e-14,
+          ExcInternalError());
+
+                                   // make sure norm is induced by scalar
+                                   // product
+  Assert (std::fabs (t3.norm()*t3.norm() - t3*t3) < 1e-14,
+          ExcInternalError());
+
+  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.