From: heister Date: Wed, 31 Jul 2013 15:01:04 +0000 (+0000) Subject: fix SparsityTools::distribute_sparsity_pattern for block systems X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec62933bb779c740246daa857cfac4355d0bf5db;p=dealii-svn.git fix SparsityTools::distribute_sparsity_pattern for block systems git-svn-id: https://svn.dealii.org/trunk@30197 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index e7a29282fd..9ba000d174 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -44,6 +44,13 @@ inconvenience this causes.

Specific improvements

    +
  1. + SparsityTools::distribute_sparsity_pattern did not work correctly for + block systems, this has been fixed (function has a different signature). +
    + (Timo Heister, 2013/07/31) +
  2. +
  3. Fixed: When typing make run in the step-32 directory, the program was executed with mpirun -np 2 ./step-32. This assumes that a program mpirun exists, but also does that diff --git a/deal.II/include/deal.II/lac/sparsity_tools.h b/deal.II/include/deal.II/lac/sparsity_tools.h index 46b7d07308..860eedfae7 100644 --- a/deal.II/include/deal.II/lac/sparsity_tools.h +++ b/deal.II/include/deal.II/lac/sparsity_tools.h @@ -236,7 +236,9 @@ namespace SparsityTools * range of elements stored locally * and should be the one used in * the constructor of the - * CompressedSimpleSparsityPattern. Only + * CompressedSimpleSparsityPattern. + * This should be the locally relevant set. + * Only * rows contained in myrange are * checked in csp for transfer. * This function needs to be used @@ -250,6 +252,19 @@ namespace SparsityTools const std::vector &rows_per_cpu, const MPI_Comm &mpi_comm, const IndexSet &myrange); + + /** + * similar to the function above, but includes support for + * BlockCompressedSimpleSparsityPattern. + * @p owned_set_per_cpu is typically DoFHandler::locally_owned_dofs_per_processor + * and @p myrange are locally_relevant_dofs. + */ + template + void distribute_sparsity_pattern(CSP_t &csp, + const std::vector &owned_set_per_cpu, + const MPI_Comm &mpi_comm, + const IndexSet &myrange); + #endif diff --git a/deal.II/source/lac/sparsity_tools.cc b/deal.II/source/lac/sparsity_tools.cc index f88015c32b..066aa09a9b 100644 --- a/deal.II/source/lac/sparsity_tools.cc +++ b/deal.II/source/lac/sparsity_tools.cc @@ -505,6 +505,132 @@ namespace SparsityTools MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); } + +template +void distribute_sparsity_pattern(CSP_t &csp, + const std::vector &owned_set_per_cpu, + const MPI_Comm &mpi_comm, + const IndexSet &myrange) +{ + size_type myid = Utilities::MPI::this_mpi_process(mpi_comm); + + typedef std::map > map_vec_t; + map_vec_t send_data; + + { + unsigned int dest_cpu=0; + + size_type n_local_rel_rows = myrange.n_elements(); + for (size_type row_idx=0; row_idx &dst = send_data[dest_cpu]; + + dst.push_back(rlen); // number of entries + dst.push_back(row); // row index + for (size_type c=0; c send_to; + send_to.reserve(send_data.size()); + for (map_vec_t::iterator it=send_data.begin(); it!=send_data.end(); ++it) + send_to.push_back(it->first); + + num_receive = + Utilities::MPI:: + compute_point_to_point_communication_pattern(mpi_comm, send_to).size(); + } + + std::vector requests(send_data.size()); + + + // send data + { + unsigned int idx=0; + for (map_vec_t::iterator it=send_data.begin(); it!=send_data.end(); ++it, ++idx) + MPI_Isend(&(it->second[0]), + it->second.size(), + DEAL_II_DOF_INDEX_MPI_TYPE, + it->first, + 124, + mpi_comm, + &requests[idx]); + } + +//TODO: In the following, we read individual bytes and then reinterpret them +// as size_type objects. this is error prone. use properly typed reads that +// match the write above + { + //receive + std::vector recv_buf; + for (unsigned int index=0; index::const_iterator ptr = recv_buf.begin(); + std::vector::const_iterator end = recv_buf.end(); + while (ptr+1 +(BlockCompressedSimpleSparsityPattern &csp, + const std::vector &owned_set_per_cpu, + const MPI_Comm &mpi_comm, + const IndexSet &myrange); + #endif #undef SPARSITY_FUNCTIONS