]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add new test for symmetric tensors.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 28 Mar 2005 22:06:40 +0000 (22:06 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 28 Mar 2005 22:06:40 +0000 (22:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@10261 0785d39b-7218-0410-832d-ea1e28bc413d

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

index ff654f765f39b196fc9b7d80d955a787afaddeff..7d677602d2bc5a8d291346bf9ffaf5e8db8ffb9a 100644 (file)
@@ -29,6 +29,7 @@ tests_x =  logtest \
           slice_vector \
           table \
           tensor \
+          symmetric_tensor_* \
            timer \
           threads \
           polynomial* \
diff --git a/tests/base/symmetric_tensor_01.cc b/tests/base/symmetric_tensor_01.cc
new file mode 100644 (file)
index 0000000..04b3312
--- /dev/null
@@ -0,0 +1,56 @@
+//----------------------------  symmetric_tensor_01.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_01.cc  ---------------------------
+
+
+#include "../tests.h"
+#include <base/symmetric_tensor.h>
+#include <base/logstream.h>
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+
+int main ()
+{
+  std::ofstream logfile("symmetric_tensor_01.output");
+  logfile.precision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  
+  SymmetricTensor<2,2> t2;
+  t2[0][0] = 1;
+  t2[1][1] = 2;
+  t2[0][1] = 3;
+
+  Assert (t2[0][1] == t2[1][0], ExcInternalError());
+
+                                   // check that if a single element is
+                                   // accessed, its transpose element gets the
+                                   // same value
+  t2[1][0] = 4;
+  Assert (t2[0][1] == 4, ExcInternalError());
+
+                                   // make sure transposition doesn't change
+                                   // anything
+  Assert (t2 == transpose(t2), ExcInternalError());
+
+                                   // check norm of tensor
+  Assert (std::fabs(t2.norm() - std::sqrt(1.*1+2*2+2*4*4)) < 1e-14,
+          ExcInternalError());
+
+                                   // make sure norm is induced by scalar
+                                   // product
+  Assert (std::fabs (t2.norm()*t2.norm() - t2*t2) < 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.