From: Wolfgang Bangerth Date: Tue, 29 Mar 2005 21:24:59 +0000 (+0000) Subject: New testcase. X-Git-Tag: v8.0.0~14247 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a9b258f5f8503ff0a8ba07965cdb67406ed23fe;p=dealii.git New testcase. git-svn-id: https://svn.dealii.org/trunk@10300 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/base/symmetric_tensor_03.cc b/tests/base/symmetric_tensor_03.cc new file mode 100644 index 0000000000..72d35a9b45 --- /dev/null +++ b/tests/base/symmetric_tensor_03.cc @@ -0,0 +1,55 @@ +//---------------------------- 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 +#include +#include +#include + +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; +} diff --git a/tests/base/symmetric_tensor_04.cc b/tests/base/symmetric_tensor_04.cc new file mode 100644 index 0000000000..9a6af12cd7 --- /dev/null +++ b/tests/base/symmetric_tensor_04.cc @@ -0,0 +1,55 @@ +//---------------------------- 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 +#include +#include +#include + +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; +} diff --git a/tests/base/symmetric_tensor_05.cc b/tests/base/symmetric_tensor_05.cc new file mode 100644 index 0000000000..833a07756a --- /dev/null +++ b/tests/base/symmetric_tensor_05.cc @@ -0,0 +1,88 @@ +//---------------------------- 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 +#include +#include +#include + + +template +void test () +{ + SymmetricTensor<4,dim> t; + for (unsigned int i=0; i a, b; + a[0][0] = 1; + a[1][1] = 2; + a[0][1] = 3; + + for (unsigned int i=0; i (); + test<3> (); + + deallog << "OK" << std::endl; +}