From: Daniel Arndt Date: Sat, 28 Jan 2017 11:22:59 +0000 (+0100) Subject: Allow SymmetricGradient::operator* for aggregates X-Git-Tag: v8.5.0-rc1~189^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af50cd01bbbb651fbfac428438f909f5d59f0d21;p=dealii.git Allow SymmetricGradient::operator* for aggregates --- diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 2a5b4c16fa..65b8626f0a 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -2916,7 +2916,9 @@ operator * (const SymmetricTensor &t, // (as well as with switched arguments and double<->float). typedef typename ProductType::type product_type; SymmetricTensor tt(t); - tt *= product_type(factor); + product_type new_factor; + new_factor = factor; + tt *= new_factor; return tt; } diff --git a/tests/base/symmetric_tensor_38.cc b/tests/base/symmetric_tensor_38.cc new file mode 100644 index 0000000000..ad780e8276 --- /dev/null +++ b/tests/base/symmetric_tensor_38.cc @@ -0,0 +1,75 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 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. +// +// --------------------------------------------------------------------- + + +// Check operator* with a VectorizedArray + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include + +int main () +{ + std::ofstream logfile("output"); + deallog << std::setprecision(5); + deallog.attach(logfile); + deallog.threshold_double(1.e-10); + + const int dim = 3; + SymmetricTensor<2,dim,VectorizedArray > s1; + SymmetricTensor<2,dim,VectorizedArray > s2; + + for (unsigned int i=0; i > r1 = factor_float*s1; + SymmetricTensor<2,dim,VectorizedArray > r2 = factor_double*s2; + + for (unsigned int i=0; i::n_array_elements; ++k) + { + AssertThrow(std::abs(r1[i][j][k]-r1[i][j][0])<1.e-10, + ExcInternalError()); + } + deallog << r2[i][j][0] << std::endl; + Assert(std::abs(r2[i][j][0]-factor_double*s2[i][j][0])<1.e-10, + ExcInternalError()); + for (unsigned int k=1; k::n_array_elements; ++k) + { + AssertThrow(std::abs(r2[i][j][k]-r2[i][j][0])<1.e-10, + ExcInternalError()); + } + deallog << std::endl; + } + + deallog << "OK" << std::endl; +} diff --git a/tests/base/symmetric_tensor_38.output b/tests/base/symmetric_tensor_38.output new file mode 100644 index 0000000000..76d7764ed0 --- /dev/null +++ b/tests/base/symmetric_tensor_38.output @@ -0,0 +1,38 @@ + +DEAL::0 0 +DEAL::2.0000 +DEAL::6.0000 +DEAL:: +DEAL::0 1 +DEAL::8.0000 +DEAL::15.000 +DEAL:: +DEAL::0 2 +DEAL::14.000 +DEAL::24.000 +DEAL:: +DEAL::1 0 +DEAL::8.0000 +DEAL::15.000 +DEAL:: +DEAL::1 1 +DEAL::10.000 +DEAL::24.000 +DEAL:: +DEAL::1 2 +DEAL::16.000 +DEAL::33.000 +DEAL:: +DEAL::2 0 +DEAL::14.000 +DEAL::24.000 +DEAL:: +DEAL::2 1 +DEAL::16.000 +DEAL::33.000 +DEAL:: +DEAL::2 2 +DEAL::18.000 +DEAL::42.000 +DEAL:: +DEAL::OK