table \
tensor \
symmetric_tensor_* \
+ full_tensor_* \
timer \
threads \
polynomial* \
--- /dev/null
+//---------------------------- full_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.
+//
+//---------------------------- full_tensor_01.cc ---------------------------
+
+// test full 2x2 tensors
+
+#include "../tests.h"
+#include <base/tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+int main ()
+{
+ std::ofstream logfile("full_tensor_01.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ Tensor<2,2> t;
+ t[0][0] = 1;
+ t[1][1] = 2;
+ t[0][1] = 4;
+ t[1][0] = 4;
+ // make sure transposition doesn't change
+ // anything
+ Assert (t == transpose(t), ExcInternalError());
+
+ // check norm of tensor
+ Assert (std::fabs(t.norm() - std::sqrt(1.*1+2*2+2*4*4)) < 1e-14,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+//---------------------------- full_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.
+//
+//---------------------------- full_tensor_02.cc ---------------------------
+
+// test full 3x3 tensors
+
+#include "../tests.h"
+#include <base/tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+int main ()
+{
+ std::ofstream logfile("full_tensor_02.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ Tensor<2,3> t;
+ t[0][0] = 1;
+ t[1][1] = 2;
+ t[2][2] = 3;
+ t[0][1] = 4;
+ t[1][0] = 4;
+ t[0][2] = 5;
+ t[2][0] = 5;
+ t[1][2] = 6;
+ t[2][1] = 6;
+
+ Assert (t[0][1] == t[1][0], ExcInternalError());
+
+ // make sure transposition doesn't change
+ // anything
+ Assert (t == transpose(t), ExcInternalError());
+
+ // check norm of tensor
+ Assert (std::fabs(t.norm() - std::sqrt(1.*1+2*2+3*3+2*4*4+2*5*5+2*6*6))
+ < 1e-14,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+//---------------------------- full_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.
+//
+//---------------------------- full_tensor_03.cc ---------------------------
+
+// test full 2x2x2x2 tensors
+
+#include "../tests.h"
+#include <base/tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+int main ()
+{
+ std::ofstream logfile("full_tensor_03.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ Tensor<4,2> t;
+ t[0][0][0][0] = 1;
+ t[1][1][1][1] = 2;
+ t[0][1][0][1] = 3;
+ t[1][0][1][0] = 3;
+
+ Assert (t[0][1][0][1] == t[1][0][1][0], ExcInternalError());
+
+ // check norm of tensor
+ deallog << t.norm() << std::endl;
+
+ // make sure norm is induced by scalar
+ // product
+ double norm_sqr = 0;
+ for (unsigned int i=0; i<2; ++i)
+ for (unsigned int j=0; j<2; ++j)
+ for (unsigned int k=0; k<2; ++k)
+ for (unsigned int l=0; l<2; ++l)
+ norm_sqr += t[i][j][k][l] * t[i][j][k][l];
+
+ Assert (std::fabs (t.norm()*t.norm() - norm_sqr) < 1e-14,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+//---------------------------- full_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.
+//
+//---------------------------- full_tensor_04.cc ---------------------------
+
+// test full 3x3x3x3 tensors
+
+#include "../tests.h"
+#include <base/tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+int main ()
+{
+ std::ofstream logfile("full_tensor_04.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ Tensor<4,3> t;
+ t[0][0][0][0] = 1;
+ t[1][1][1][1] = 2;
+ t[0][1][0][1] = 3;
+ t[1][0][1][0] = 3;
+
+ Assert (t[0][1][0][1] == t[1][0][1][0], ExcInternalError());
+
+ // check norm of tensor
+ deallog << t.norm() << std::endl;
+
+ // make sure norm is induced by scalar
+ // product
+ double norm_sqr = 0;
+ for (unsigned int i=0; i<2; ++i)
+ for (unsigned int j=0; j<2; ++j)
+ for (unsigned int k=0; k<2; ++k)
+ for (unsigned int l=0; l<2; ++l)
+ norm_sqr += t[i][j][k][l] * t[i][j][k][l];
+ Assert (std::fabs (t.norm()*t.norm() - norm_sqr) < 1e-14,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+//---------------------------- full_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.
+//
+//---------------------------- full_tensor_05.cc ---------------------------
+
+// make sure the tensor t_ijkl=delta_ik delta_jl
+// actually maps a rank-2 tensor onto twice itself
+
+#include "../tests.h"
+#include <base/tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+
+template <int dim>
+void test ()
+{
+ Tensor<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);
+
+ Tensor<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, 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/2, ExcInternalError());
+}
+
+
+
+
+int main ()
+{
+ std::ofstream logfile("full_tensor_05.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ test<2> ();
+ test<3> ();
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+//---------------------------- full_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.
+//
+//---------------------------- full_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/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;
+ Tensor<4,dim> ts;
+ Tensor<4,dim> ta;
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=0; j<dim; ++j)
+ {
+ ta[i][j][i][j] += mu;
+ ta[i][j][j][i] += mu;
+ ta[i][i][j][j] += lambda;
+ }
+ 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];
+
+ Tensor<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("full_tensor_06.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ test<2> ();
+ test<3> ();
+
+ deallog << "OK" << std::endl;
+}