--- /dev/null
+//---------------------------- symmetric_tensor_03.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_03.cc ---------------------------
+
+// test symmetric 2x2x2x2 tensors
+
+#include "../tests.h"
+#include <base/symmetric_tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+int main ()
+{
+ std::ofstream logfile("symmetric_tensor_03.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ SymmetricTensor<4,2> t;
+ t[0][0][0][0] = 1;
+ t[1][1][1][1] = 2;
+ t[0][1][0][1] = 3;
+
+ Assert (t[0][1][0][1] == t[1][0][1][0], ExcInternalError());
+
+ // check that if a single element is
+ // accessed, its transpose element gets the
+ // same value
+ t[1][0][0][1] = 4;
+ Assert (t[0][1][1][0] == 4, ExcInternalError());
+
+ // make sure transposition doesn't change
+ // anything
+ Assert (t == transpose(t), ExcInternalError());
+
+ // check norm of tensor
+ deallog << t.norm() << std::endl;
+
+ // make sure norm is induced by scalar
+ // product
+ Assert (std::fabs (t.norm()*t.norm() - t*t) < 1e-14,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+//---------------------------- symmetric_tensor_04.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_04.cc ---------------------------
+
+// test symmetric 3x3x3x3 tensors
+
+#include "../tests.h"
+#include <base/symmetric_tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+int main ()
+{
+ std::ofstream logfile("symmetric_tensor_04.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ SymmetricTensor<4,3> t;
+ t[0][0][0][0] = 1;
+ t[1][1][1][1] = 2;
+ t[0][1][0][1] = 3;
+
+ Assert (t[0][1][0][1] == t[1][0][1][0], ExcInternalError());
+
+ // check that if a single element is
+ // accessed, its transpose element gets the
+ // same value
+ t[1][0][0][1] = 4;
+ Assert (t[0][1][1][0] == 4, ExcInternalError());
+
+ // make sure transposition doesn't change
+ // anything
+ Assert (t == transpose(t), ExcInternalError());
+
+ // check norm of tensor
+ deallog << t.norm() << std::endl;
+
+ // make sure norm is induced by scalar
+ // product
+ Assert (std::fabs (t.norm()*t.norm() - t*t) < 1e-14,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+//---------------------------- symmetric_tensor_05.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_05.cc ---------------------------
+
+// make sure the tensor t_ijkl=delta_ik delta_jl + delta_il delta_jk
+// actually maps a rank-2 tensor onto twice itself
+
+#include "../tests.h"
+#include <base/symmetric_tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+
+template <int dim>
+void test ()
+{
+ 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) ? 1 : 0) +
+ ((i==l) && (j==k) ? 1 : 0));
+
+ SymmetricTensor<2,dim> a, b;
+ a[0][0] = 1;
+ a[1][1] = 2;
+ a[0][1] = 3;
+
+ 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 << ": "
+ << t[i][j][k][l] << ' ' << a[k][l]
+ << std::endl;
+ tmp_ij += t[i][j][k][l] * a[k][l];
+ }
+ b[i][j] = tmp_ij;
+ }
+
+ Assert (a == b/2, ExcInternalError());
+
+ // try the same thing with scaled
+ // tensors etc
+ t *= 2;
+ b.clear ();
+ 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)
+ tmp_ij += t[i][j][k][l] * a[k][l];
+ b[i][j] = tmp_ij;
+ }
+
+ Assert (a == b/4, ExcInternalError());
+}
+
+
+
+
+int main ()
+{
+ std::ofstream logfile("symmetric_tensor_05.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ test<2> ();
+ test<3> ();
+
+ deallog << "OK" << std::endl;
+}