void partition_triangulation (const unsigned int n_partitions,
Triangulation<dim> &triangulation);
+ /**
+ * For each active cell, return in the
+ * output array to which subdomain (as
+ * given by the @p{cell->subdomain_id()}
+ * function) it belongs. The output array
+ * is supposed to have the right size
+ * already when calling this function.
+ *
+ * This function returns the association
+ * of each cell with one subdomain. If
+ * you are looking for the association of
+ * each @em DoF with a subdomain, use the
+ * <tt>DoFTools::get_subdomain_association</tt>
+ * function.
+ */
+ template <int dim>
+ static void
+ get_subdomain_association (const Triangulation<dim> &triangulation,
+ std::vector<unsigned int> &subdomain);
+
+ /**
+ * Count how many cells are uniquely
+ * associated with the given @p subdomain
+ * index.
+ *
+ * This function will generate an
+ * exception if there are no cells with
+ * the given @p subdomain index.
+ *
+ * This function returns the number of
+ * cells associated with one
+ * subdomain. If you are looking for the
+ * association of @em DoFs with this
+ * subdomain, use the
+ * <tt>DoFTools::count_dofs_with_subdomain_association</tt>
+ * function.
+ */
+ template <int dim>
+ static unsigned int
+ count_cells_with_subdomain_association (const Triangulation<dim> &triangulation,
+ const unsigned int subdomain);
+
/**
* Exception
*/
int,
<< "The number of partitions you gave is " << arg1
<< ", but must be greater than zero.");
+ /**
+ * Exception
+ */
+ DeclException1 (ExcNonExistentSubdomain,
+ int,
+ << "The subdomain id " << arg1
+ << " has no cells associated with it.");
/**
* Exception
*/
+template <int dim>
+void
+GridTools::
+get_subdomain_association (const Triangulation<dim> &triangulation,
+ std::vector<unsigned int> &subdomain)
+{
+ Assert (subdomain.size() == triangulation.n_active_cells(),
+ ExcDimensionMismatch (subdomain.size(),
+ triangulation.n_active_cells()));
+ unsigned int index = 0;
+ for (typename Triangulation<dim>::active_cell_iterator
+ cell = triangulation.begin_active();
+ cell!=triangulation.end(); ++cell, ++index)
+ subdomain[index] = cell->subdomain_id();
+
+ Assert (index == subdomain.size(), ExcInternalError());
+}
+
+
+
+template <int dim>
+unsigned int
+GridTools::
+count_cells_with_subdomain_association (const Triangulation<dim> &triangulation,
+ const unsigned int subdomain)
+{
+ unsigned int count = 0;
+ for (typename Triangulation<dim>::active_cell_iterator
+ cell = triangulation.begin_active();
+ cell!=triangulation.end(); ++cell)
+ if (cell->subdomain_id() == subdomain)
+ ++count;
+
+ Assert (count != 0, ExcNonExistentSubdomain(subdomain));
+
+ return count;
+}
+
+
+
#if deal_II_dimension != 1
template
double
void
GridTools::partition_triangulation (const unsigned int,
Triangulation<deal_II_dimension> &);
+
+template
+void
+GridTools::
+get_subdomain_association (const Triangulation<deal_II_dimension> &,
+ std::vector<unsigned int> &);
+
+template
+unsigned int
+GridTools::
+count_cells_with_subdomain_association (const Triangulation<deal_II_dimension> &,
+ const unsigned int );
+