From 11296e620f1a54bab28eecb9f76064500a38813c Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 25 May 2022 20:52:24 -0500 Subject: [PATCH] Step-81: Avoid using 1.0i literal when multiplying dealii::Tensor<> --- examples/step-81/step-81.cc | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/examples/step-81/step-81.cc b/examples/step-81/step-81.cc index 0cb2dfeaf2..22bf2e8acd 100644 --- a/examples/step-81/step-81.cc +++ b/examples/step-81/step-81.cc @@ -671,21 +671,23 @@ namespace Step81 for (const auto i : fe_values.dof_indices()) { + constexpr std::complex imag{0., 1.}; + const auto phi_i = real_part.value(i, q_point) - - 1.0i * imag_part.value(i, q_point); + imag * imag_part.value(i, q_point); const auto curl_phi_i = real_part.curl(i, q_point) - - 1.0i * imag_part.curl(i, q_point); + imag * imag_part.curl(i, q_point); const auto rhs_value = - (1.0i * scalar_product(J_a, phi_i)) * fe_values.JxW(q_point); + (imag * scalar_product(J_a, phi_i)) * fe_values.JxW(q_point); cell_rhs(i) += rhs_value.real(); for (const auto j : fe_values.dof_indices()) { const auto phi_j = real_part.value(j, q_point) + - 1.0i * imag_part.value(j, q_point); + imag * imag_part.value(j, q_point); const auto curl_phi_j = real_part.curl(j, q_point) + - 1.0i * imag_part.curl(j, q_point); + imag * imag_part.curl(j, q_point); const auto temp = (scalar_product(mu_inv * curl_phi_j, curl_phi_i) - @@ -739,16 +741,18 @@ namespace Step81 for (const auto i : fe_face_values.dof_indices()) { + constexpr std::complex imag{0., 1.}; + const auto phi_i = real_part.value(i, q_point) - - 1.0i * imag_part.value(i, q_point); + imag * imag_part.value(i, q_point); const auto phi_i_T = tangential_part(phi_i, normal); for (const auto j : fe_face_values.dof_indices()) { const auto phi_j = real_part.value(j, q_point) + - 1.0i * imag_part.value(j, q_point); + imag * imag_part.value(j, q_point); const auto phi_j_T = tangential_part(phi_j, normal) * fe_face_values.JxW(q_point); @@ -757,7 +761,7 @@ namespace Step81 const auto sqrt_prod = prod; const auto temp = - -1.0i * scalar_product((sqrt_prod * phi_j_T), + -imag * scalar_product((sqrt_prod * phi_j_T), phi_i_T); cell_matrix(i, j) += temp.real(); } /* j */ @@ -795,19 +799,21 @@ namespace Step81 for (const auto i : fe_face_values.dof_indices()) { + constexpr std::complex imag{0., 1.}; + const auto phi_i = real_part.value(i, q_point) - - 1.0i * imag_part.value(i, q_point); + imag * imag_part.value(i, q_point); const auto phi_i_T = tangential_part(phi_i, normal); for (const auto j : fe_face_values.dof_indices()) { const auto phi_j = real_part.value(j, q_point) + - 1.0i * imag_part.value(j, q_point); + imag * imag_part.value(j, q_point); const auto phi_j_T = tangential_part(phi_j, normal); const auto temp = - -1.0i * + -imag * scalar_product((sigma * phi_j_T), phi_i_T) * fe_face_values.JxW(q_point); cell_matrix(i, j) += temp.real(); -- 2.39.5