static void
get_subdomain_association (const DoFHandler<dim> &dof_handler,
std::vector<unsigned int> &subdomain);
-
- /**
+
+ /**
+ * Count how many degrees of freedom are
+ * uniquely associated with the given
+ * @arg subdomain index.
+ *
+ * Note that there may be rare cases
+ * where cells with the given @arg
+ * subdomain index exist, but none of its
+ * degrees of freedom are actually
+ * associated with it. In that case, the
+ * returned value will be zero.
+ *
+ * This function will generate an
+ * exception if there are no cells with
+ * the given @arg subdomain index.
+ */
+ template <int dim>
+ static unsigned int
+ count_dofs_with_subdomain_association (const DoFHandler<dim> &dof_handler,
+ const unsigned int subdomain);
+
+ /**
* Count how many degrees of
* freedom out of the total
* number belong to each
+template <int dim>
+unsigned int
+DoFTools::
+count_dofs_with_subdomain_association (const DoFHandler<dim> &dof_handler,
+ const unsigned int subdomain)
+{
+ // in debug mode, make sure that there are
+ // some cells at least with this subdomain
+ // id
+#ifdef DEBUG
+ {
+ bool found = false;
+ for (typename Triangulation<dim>::active_cell_iterator
+ cell=dof_handler.get_tria().begin_active();
+ cell!=dof_handler.get_tria().end(); ++cell)
+ if (cell->subdomain_id() == subdomain)
+ {
+ found = true;
+ break;
+ }
+ Assert (found == true,
+ ExcMessage ("There are no cells for the given subdomain!"));
+ }
+#endif
+
+ std::vector<unsigned int> subdomain_association (dof_handler.n_dofs());
+ get_subdomain_association (dof_handler, subdomain_association);
+
+ return std::count (subdomain_association.begin(),
+ subdomain_association.end(),
+ subdomain);
+}
+
+
+
template <int dim>
void
DoFTools::
(const DoFHandler<deal_II_dimension> &dof_handler,
std::vector<unsigned int> &subdomain_association);
-
+
+template
+unsigned int
+DoFTools::
+count_dofs_with_subdomain_association (const DoFHandler<deal_II_dimension> &,
+ const unsigned int);
+
+
template
void
DoFTools::count_dofs_per_component<deal_II_dimension>