From a8f358c08a59d7139f20036c920d4e24d3b68f27 Mon Sep 17 00:00:00 2001 From: "denis.davydov" Date: Sun, 4 May 2014 12:46:23 +0000 Subject: [PATCH] started adding some processing of new_numbers in ParallelShared::renumber_dofs... git-svn-id: https://svn.dealii.org/branches/branch_sharedtria@32881 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/dofs/dof_handler_policy.cc | 44 ++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/deal.II/source/dofs/dof_handler_policy.cc b/deal.II/source/dofs/dof_handler_policy.cc index b95e4641ab..94859feff2 100644 --- a/deal.II/source/dofs/dof_handler_policy.cc +++ b/deal.II/source/dofs/dof_handler_policy.cc @@ -1004,7 +1004,49 @@ namespace internal dealii::DoFHandler &dof_handler, NumberCache &number_cache_current) const { - NumberCache number_cache = Sequential::renumber_dofs (new_numbers,dof_handler,number_cache_current); + //shift: + std::vector gathered_new_numbers; + if ( new_numbers.size() < dof_handler.n_dofs()) + { + //gather sizes of new_nubers + const parallel::shared::Triangulation< dim, spacedim > *tr + = (dynamic_cast*> + (&dof_handler.get_tria())); + Assert (tr != 0, ExcInternalError()); + const unsigned int n_cpu = Utilities::MPI::n_mpi_processes(tr->get_communicator()); + + std::vector global_n_dofs(n_cpu); + types::global_dof_index n_dofs = new_numbers.size(); + MPI_Allgather(&n_dofs, 1, DEAL_II_DOF_INDEX_MPI_TYPE, + &global_n_dofs[0], 1, DEAL_II_DOF_INDEX_MPI_TYPE, + tr->get_communicator()); + + std::vector local_new_numbers (new_numbers.size(),0); + types::global_dof_index shift = 0; + for (unsigned int i = 0; i < tr->locally_owned_subdomain(); i++ ) + shift+=global_n_dofs[i]; + + for (unsigned int i = 0; i < new_numbers.size(); i++) + local_new_numbers[i] = new_numbers[i]+shift; + + //Assert ( std::max_element(local_new_numbers.begin(),local_new_numbers.end()) < dof_handler.n_dofs(),ExcInternalError() ); + + gathered_new_numbers.resize(dof_handler.n_dofs()); + MPI_Allgather(&local_new_numbers[0], local_new_numbers.size(), DEAL_II_DOF_INDEX_MPI_TYPE, + &gathered_new_numbers[0], local_new_numbers.size(), DEAL_II_DOF_INDEX_MPI_TYPE, + tr->get_communicator()); + } + else + { + gathered_new_numbers = new_numbers; + } + //debug: + //for (unsigned int i = 0; i < new_numbers.size(); i++) + // std::cout<::renumber_dofs (gathered_new_numbers,dof_handler,number_cache_current); //update current number cache number_cache_current = number_cache; //correct number_cache: -- 2.39.5