]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a function.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 4 Jan 2010 14:52:36 +0000 (14:52 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 4 Jan 2010 14:52:36 +0000 (14:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@20279 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_tools.h
deal.II/deal.II/source/multigrid/mg_dof_tools.cc

index 046decf5daef9dfd946531e8911ba2ea5a2ff63b..c97ec97b87944ecf5271dd50774e3febfcac78dc 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2005, 2006, 2007, 2008 by the deal.II authors
+//    Copyright (C) 2005, 2006, 2007, 2008, 2010 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -389,6 +389,14 @@ class MGTools
        const std::vector<bool> &selected,
        const std::vector<unsigned int> &target_component,
        std::vector<std::vector<unsigned int> >& cached_sizes);
+
+
+    template <int dim, int spacedim>
+    static
+    void
+    extract_inner_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
+                                 std::vector<std::vector<bool> >  &interface_dofs,
+                                 std::vector<std::vector<bool> >  &boundary_interface_dofs);
 };
 
 /*@}*/
index 22c40f93edfebadb5c2419486b481e17f24dacec..7263edb93879845f807068738ea06246cd646974 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -1518,6 +1518,80 @@ MGTools::reinit_vector_by_blocks (
 }
 
 
+
+template <int dim, int spacedim>
+void
+MGTools::
+extract_inner_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
+                             std::vector<std::vector<bool> >  &interface_dofs,
+                             std::vector<std::vector<bool> >  &boundary_interface_dofs)
+{
+  const FiniteElement<dim,spacedim> &fe = mg_dof_handler.get_fe();
+  
+  const unsigned int   dofs_per_cell   = fe.dofs_per_cell;
+  const unsigned int   dofs_per_face   = fe.dofs_per_face;
+
+  std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+  std::vector<unsigned int> face_dof_indices (dofs_per_face);
+
+  std::vector<bool> cell_dofs(dofs_per_cell, false);
+  std::vector<bool> boundary_cell_dofs(dofs_per_cell, false);
+  
+  typename MGDoFHandler<dim>::cell_iterator cell = mg_dof_handler.begin(),
+                                           endc = mg_dof_handler.end();
+
+  for (; cell!=endc; ++cell)
+    {
+      bool has_coarser_neighbor = false;
+      
+      std::fill (cell_dofs.begin(), cell_dofs.end(), false);
+      std::fill (boundary_cell_dofs.begin(), boundary_cell_dofs.end(), false);
+  
+      for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
+       {
+         const typename DoFHandler<dim>::face_iterator face = cell->face(face_nr);
+         if (!face->at_boundary())
+           {
+                                              //interior face
+             const typename MGDoFHandler<dim>::cell_iterator
+               neighbor = cell->neighbor(face_nr);
+
+                                              // Do refinement face
+                                              // from the coarse side
+             if (neighbor->level() < cell->level())
+               {
+                 for (unsigned int j=0; j<dofs_per_face; ++j)
+                   cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
+
+                 has_coarser_neighbor = true;
+               }
+           }
+       }
+
+      if (has_coarser_neighbor == true)
+       for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
+         if(cell->at_boundary(face_nr))
+           for(unsigned int j=0; j<dofs_per_face; ++j)
+             if (cell_dofs[fe.face_to_cell_index(j,face_nr)] == true)
+               boundary_cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
+
+      
+      const unsigned int level = cell->level();
+      cell->get_mg_dof_indices (local_dof_indices);
+
+      for(unsigned int i=0; i<dofs_per_cell; ++i)
+       {
+         if (cell_dofs[i])
+           interface_dofs[level][local_dof_indices[i]] = true;
+
+         if (boundary_cell_dofs[i])
+           boundary_interface_dofs[level][local_dof_indices[i]] = true;
+       }
+    }
+}
+
+
+
 DEAL_II_NAMESPACE_CLOSE
 
 
@@ -1637,4 +1711,13 @@ template void MGTools::make_boundary_list(
   std::vector<std::set<unsigned int> >&,
   const std::vector<bool>&);
 
+#if deal_II_dimension > 1
+template
+void
+MGTools::
+extract_inner_interface_dofs (const MGDoFHandler<deal_II_dimension> &mg_dof_handler,
+                             std::vector<std::vector<bool> >  &interface_dofs,
+                             std::vector<std::vector<bool> >  &boundary_interface_dofs);
+#endif
+
 DEAL_II_NAMESPACE_CLOSE

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.