]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add BlockInfo to DoFHandler
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 18 Mar 2010 16:16:39 +0000 (16:16 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 18 Mar 2010 16:16:39 +0000 (16:16 +0000)
git-svn-id: https://svn.dealii.org/trunk@20848 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/block_info.h
deal.II/deal.II/include/dofs/dof_handler.h
deal.II/deal.II/source/dofs/block_info.cc
deal.II/deal.II/source/dofs/dof_handler.cc
deal.II/deal.II/source/dofs/dof_tools.cc
deal.II/deal.II/source/fe/fe_tools.cc
deal.II/deal.II/source/multigrid/mg_dof_handler.cc
deal.II/deal.II/source/multigrid/mg_tools.cc
deal.II/doc/news/changes.h

index d8bb24f53314025cca250897a25f12c444fb7697..26d687c149e02b0cbaaaa85072562ce134b335fe 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2009 by the deal.II authors
+//    Copyright (C) 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
@@ -58,13 +58,17 @@ class BlockInfo : public Subscriptor
                                     /**
                                      * @brief Fill the object with values
                                      * describing level block
-                                     * structure of the MGDoFHandler.
+                                     * structure of the
+                                     * MGDoFHandler. If
+                                     * <tt>levels_only</tt> is false,
+                                     * the other initialize() is
+                                     * called as well.
                                      *
                                      * This function will also clear
                                      * the local() indices.
                                      */
     template <int dim, int spacedim>
-    void initialize(const MGDoFHandler<dim, spacedim>&);
+    void initialize(const MGDoFHandler<dim, spacedim>&, bool levels_only = false);
     
                                     /**
                                      * @brief Initialize block structure
index 21d0199550a32fc9d953ea773844405ec0b5c49b..9f70cd86f08e75c8ed9a898b8464d8e87c9abaa0 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
+//    Copyright (C) 1998, 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
@@ -18,6 +18,7 @@
 #include <base/config.h>
 #include <base/exceptions.h>
 #include <base/smartpointer.h>
+#include <dofs/block_info.h>
 #include <dofs/dof_iterator_selector.h>
 #include <dofs/function_map.h>
 
@@ -250,6 +251,19 @@ class DoFHandler  :  public Subscriptor
     virtual void distribute_dofs (const FiniteElement<dim,spacedim> &fe,
                                  const unsigned int        offset = 0);
 
+                                    /**
+                                     * After disatribute_dofs() with
+                                     * an FESystem element, the block
+                                     * structure of global and level
+                                     * vectors is stored in a
+                                     * BlockInfo object accessible
+                                     * with block_info(). This
+                                     * function initializes the local
+                                     * block structure on each cell
+                                     * in the same object.
+                                     */
+    void initialize_local_block_info();
+    
                                     /**
                                      * Clear all data of this object and
                                      * especially delete the lock this object
@@ -918,6 +932,34 @@ class DoFHandler  :  public Subscriptor
     unsigned int
     n_boundary_dofs (const std::set<unsigned char> &boundary_indicators) const;
 
+                                    /**
+                                     * Access to an object informing
+                                     * of the block structure of the
+                                     * dof handler.
+                                     *
+                                     * If an FESystem is used in
+                                     * distribute_dofs(), degrees ofd
+                                     * freedom naturally split into
+                                     * several @ref GlossBlock
+                                     * blocks. For each base element
+                                     * as many blocks appear as its
+                                     * multiplicity.
+                                     *
+                                     * At the end of
+                                     * distribute_dofs(), the number
+                                     * of degrees of freedom in each
+                                     * block is counted, and stored
+                                     * in a BlockInfo object, which
+                                     * can be accessed here. In an
+                                     * MGDoFHandler, the same is done
+                                     * on each level. Additionally,
+                                     * the block structure on each
+                                     * cell can be generated in this
+                                     * object by calling
+                                     * initialize_local_block_indices().
+                                     */
+    const BlockInfo& block_info() const;
+    
                                     /**
                                      * Return a constant reference to
                                      * the selected finite element
@@ -951,11 +993,16 @@ class DoFHandler  :  public Subscriptor
                                      */
     DeclException0 (ExcInvalidTriangulation);
                                     /**
-                                     * Exception
+                                     * No finite element has been
+                                     * assigned to this
+                                     * DoFHandler. Call the function
+                                     * DoFHandler::distribute_dofs()
+                                     * before you attemped to do what
+                                     * raised this exception.
                                      */
     DeclException0 (ExcNoFESelected);
                                     /**
-                                     * Exception
+                                     * @todo Replace by ExcInternalError.
                                      */
     DeclException0 (ExcRenumberingIncomplete);
                                     /**
@@ -1020,7 +1067,8 @@ class DoFHandler  :  public Subscriptor
                                      * this object as well, though).
                                      */
     SmartPointer<const FiniteElement<dim,spacedim>,DoFHandler<dim,spacedim> > selected_fe;
-
+    
+    BlockInfo block_info_object;
   private:
 
                                     /**
@@ -1137,6 +1185,15 @@ DoFHandler<dim,spacedim>::get_tria () const
 }
 
 
+template <int dim, int spacedim>
+inline
+const BlockInfo&
+DoFHandler<dim,spacedim>::block_info () const
+{
+  return block_info_object;
+}
+
+
 
 
 #endif // DOXYGEN
index fcbdfef5c3266e0ae7c12d9a1abc00b04ef17115..e3b2991c6f9ac52fe225c51a4f8e030946c1a418 100644 (file)
@@ -56,9 +56,10 @@ BlockInfo::initialize_local(const DoFHandler<dim, spacedim>& dof)
 
 template <int dim, int spacedim>
 void
-BlockInfo::initialize(const MGDoFHandler<dim, spacedim>& dof)
+BlockInfo::initialize(const MGDoFHandler<dim, spacedim>& dof, bool levels_only)
 {
-  initialize((DoFHandler<dim, spacedim>&) dof);
+  if (!levels_only)
+    initialize((DoFHandler<dim, spacedim>&) dof);
 
   std::vector<std::vector<unsigned int> > sizes (dof.get_tria().n_levels());
   for (unsigned int i=0; i<sizes.size(); ++i)
@@ -72,8 +73,14 @@ BlockInfo::initialize(const MGDoFHandler<dim, spacedim>& dof)
 
 
 template void BlockInfo::initialize(const DoFHandler<deal_II_dimension,deal_II_dimension>&);
-template void BlockInfo::initialize(const MGDoFHandler<deal_II_dimension,deal_II_dimension>&);
+template void BlockInfo::initialize(const MGDoFHandler<deal_II_dimension,deal_II_dimension>&, bool);
 template void BlockInfo::initialize_local(const DoFHandler<deal_II_dimension,deal_II_dimension>&);
 
+#if deal_II_dimension==1 || deal_II_dimension==2
+template void BlockInfo::initialize(const DoFHandler<deal_II_dimension,deal_II_dimension+1>&);
+template void BlockInfo::initialize(const MGDoFHandler<deal_II_dimension,deal_II_dimension+1>&, bool);
+template void BlockInfo::initialize_local(const DoFHandler<deal_II_dimension,deal_II_dimension+1>&);
+#endif
+
 
 DEAL_II_NAMESPACE_CLOSE
index 36c82dbba3622adf02967f9e9fce131b9bf2afd4..e776316bbda0f7fa0ad00c6dcd61dc91f4793211 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
+//    Copyright (C) 1998, 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
@@ -1995,9 +1995,17 @@ void DoFHandler<dim,spacedim>::
 
                                   // finally restore the user flags
   const_cast<Triangulation<dim,spacedim> &>(*tria).load_user_flags(user_flags);
+
+  block_info_object.initialize(*this);
 }
 
 
+template<int dim, int spacedim>
+void DoFHandler<dim,spacedim>::initialize_local_block_info ()
+{
+  block_info_object.initialize_local(*this);
+}
+
 
 template<int dim, int spacedim>
 void DoFHandler<dim,spacedim>::clear ()
index fcc25815aefe91cfa3f25bd4bed7f4bb0b230405..3366c7b68261a1920c67c7cb942d57dc3d4ee494 100644 (file)
@@ -5751,6 +5751,10 @@ DoFTools::count_dofs_per_component<deal_II_dimension> (
   std::vector<unsigned int>&, bool, std::vector<unsigned int>);
 
 #if deal_II_dimension < 3
+template void DoFTools::extract_level_dofs<deal_II_dimension, deal_II_dimension+1>
+(const unsigned int level, const MGDoFHandler<deal_II_dimension, deal_II_dimension+1>&,
+ const std::vector<bool>&, std::vector<bool>&, bool);
+
 template
 void
 DoFTools::count_dofs_per_component<deal_II_dimension, deal_II_dimension+1> (
@@ -5842,6 +5846,12 @@ DoFTools::map_dofs_to_support_points<deal_II_dimension,deal_II_dimension+1>
  const DoFHandler<deal_II_dimension, deal_II_dimension+1>&,
  std::vector<Point<deal_II_dimension+1> >&);
 
+template
+void
+DoFTools::count_dofs_per_block<deal_II_dimension,deal_II_dimension+1> (
+  const DoFHandler<deal_II_dimension,deal_II_dimension+1>&,
+  std::vector<unsigned int>&, std::vector<unsigned int>);
+
 #endif
 
 template
index d9ecc24fa88670b3f7d9b8eac63416da6f2bb69d..8152b48a24fa8f23941a9965044f3f5fdd324418 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors
+//    Copyright (C) 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
@@ -2115,6 +2115,10 @@ void FETools::interpolate<deal_II_dimension>
 
 #if deal_II_dimension != 3
 template
+void FETools::compute_block_renumbering (
+  const FiniteElement<deal_II_dimension,deal_II_dimension+1>& element,
+  std::vector<unsigned int>&, std::vector<unsigned int>&_indices, bool);
+template
 void FETools::interpolate<deal_II_dimension,deal_II_dimension+1>
 (const DoFHandler<deal_II_dimension,deal_II_dimension+1> &, const Vector<double> &,
  const DoFHandler<deal_II_dimension,deal_II_dimension+1> &, Vector<double> &);
index 42570597f0ed6a9364c6f7f32fd7e151c68dd650..d2819a894743c62481c4b2d01b5b3cfe7f92560c 100644 (file)
@@ -1992,6 +1992,8 @@ void MGDoFHandler<dim,spacedim>::distribute_dofs (const FiniteElement<dim,spaced
                                   // finally restore the user flags
   const_cast<Triangulation<dim,spacedim> &>(*(this->tria))
     .load_user_flags(user_flags);
+
+  this->block_info_object.initialize(*this, true);
 }
 
 
index a5673cdb2e9d30f2468e3136d76395071560839f..2afe759d0cd7f7bee34aedb0c221ee075a1bc1fd 100644 (file)
@@ -1024,7 +1024,7 @@ MGTools::count_dofs_per_block (
   std::vector<std::vector<unsigned int> >& dofs_per_block,
   std::vector<unsigned int>  target_block)
 {
-  const FiniteElement<dim>& fe = dof_handler.get_fe();
+  const FiniteElement<dim,spacedim>& fe = dof_handler.get_fe();
   const unsigned int n_blocks = fe.n_blocks();
   const unsigned int n_levels = dof_handler.get_tria().n_levels();
 
@@ -1639,4 +1639,12 @@ MGTools::
 extract_inner_interface_dofs (const MGDoFHandler<deal_II_dimension> &mg_dof_handler,
                              std::vector<std::vector<bool> >  &interface_dofs);
 
+#if deal_II_dimension < 3
+
+template void MGTools::count_dofs_per_block<deal_II_dimension,deal_II_dimension+1> (
+  const MGDoFHandler<deal_II_dimension,deal_II_dimension+1>&,
+  std::vector<std::vector<unsigned int> >&, std::vector<unsigned int>);
+
+#endif
+
 DEAL_II_NAMESPACE_CLOSE
index d782f6bcff96569045787416a71c1275c972cd11..77558246eca9fbd46700b0f20bcdf87fe7153a19 100644 (file)
@@ -589,6 +589,13 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+
+<li><p> Improved: DoFHandler now has a BlockInfo object, automatically updated after DoFHandler::distribute_dofs() and accessible by DoFHandler::block_info(). This object can be used to initialize block vectors and obliterates the necessity to count dofs per block (or dofs per component in legacy code) in application programs.
+<br>
+(GK 2010/03/18)
+</p>
+</li>
+
   <li>
   <p>
   New: The class MGTransferSelect is prepared for use on adaptively refined meshes.

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.