From 616e9a68c5d3c0de468a3e80b084c85c59ddbbce Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 28 Mar 2005 22:17:28 +0000 Subject: [PATCH] Add a second testcase. git-svn-id: https://svn.dealii.org/trunk@10263 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/symmetric_tensor_02.cc | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/base/symmetric_tensor_02.cc diff --git a/tests/base/symmetric_tensor_02.cc b/tests/base/symmetric_tensor_02.cc new file mode 100644 index 0000000000..72c71a232f --- /dev/null +++ b/tests/base/symmetric_tensor_02.cc @@ -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 +#include +#include +#include + +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; +} -- 2.39.5