]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
DoFTools::count_dofs_with_subdomain_association.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Mar 2004 20:15:44 +0000 (20:15 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Mar 2004 20:15:44 +0000 (20:15 +0000)
git-svn-id: https://svn.dealii.org/trunk@8864 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/dof_tools.h
deal.II/deal.II/source/dofs/dof_tools.cc

index 9f0f8a75f8000b1827b4a5a0ef38f2fdb7fb7717..0fe5070afa2918fb26be4820856e14839bf11b3f 100644 (file)
@@ -805,8 +805,29 @@ class DoFTools
     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
index f3f04aa07e2196daf508a8fea9c8117d9bcf2458..f5ffb0e50aba88f916cecae652ebc960be2d1865 100644 (file)
@@ -1715,6 +1715,41 @@ get_subdomain_association (const DoFHandler<dim>     &dof_handler,
 
 
 
+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::
@@ -3038,7 +3073,14 @@ DoFTools::get_subdomain_association<deal_II_dimension>
 (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>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.