From be3ebbde1bea5444876f66a1cf75a1e1c5b9c8f9 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 27 May 2013 15:25:21 +0000 Subject: [PATCH] Two minor improvements git-svn-id: https://svn.dealii.org/trunk@29649 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/lac/parallel_vector.templates.h | 16 ++++++++------ deal.II/include/deal.II/lac/precondition.h | 21 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/deal.II/include/deal.II/lac/parallel_vector.templates.h b/deal.II/include/deal.II/lac/parallel_vector.templates.h index d71c786ea6..f95d78697c 100644 --- a/deal.II/include/deal.II/lac/parallel_vector.templates.h +++ b/deal.II/include/deal.II/lac/parallel_vector.templates.h @@ -561,8 +561,9 @@ namespace parallel // as there are processors and start writing // when it's our turn #ifdef DEAL_II_WITH_MPI - for (unsigned int i=0; ithis_mpi_process(); i++) - MPI_Barrier (partitioner->get_communicator()); + if (partitioner->n_mpi_processes() > 1) + for (unsigned int i=0; ithis_mpi_process(); i++) + MPI_Barrier (partitioner->get_communicator()); #endif out << "Process #" << partitioner->this_mpi_process() << std::endl @@ -590,11 +591,14 @@ namespace parallel out << std::endl << std::flush; #ifdef DEAL_II_WITH_MPI - MPI_Barrier (partitioner->get_communicator()); + if (partitioner->n_mpi_processes() > 1) + { + MPI_Barrier (partitioner->get_communicator()); - for (unsigned int i=partitioner->this_mpi_process()+1; - in_mpi_processes(); i++) - MPI_Barrier (partitioner->get_communicator()); + for (unsigned int i=partitioner->this_mpi_process()+1; + in_mpi_processes(); i++) + MPI_Barrier (partitioner->get_communicator()); + } #endif AssertThrow (out, ExcIO()); diff --git a/deal.II/include/deal.II/lac/precondition.h b/deal.II/include/deal.II/lac/precondition.h index 9d34b5958a..c0c2cf9ac7 100644 --- a/deal.II/include/deal.II/lac/precondition.h +++ b/deal.II/include/deal.II/lac/precondition.h @@ -1793,14 +1793,19 @@ PreconditionChebyshev::initialize (const MATRIX &matrix, // read the log stream: grab the first and last eigenvalue std::string cg_message = log_msg.str(); const std::size_t pos = cg_message.find("cg:: "); - Assert(pos < std::string::npos, ExcInternalError()); - cg_message.erase(0, pos+5); - std::istringstream os1(cg_message); - os1 >> min_eigenvalue; - for (unsigned int i=0; i> max_eigenvalue; + if (pos != std::string::npos) + { + cg_message.erase(0, pos+5); + std::string first = cg_message; + + first.erase(cg_message.find_first_of(" "), std::string::npos); + std::istringstream(first) >> min_eigenvalue; + + cg_message.erase(0, cg_message.find_last_of(" ")+1); + std::istringstream(cg_message) >> max_eigenvalue; + } + else + min_eigenvalue = max_eigenvalue = 1; // reset deal.II stream deallog.detach(); -- 2.39.5