From: denis.davydov Date: Fri, 11 Jul 2014 21:32:23 +0000 (+0000) Subject: fixed some white spaces and indentation X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fbranch_sharedtria;p=dealii-svn.git fixed some white spaces and indentation git-svn-id: https://svn.dealii.org/branches/branch_sharedtria@33139 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/dofs/dof_handler_policy.cc b/deal.II/source/dofs/dof_handler_policy.cc index 462e3372db..9fce8e1136 100644 --- a/deal.II/source/dofs/dof_handler_policy.cc +++ b/deal.II/source/dofs/dof_handler_policy.cc @@ -1022,6 +1022,8 @@ namespace internal const unsigned int this_process = Utilities::MPI::this_mpi_process (tr->get_communicator ()); std::vector gathered_new_numbers (dof_handler.n_dofs (), 0); + Assert(this_process == dof_handler.get_tria ().locally_owned_subdomain (), + ExcInternalError()) //debug (TODO: remove when everything works): if (renumber_debug) @@ -1057,15 +1059,18 @@ namespace internal for (unsigned int i = 0; i < n_cpu; i++) { displs[i] = shift; + //rcounts[i] = dof_handler.n_locally_owned_dofs_per_processor()[i]; rcounts[i] = number_cache_current.n_locally_owned_dofs_per_processor[i]; shift += rcounts[i]; } + Assert(((int)new_numbers_copy.size()) == rcounts[this_process], + ExcInternalError()); MPI_Allgatherv (&new_numbers_copy[0], new_numbers_copy.size (), DEAL_II_DOF_INDEX_MPI_TYPE, &gathered_new_numbers[0], &rcounts[0], &displs[0], DEAL_II_DOF_INDEX_MPI_TYPE, - tr->get_communicator ()); + tr->get_communicator ()); } //debug (TODO: remove when everything works): @@ -1117,9 +1122,9 @@ namespace internal shift += iset.n_elements (); } - Assert(*max_element(flag_1.begin(), flag_1.end()) == 1, + Assert(*std::max_element(flag_1.begin(), flag_1.end()) == 1, ExcInternalError()); - Assert(*min_element(flag_1.begin(), flag_1.end()) == 1, + Assert(*std::min_element(flag_1.begin(), flag_1.end()) == 1, ExcInternalError()); Assert((*std::max_element(flag_2.begin(), flag_2.end())) == 1, ExcInternalError()); diff --git a/deal.II/source/dofs/dof_tools.cc b/deal.II/source/dofs/dof_tools.cc index 0b43671c13..160d0cde74 100644 --- a/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/source/dofs/dof_tools.cc @@ -1079,41 +1079,49 @@ namespace DoFTools std::vector locally_owned_dofs_with_subdomain (const DH &dof_handler) { - //the following is a random process (flip of a coin), thus should be called once only. - std::vector< types::subdomain_id > subdomain_association(dof_handler.n_dofs()); - DoFTools::get_subdomain_association(dof_handler,subdomain_association); + //the following is a random process (flip of a coin), thus should be called once only. + std::vector< dealii::types::subdomain_id > subdomain_association (dof_handler.n_dofs ()); + dealii::DoFTools::get_subdomain_association (dof_handler, subdomain_association); - const unsigned int num_subdomains = 1 + (*max_element(subdomain_association.begin(), subdomain_association.end())); + const unsigned int n_subdomains = 1 + (*std::max_element (subdomain_association.begin (), + subdomain_association.end () )); - std::vector index_sets (num_subdomains,IndexSet(dof_handler.n_dofs())); + std::vector index_sets (n_subdomains,dealii::IndexSet(dof_handler.n_dofs())); - //loop over subdomain_association - //and populate IndexSet when - //a change in subdomain ID is found - types::global_dof_index i_min = 0; - types::global_dof_index cur_subdomain = subdomain_association[0]; - for (types::global_dof_index ind = 1; ind < subdomain_association.size(); ind++) - { - //found index different from the current one - if (subdomain_association[ind] != cur_subdomain) - { - index_sets[cur_subdomain].add_range(i_min,ind); - i_min = ind; - cur_subdomain = subdomain_association[ind]; - } - } - //the very last element is of different index - if (i_min == subdomain_association.size()-1) - { - index_sets[cur_subdomain].add_index(i_min); - } - else //there are at least two different indices + // loop over subdomain_association and populate IndexSet when a + // change in subdomain ID is found + dealii::types::global_dof_index i_min = 0; + dealii::types::global_dof_index this_subdomain = subdomain_association[0]; + + for (dealii::types::global_dof_index index = 1; + index < subdomain_association.size (); ++index) + { + //found index different from the current one + if (subdomain_association[index] != this_subdomain) { - index_sets[cur_subdomain].add_range(i_min,subdomain_association.size()); + index_sets[this_subdomain].add_range (i_min, index); + i_min = index; + this_subdomain = subdomain_association[index]; } - for (unsigned int i = 0;i< num_subdomains; i++) - index_sets[i].compress(); - return index_sets; + } + + // the very last element is of different index + if (i_min == subdomain_association.size () - 1) + { + index_sets[this_subdomain].add_index (i_min); + } + + // otherwise there are at least two different indices + else + { + index_sets[this_subdomain].add_range ( + i_min, subdomain_association.size ()); + } + + for (unsigned int i = 0; i < n_subdomains; i++) + index_sets[i].compress (); + + return index_sets; } template