]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add extract_locally_relevant_mg_dofs
authorTimo Heister <timo.heister@gmail.com>
Sun, 8 Jun 2014 23:23:56 +0000 (19:23 -0400)
committerTimo Heister <timo.heister@gmail.com>
Thu, 31 Jul 2014 06:20:18 +0000 (08:20 +0200)
include/deal.II/dofs/dof_tools.h
source/dofs/dof_tools.cc
source/dofs/dof_tools.inst.in

index 10474e286549688f35f2c7505bd18b39735149d4..30737de05da86289316afac15338eee6a86158e7 100644 (file)
@@ -1,5 +1,5 @@
 // ---------------------------------------------------------------------
-// $Id$
+// $Id: dof_tools.h 32722 2014-04-06 17:25:25Z kronbichler $
 //
 // Copyright (C) 1999 - 2014 by the deal.II authors
 //
@@ -1525,6 +1525,16 @@ namespace DoFTools
   extract_locally_relevant_dofs (const DH &dof_handler,
                                  IndexSet &dof_set);
 
+  /**
+   * Same as extract_locally_relevant_dofs() but for multigrid DoFs
+   * for the given @p level.
+   */
+  template <class DH>
+  void
+  extract_locally_relevant_mg_dofs (const DH &dof_handler,
+                                 IndexSet &dof_set,
+                                 unsigned int level);
+
   /**
    * For each DoF, return in the output array to which subdomain (as
    * given by the <tt>cell->subdomain_id()</tt> function) it
index 90967781b0ccf49988adfcd77d359eaa8a8ce4ab..f5605b90d2fd56549c5f294c5a313877f60039e6 100644 (file)
@@ -972,6 +972,46 @@ namespace DoFTools
   }
 
 
+  template <class DH>
+  void
+  extract_locally_relevant_mg_dofs (const DH &dof_handler,
+                                 IndexSet &dof_set,
+                                 unsigned int level)
+  {
+    // collect all the locally owned dofs
+    dof_set = dof_handler.locally_owned_mg_dofs(level);
+
+    // add the DoF on the adjacent ghost cells to the IndexSet, cache them
+    // in a set. need to check each dof manually because we can't be sure
+    // that the dof range of locally_owned_dofs is really contiguous.
+    std::vector<types::global_dof_index> dof_indices;
+    std::set<types::global_dof_index> global_dof_indices;
+
+    typename DH::cell_iterator cell = dof_handler.begin(level),
+                                      endc = dof_handler.end(level);
+    for (; cell!=endc; ++cell)
+      {
+        types::subdomain_id id = cell->level_subdomain_id();
+
+        // skip artificial and own cells (only look at ghost cells)
+        if (id == dof_handler.get_tria().locally_owned_subdomain()
+            || id == numbers::artificial_subdomain_id)
+          continue;
+
+        dof_indices.resize(cell->get_fe().dofs_per_cell);
+        cell->get_mg_dof_indices(dof_indices);
+
+        for (std::vector<types::global_dof_index>::iterator it=dof_indices.begin();
+            it!=dof_indices.end();
+            ++it)
+          if (!dof_set.is_element(*it))
+            global_dof_indices.insert(*it);
+        }
+
+    dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end());
+
+    dof_set.compress();
+  }
 
   template <class DH>
   void
index 05a94aaef92a50c2c11b0e5a88ff2e2a4a856a1b..f7695d7c0a81d83f404d24df748fc92db5e99ed0 100644 (file)
@@ -263,6 +263,12 @@ DoFTools::extract_locally_relevant_dofs<hp::DoFHandler<deal_II_dimension> >
 (const hp::DoFHandler<deal_II_dimension> & dof_handler,
  IndexSet & dof_set);
 
+template
+void
+DoFTools::extract_locally_relevant_mg_dofs<DoFHandler<deal_II_dimension> >
+(const DoFHandler<deal_II_dimension> & dof_handler,
+ IndexSet & dof_set, unsigned int level);
+
 template
 void
 DoFTools::extract_constant_modes<DoFHandler<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.