From: Wolfgang Bangerth Date: Fri, 8 Jul 2016 21:05:19 +0000 (-0500) Subject: Add tests for SymmetricTensor::norm() for complex-valued tensors. X-Git-Tag: v8.5.0-rc1~896^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2791%2Fhead;p=dealii.git Add tests for SymmetricTensor::norm() for complex-valued tensors. This incidentally also tests that SymmetricTensor::access_raw_entry() function. --- diff --git a/tests/base/symmetric_tensor_32.cc b/tests/base/symmetric_tensor_32.cc new file mode 100644 index 0000000000..ba776730de --- /dev/null +++ b/tests/base/symmetric_tensor_32.cc @@ -0,0 +1,66 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +// Test SymmetricTensor::norm() for complex-valued tensors + +#include "../tests.h" +#include +#include + + +template +void check () +{ + // build a regular tensor + SymmetricTensor t; + + // build one in which all numbers are the same but purely imaginary + SymmetricTensor > ti; + + // build one in which all numbers have both real and imaginary components + SymmetricTensor > tc; + + for (unsigned int i=0; i(0,1.0*(i+1)); + tc.access_raw_entry(i) = std::complex(1.0*(i+1),1.0*(i+1)); + } + + deallog << t.norm() << ' ' + << ti.norm() << ' ' + << tc.norm() << std::endl; +} + + +int main () +{ + std::ofstream logfile("output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.threshold_double(1.e-10); + + deallog << "check rank 2 tensors" << std::endl; + check<2,1>(); + check<2,2>(); + check<2,3>(); + + deallog << "check rank 4 tensors" << std::endl; + check<4,1>(); + check<4,2>(); + check<4,3>(); + + deallog << "OK" << std::endl; +} diff --git a/tests/base/symmetric_tensor_32.output b/tests/base/symmetric_tensor_32.output new file mode 100644 index 0000000000..ee6976348e --- /dev/null +++ b/tests/base/symmetric_tensor_32.output @@ -0,0 +1,10 @@ + +DEAL::check rank 2 tensors +DEAL::1.00 1.00 1.41 +DEAL::4.80 4.80 6.78 +DEAL::13.0 13.0 18.3 +DEAL::check rank 4 tensors +DEAL::1.00 1.00 1.41 +DEAL::26.2 26.2 37.0 +DEAL::217. 217. 307. +DEAL::OK