From: Timo Heister Date: Wed, 26 Jan 2011 08:02:09 +0000 (+0000) Subject: step-32: correct comment and cleanup calculation of get_extrapolated_temperature_range(). X-Git-Tag: v8.0.0~4433 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=103490fc8e626d57cb62363605d6800062f8e5a8;p=dealii.git step-32: correct comment and cleanup calculation of get_extrapolated_temperature_range(). git-svn-id: https://svn.dealii.org/trunk@23263 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-32/step-32.cc b/deal.II/examples/step-32/step-32.cc index ad34bce157..78c0229f2f 100644 --- a/deal.II/examples/step-32/step-32.cc +++ b/deal.II/examples/step-32/step-32.cc @@ -69,6 +69,7 @@ #include #include +#include // This is the only include file that is new: // We use an IndexSet to describe the @@ -1133,15 +1134,17 @@ BoussinesqFlowProblem::get_extrapolated_temperature_range () const std::vector old_temperature_values(n_q_points); std::vector old_old_temperature_values(n_q_points); + // This presets the minimum with a bigger + // and the maximum with a smaller number + // than one that is going to appear. Will + // be overwritten in the cell loop or in + // the communication step at the + // latest. + double min_local_temperature = std::numeric_limits::max(), + max_local_temperature = -std::numeric_limits::max(); + if (timestep_number != 0) { - // use different formula here than in - // step-31 to avoid computing the - // linfty_norm of the temperature - // (which requires a communication) - double min_local_temperature = 1e30, - max_local_temperature = -1e30; - typename DoFHandler::active_cell_iterator cell = temperature_dof_handler.begin_active(), endc = temperature_dof_handler.end(); @@ -1167,25 +1170,9 @@ BoussinesqFlowProblem::get_extrapolated_temperature_range () const temperature); } } - - double min_temperature, max_temperature; -#ifdef DEAL_II_COMPILER_SUPPORTS_MPI - MPI_Allreduce (&max_local_temperature, &max_temperature, 1, MPI_DOUBLE, - MPI_MAX, MPI_COMM_WORLD); - MPI_Allreduce (&min_local_temperature, &min_temperature, 1, MPI_DOUBLE, - MPI_MIN, MPI_COMM_WORLD); -#else - min_temperature = min_local_temperature; - max_temperature = max_local_temperature; -#endif - - return std::make_pair(min_temperature, max_temperature); } else { - double min_local_temperature = 1e30, - max_local_temperature = -1e30; - typename DoFHandler::active_cell_iterator cell = temperature_dof_handler.begin_active(), endc = temperature_dof_handler.end(); @@ -1207,20 +1194,20 @@ BoussinesqFlowProblem::get_extrapolated_temperature_range () const temperature); } } - - double min_temperature, max_temperature; + } + + double min_temperature, max_temperature; #ifdef DEAL_II_COMPILER_SUPPORTS_MPI - MPI_Allreduce (&max_local_temperature, &max_temperature, 1, MPI_DOUBLE, - MPI_MAX, MPI_COMM_WORLD); - MPI_Allreduce (&min_local_temperature, &min_temperature, 1, MPI_DOUBLE, - MPI_MIN, MPI_COMM_WORLD); + MPI_Allreduce (&max_local_temperature, &max_temperature, 1, MPI_DOUBLE, + MPI_MAX, MPI_COMM_WORLD); + MPI_Allreduce (&min_local_temperature, &min_temperature, 1, MPI_DOUBLE, + MPI_MIN, MPI_COMM_WORLD); #else - min_temperature = min_local_temperature; - max_temperature = max_local_temperature; + min_temperature = min_local_temperature; + max_temperature = max_local_temperature; #endif - return std::make_pair(min_temperature, max_temperature); - } + return std::make_pair(min_temperature, max_temperature); }