]> https://gitweb.dealii.org/ - dealii.git/commitdiff
update Allreduce operation to fit complex numbers in compute_mean_value
authorDenis Davydov <davydden@gmail.com>
Thu, 2 Apr 2015 07:50:43 +0000 (09:50 +0200)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 8 May 2015 16:23:52 +0000 (11:23 -0500)
include/deal.II/numerics/vector_tools.templates.h

index 0a2bed01e0d4333456d51fd44e61db05e78f3383..b29210df033ba13ca384e0439332132195cde7b3 100644 (file)
@@ -6998,6 +6998,21 @@ namespace VectorTools
       }
   }
 
+  // move to deal.ii/base/numbers.h ?
+  namespace internal
+  {
+    template <typename Number>
+    void set_possibly_complex_number(Number &n, const double &r, const double &i)
+    {
+      n = r;
+    }
+
+    template <typename Type>
+    void set_possibly_complex_number(std::complex<Type> &n, const double &r, const double &i)
+    {
+      n = std::complex<Type>(r,i);
+    }
+  }
 
 
   template <int dim, class InVector, int spacedim>
@@ -7044,16 +7059,16 @@ namespace VectorTools
         p_d_triangulation
         = dynamic_cast<const parallel::distributed::Triangulation<dim,spacedim> *>(&dof.get_tria()))
       {
-        double mean_double = mean;
-        double my_values[2] = { mean_double, area };
-        double global_values[2];
+        std::complex<double> 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
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.