]> https://gitweb.dealii.org/ - dealii.git/commitdiff
count_dofs_per_component
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 22 Feb 2001 11:50:33 +0000 (11:50 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 22 Feb 2001 11:50:33 +0000 (11:50 +0000)
git-svn-id: https://svn.dealii.org/trunk@4010 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/dofs/dof_tools.cc
deal.II/doc/news/2001/c-3-1.html

index 7141a1e5f0ccbf2fbcf8faf5c58d07dc504cc188..7c206cda164b989ad7ea13d2530a85dad54bec65 100644 (file)
@@ -30,7 +30,7 @@
 #include <lac/vector.h>
 
 #include <algorithm>
-
+#include <numeric>
 
 // if necessary try to work around a bug in the IBM xlC compiler
 #ifdef XLC_WORK_AROUND_STD_BUG
@@ -1037,6 +1037,59 @@ DoFTools::extract_hanging_node_dofs (const DoFHandler<3> &dof_handler,
 
 
 
+template <int dim>
+void
+DoFTools::count_dofs_per_component (const DoFHandler<dim>     &dof_handler,
+                                   std::vector<unsigned int> &dofs_per_component)
+{
+  const unsigned int n_components = dof_handler.get_fe().n_components();
+  dofs_per_component.resize (n_components);
+
+                                  // special case for only one
+                                  // component. treat this first
+                                  // since it does not require any
+                                  // computations
+  if (n_components == 1)
+    {
+      dofs_per_component[0] = dof_handler.n_dofs();
+      return;
+    };
+  
+                                  // otherwise determine the number
+                                  // of dofs in each component
+                                  // separately. do so in parallel
+  std::vector<std::vector<bool> > dofs_in_component (n_components,
+                                                    std::vector<bool>(dof_handler.n_dofs(),
+                                                                      false));
+  std::vector<std::vector<bool> > component_select (n_components,
+                                                   std::vector<bool>(n_components, false));
+  Threads::ThreadManager thread_manager;
+  for (unsigned int i=0; i<n_components; ++i)
+    {
+      component_select[i][i] = true;
+      Threads::spawn (thread_manager,
+                     Threads::encapsulate (&DoFTools::template extract_dofs<dim>)
+                     .collect_args (dof_handler, component_select[i],
+                                    dofs_in_component[i]));
+    };
+  thread_manager.wait();
+
+                                  // next count what we got
+  for (unsigned int i=0; i<n_components; ++i)
+    dofs_per_component[i] = std::count(dofs_in_component[i].begin(),
+                                      dofs_in_component[i].end(),
+                                      true);
+
+                                  // finally sanity check
+  Assert (std::accumulate (dofs_per_component.begin(), dofs_per_component.end(), 0U)
+         ==
+         dof_handler.n_dofs(),
+         ExcInternalError());
+         
+};
+
+
+
 template <int dim>
 void
 DoFTools::compute_intergrid_constraints (const DoFHandler<dim>              &coarse_grid,
@@ -1780,6 +1833,13 @@ DoFTools::extract_boundary_dofs (const DoFHandler<deal_II_dimension> &,
                                 std::vector<bool>                        &);
 #endif 
 
+
+template
+void
+DoFTools::count_dofs_per_component (const DoFHandler<deal_II_dimension> &dof_handler,
+                                   std::vector<unsigned int>           &dofs_per_component);
+
+
 template
 void
 DoFTools::compute_intergrid_constraints (const DoFHandler<deal_II_dimension> &,
index 2e952238fd723a63ec6b3629d5958fd553aff895..0dff483f9605cf9b3e8135e9800776985fc98d8d 100644 (file)
@@ -111,8 +111,18 @@ documentation, etc</a>.
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p> 
+       New: The <code class="class">DoFTools</code> class now has
+       a function <code class="member">count_dofs_per_component</code>
+       that counts the number of degrees of freedom in each of the
+       components of the finite element, i.e. how many degrees of
+       freedom there are on the global mesh for each variable (field).
+       <br>
+       (WB 2001/02/22)
+       </p>
+
   <li> <p>
-       New: The <code class="class">CellAccessor</code> now has a function
+       New: The <code class="class">CellAccessor</code> class now has a function
        <code class="member">has_boundary_lines</code> that mostly has
        the same semantics that <code class="member">at_boundary</code>
        has, but also covers the case that a hexahedron in 3d may be at

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.