const unsigned int this_process =
Utilities::MPI::this_mpi_process (tr->get_communicator ());
std::vector<types::global_dof_index> 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)
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):
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());
std::vector<IndexSet>
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<IndexSet> index_sets (num_subdomains,IndexSet(dof_handler.n_dofs()));
+ std::vector<dealii::IndexSet> 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 <class DH>