From: Denis Davydov Date: Thu, 2 Apr 2015 07:50:43 +0000 (+0200) Subject: update Allreduce operation to fit complex numbers in compute_mean_value X-Git-Tag: v8.3.0-rc1~184^2~12 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=492997c9666643f0b6ccefcc2f51ed8e65ef3079;p=dealii.git update Allreduce operation to fit complex numbers in compute_mean_value --- diff --git a/include/deal.II/numerics/vector_tools.templates.h b/include/deal.II/numerics/vector_tools.templates.h index 0a2bed01e0..b29210df03 100644 --- a/include/deal.II/numerics/vector_tools.templates.h +++ b/include/deal.II/numerics/vector_tools.templates.h @@ -6998,6 +6998,21 @@ namespace VectorTools } } + // move to deal.ii/base/numbers.h ? + namespace internal + { + template + void set_possibly_complex_number(Number &n, const double &r, const double &i) + { + n = r; + } + + template + void set_possibly_complex_number(std::complex &n, const double &r, const double &i) + { + n = std::complex(r,i); + } + } template @@ -7044,16 +7059,16 @@ namespace VectorTools p_d_triangulation = dynamic_cast *>(&dof.get_tria())) { - double mean_double = mean; - double my_values[2] = { mean_double, area }; - double global_values[2]; + std::complex mean_double = mean; + double my_values[3] = { mean_double.real(), mean_double.imag(), area }; + double global_values[3]; - MPI_Allreduce (&my_values, &global_values, 2, MPI_DOUBLE, + MPI_Allreduce (&my_values, &global_values, 3, MPI_DOUBLE, MPI_SUM, p_d_triangulation->get_communicator()); - mean = global_values[0]; - area = global_values[1]; + internal::set_possibly_complex_number(mean,global_values[0],global_values[1]); + area = global_values[2]; } #endif