From c377f4d4b49b40a3d7a3784d4c296a6924f3e498 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 1 Jun 2005 00:25:57 +0000 Subject: [PATCH] New test. git-svn-id: https://svn.dealii.org/trunk@10799 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/symmetric_tensor_15.cc | 86 +++++++++++++++++++++++++++++++ tests/base/symmetric_tensor_16.cc | 53 +++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 tests/base/symmetric_tensor_15.cc create mode 100644 tests/base/symmetric_tensor_16.cc diff --git a/tests/base/symmetric_tensor_15.cc b/tests/base/symmetric_tensor_15.cc new file mode 100644 index 0000000000..80104c3c0c --- /dev/null +++ b/tests/base/symmetric_tensor_15.cc @@ -0,0 +1,86 @@ +//---------------------------- symmetric_tensor_15.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_15.cc --------------------------- + +// test outer_product + +#include "../tests.h" +#include +#include +#include +#include + + +template +void test () +{ + deallog << "dim=" << dim << std::endl; + + SymmetricTensor<2,dim> t; + for (unsigned int i=0; i T + = outer_product (unit_symmetric_tensor(), + unit_symmetric_tensor()); + + // T*t should yield a diagonal tensor + // where the diagonal elements are the + // traces of t + SymmetricTensor<2,dim> x = T * t; + Assert ((x-trace(t)*unit_symmetric_tensor()).norm() + < 1e-15*t.norm(), ExcInternalError()); + + deallog << "x=" << std::endl; + for (unsigned int i=0; i T = outer_product (t,t); + + // T*t should yield norm(t)^2*t + SymmetricTensor<2,dim> x = T * t; + Assert ((x-(t*t)*t).norm() + < 1e-15*t.norm(), ExcInternalError()); + + deallog << "x=" << std::endl; + for (unsigned int i=0; i (); + test<2> (); + test<3> (); + + deallog << "OK" << std::endl; +} diff --git a/tests/base/symmetric_tensor_16.cc b/tests/base/symmetric_tensor_16.cc new file mode 100644 index 0000000000..2191d96f44 --- /dev/null +++ b/tests/base/symmetric_tensor_16.cc @@ -0,0 +1,53 @@ +//---------------------------- symmetric_tensor_16.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_16.cc --------------------------- + +// compute the deviator tensor as stated in the documentation of outer_product + +#include "../tests.h" +#include +#include +#include +#include + + +template +void test () +{ + deallog << "dim=" << dim << std::endl; + + const SymmetricTensor<4,dim> + T = (identity_tensor() + - 1./dim * outer_product(unit_symmetric_tensor(), + unit_symmetric_tensor())); + + Assert ((T-deviator_tensor()).norm() + <= 1e-15*T.norm(), ExcInternalError()); +} + + + + +int main () +{ + std::ofstream logfile("symmetric_tensor_16.output"); + logfile.precision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1> (); + test<2> (); + test<3> (); + + deallog << "OK" << std::endl; +} -- 2.39.5