From 492997c9666643f0b6ccefcc2f51ed8e65ef3079 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Thu, 2 Apr 2015 09:50:43 +0200 Subject: [PATCH] update Allreduce operation to fit complex numbers in compute_mean_value --- .../deal.II/numerics/vector_tools.templates.h | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) 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 -- 2.39.5