From: Daniel Arndt Date: Wed, 12 May 2021 16:50:20 +0000 (-0500) Subject: Fix apply_transformation for different number types X-Git-Tag: v9.3.0-rc1~84^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f26e11854227961ec5b7ca807393fae896fe7fe6;p=dealii.git Fix apply_transformation for different number types --- diff --git a/include/deal.II/base/derivative_form.h b/include/deal.II/base/derivative_form.h index 38f95f1e93..8c70216894 100644 --- a/include/deal.II/base/derivative_form.h +++ b/include/deal.II/base/derivative_form.h @@ -424,12 +424,12 @@ DerivativeForm::memory_consumption() * * @relatesalso DerivativeForm */ -template -inline Tensor<1, spacedim, Number2> +template +inline Tensor<1, spacedim, typename ProductType::type> apply_transformation(const DerivativeForm<1, dim, spacedim, Number1> &grad_F, const Tensor<1, dim, Number2> & d_x) { - Tensor<1, spacedim, Number2> dest; + Tensor<1, spacedim, typename ProductType::type> dest; for (unsigned int i = 0; i < spacedim; ++i) dest[i] = grad_F[i] * d_x; return dest; @@ -446,12 +446,16 @@ apply_transformation(const DerivativeForm<1, dim, spacedim, Number1> &grad_F, * @relatesalso DerivativeForm */ // rank=2 -template -inline DerivativeForm<1, spacedim, dim, Number> -apply_transformation(const DerivativeForm<1, dim, spacedim, Number> &grad_F, - const Tensor<2, dim, Number> & D_X) +template +inline DerivativeForm<1, + spacedim, + dim, + typename ProductType::type> +apply_transformation(const DerivativeForm<1, dim, spacedim, Number1> &grad_F, + const Tensor<2, dim, Number2> & D_X) { - DerivativeForm<1, spacedim, dim, Number> dest; + DerivativeForm<1, spacedim, dim, typename ProductType::type> + dest; for (unsigned int i = 0; i < dim; ++i) dest[i] = apply_transformation(grad_F, D_X[i]); @@ -467,12 +471,22 @@ apply_transformation(const DerivativeForm<1, dim, spacedim, Number> &grad_F, * * @relatesalso DerivativeForm */ -template -inline Tensor<1, n_components, Tensor<1, spacedim, Number>> -apply_transformation(const DerivativeForm<1, dim, spacedim, Number> &grad_F, - const Tensor<1, n_components, Tensor<1, dim, Number>> &D_X) +template +inline Tensor<1, + n_components, + Tensor<1, spacedim, typename ProductType::type>> +apply_transformation( + const DerivativeForm<1, dim, spacedim, Number1> & grad_F, + const Tensor<1, n_components, Tensor<1, dim, Number2>> &D_X) { - Tensor<1, n_components, Tensor<1, spacedim, Number>> dest; + Tensor<1, + n_components, + Tensor<1, spacedim, typename ProductType::type>> + dest; for (unsigned int i = 0; i < n_components; ++i) dest[i] = apply_transformation(grad_F, D_X[i]); @@ -496,12 +510,12 @@ apply_transformation(const DerivativeForm<1, dim, spacedim, Number> &grad_F, * * @relatesalso DerivativeForm */ -template -inline Tensor<2, spacedim, Number> -apply_transformation(const DerivativeForm<1, dim, spacedim, Number> &DF1, - const DerivativeForm<1, dim, spacedim, Number> &DF2) +template +inline Tensor<2, spacedim, typename ProductType::type> +apply_transformation(const DerivativeForm<1, dim, spacedim, Number1> &DF1, + const DerivativeForm<1, dim, spacedim, Number2> &DF2) { - Tensor<2, spacedim, Number> dest; + Tensor<2, spacedim, typename ProductType::type> dest; for (unsigned int i = 0; i < spacedim; ++i) dest[i] = apply_transformation(DF1, DF2[i]);