From: Martin Kronbichler Date: Tue, 18 Nov 2014 12:02:45 +0000 (+0100) Subject: Fix uninitialized variables in Utilities::MPI::MinMaxAvg X-Git-Tag: v8.2.0-rc1~59^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F254%2Fhead;p=dealii.git Fix uninitialized variables in Utilities::MPI::MinMaxAvg --- diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index a6943e3691..75a5667f2f 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -216,6 +216,8 @@ namespace Utilities */ struct MinMaxAvg { + MinMaxAvg(); + double sum; double min; double max; diff --git a/source/base/mpi.cc b/source/base/mpi.cc index e24043da95..dd05f4361c 100644 --- a/source/base/mpi.cc +++ b/source/base/mpi.cc @@ -186,8 +186,7 @@ namespace Utilities namespace { - // custom MIP_Op for - // calculate_collective_mpi_min_max_avg + // custom MIP_Op for calculate_collective_mpi_min_max_avg void max_reduce ( const void *in_lhs_, void *inout_rhs_, int *len, @@ -206,7 +205,7 @@ namespace Utilities } else if (inout_rhs->min == in_lhs->min) { - // choose lower cpu index when tied to make operator cumutative + // choose lower cpu index when tied to make operator commutative if (inout_rhs->min_index > in_lhs->min_index) inout_rhs->min_index = in_lhs->min_index; } @@ -218,7 +217,7 @@ namespace Utilities } else if (inout_rhs->max == in_lhs->max) { - // choose lower cpu index when tied to make operator cumutative + // choose lower cpu index when tied to make operator commutative if (inout_rhs->max_index > in_lhs->max_index) inout_rhs->max_index = in_lhs->max_index; } @@ -227,6 +226,18 @@ namespace Utilities + MinMaxAvg::MinMaxAvg () + : + sum (0.), + min (std::numeric_limits::max()), + max (-min), + min_index (0), + max_index (0), + avg (0) + {} + + + MinMaxAvg min_max_avg(const double my_value, const MPI_Comm &mpi_communicator)