]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Move two functions (make_hanging_nodes_constraints and interpolate_cell_to_dof) from...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 13 Dec 1999 15:38:48 +0000 (15:38 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 13 Dec 1999 15:38:48 +0000 (15:38 +0000)
git-svn-id: https://svn.dealii.org/trunk@2053 0785d39b-7218-0410-832d-ea1e28bc413d

17 files changed:
deal.II/deal.II/Attic/examples/convergence/convergence.cc
deal.II/deal.II/Attic/examples/dof/dof_test.cc
deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc
deal.II/deal.II/Attic/examples/multigrid/multigrid.cc
deal.II/deal.II/include/dofs/dof_handler.h
deal.II/deal.II/include/dofs/dof_tools.h
deal.II/deal.II/source/dofs/dof_handler.cc
deal.II/deal.II/source/dofs/dof_renumbering.cc
deal.II/deal.II/source/dofs/dof_tools.cc
deal.II/deal.II/source/numerics/base.cc
tests/big-tests/convergence/convergence.cc
tests/big-tests/dof/dof_test.cc
tests/big-tests/error-estimation/error-estimation.cc
tests/big-tests/multigrid/multigrid.cc
tests/deal.II/Makefile
tests/deal.II/dof_test.cc
tests/deal.II/wave-test-3.cc

index b95a2e8dc679a07ee50efb0d03f35069602c5e82..40ec20423fc59ce3a0fa0079334ad8a862545207 100644 (file)
@@ -3,12 +3,13 @@
 
 
 #include <grid/tria.h>
-#include <dofs/dof_handler.h>
 #include <grid/tria_accessor.h>
-#include <dofs/dof_accessor.h>
 #include <grid/tria_iterator.h>
 #include <grid/tria_boundary_lib.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_accessor.h>
 #include <dofs/dof_constraints.h>
+#include <dofs/dof_tools.h>
 #include <grid/grid_generator.h>
 #include <base/function.h>
 #include <numerics/data_out.h>
@@ -387,13 +388,13 @@ int PoissonProblem<dim>::run (const unsigned int level) {
       Vector<double> linfty_error_per_dof(dof->n_dofs());
       Vector<double> h1_seminorm_error_per_dof(dof->n_dofs());
       Vector<double> h1_error_per_dof(dof->n_dofs());
-      dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof);
-      dof->distribute_cell_to_dof_vector (l2_error_per_cell, l2_error_per_dof);
-      dof->distribute_cell_to_dof_vector (linfty_error_per_cell,
-                                         linfty_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_seminorm_error_per_cell,
-                                         h1_seminorm_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, l1_error_per_cell, l1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, l2_error_per_cell, l2_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, linfty_error_per_cell,
+                                              linfty_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_seminorm_error_per_cell,
+                                              h1_seminorm_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_error_per_cell, h1_error_per_dof);
 
 //       Vector<double> projected_solution;
 //       ConstraintMatrix constraints;
index 594c1c084225e6b1a6066621303641dac5864760..5fe5ecf078b506e94582f9880dc1cf566b21b5ce 100644 (file)
@@ -376,7 +376,7 @@ void TestCases<dim>::run (ParameterHandler &prm) {
                                   // computing constraints
   cout << "    Computing constraints..." << endl;
   ConstraintMatrix constraints;
-  dof->make_hanging_node_constraints (constraints);
+  DoFTools::make_hanging_node_constraints (*dof, constraints);
   constraints.close ();
   constraints.condense (sparsity);
   
index 308df106035b089acd7f1f908f3ecf34965b32a5..9d6b65fdbe96956b2d1f5ccc561bbdabb516c368 100644 (file)
@@ -2,20 +2,21 @@
 /* Copyright W. Bangerth, University of Heidelberg, 1998 */
 
 
+#include <base/function.h>
+#include <base/parameter_handler.h>
+#include <base/quadrature_lib.h>
+#include <grid/grid_generator.h>
+#include <grid/grid_out.h>
 #include <grid/tria.h>
-#include <dofs/dof_handler.h>
 #include <grid/tria_accessor.h>
-#include <dofs/dof_accessor.h>
-#include <grid/tria_iterator.h>
 #include <grid/tria_boundary_lib.h>
+#include <grid/tria_iterator.h>
+#include <dofs/dof_accessor.h>
 #include <dofs/dof_constraints.h>
-#include <grid/grid_generator.h>
-#include <base/function.h>
-#include <numerics/data_out.h>
-#include <grid/grid_out.h>
-#include <base/parameter_handler.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_tools.h>
 #include <fe/fe_lib.lagrange.h>
-#include <base/quadrature_lib.h>
+#include <numerics/data_out.h>
 #include <numerics/base.h>
 #include <numerics/assembler.h>
 #include <numerics/vectors.h>
@@ -559,11 +560,11 @@ void PoissonProblem<dim>::run (ParameterHandler &prm) {
       Vector<double> l2_error_per_dof(dof->n_dofs()), linfty_error_per_dof(dof->n_dofs());
       Vector<double> h1_error_per_dof(dof->n_dofs()), estimated_error_per_dof(dof->n_dofs());
       Vector<double> error_ratio (dof->n_dofs());
-      dof->distribute_cell_to_dof_vector (l2_error_per_cell, l2_error_per_dof);
-      dof->distribute_cell_to_dof_vector (linfty_error_per_cell,
+      DoFTools::distribute_cell_to_dof_vector (*dof, l2_error_per_cell, l2_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, linfty_error_per_cell,
                                          linfty_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof);
-      dof->distribute_cell_to_dof_vector (estimated_error_per_cell,
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_error_per_cell, h1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, estimated_error_per_cell,
                                          estimated_error_per_dof);
       error_ratio.ratio (h1_error_per_dof, estimated_error_per_dof);
   
index 9e13e94fd27af7f732f4c643c21a8c0edbb60d2f..a862bdda17bc3abb27c3f80ee86ee594e2bd8d58 100644 (file)
@@ -353,7 +353,7 @@ void PoissonProblem<dim>::assemble (const Equation<dim>      &equation,
                                   // make up sparsity pattern and
                                   // compress with constraints
   constraints.clear ();
-  dof->DoFHandler<dim>::make_hanging_node_constraints (constraints);
+  DoFTools::make_hanging_node_constraints (*dof, constraints);
   constraints.close ();
   DoFTools::make_sparsity_pattern (*dof, system_sparsity);
   constraints.condense (system_sparsity);
@@ -557,13 +557,13 @@ int PoissonProblem<dim>::run (const unsigned int level) {
       Vector<double> linfty_error_per_dof (dof->DoFHandler<dim>::n_dofs());
       Vector<double> h1_seminorm_error_per_dof (dof->DoFHandler<dim>::n_dofs());
       Vector<double> h1_error_per_dof (dof->DoFHandler<dim>::n_dofs());
-      dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof);
-      dof->distribute_cell_to_dof_vector (l2_error_per_cell, l2_error_per_dof);
-      dof->distribute_cell_to_dof_vector (linfty_error_per_cell,
+      DoFTools::distribute_cell_to_dof_vector (*dof, l1_error_per_cell, l1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, l2_error_per_cell, l2_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, linfty_error_per_cell,
                                          linfty_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_seminorm_error_per_cell,
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_seminorm_error_per_cell,
                                          h1_seminorm_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_error_per_cell, h1_error_per_dof);
 
 //       Vector<double> projected_solution;
 //       ConstraintMatrix constraints;
index 07c191c11702468d2311156ceedbc472344d269a..2fbf020ec66ecc1d7b19553be16b52dcad3198dc 100644 (file)
@@ -145,10 +145,6 @@ class DoFDimensionInfo<3> {
  * degrees of freedom only. The actual layout of storage of the indices
  * is described in the \Ref{DoFLevel} class documentation.
  *
- * Additionally, the DoFHandler is able to generate the condensation
- * matrix which connects constrained and unconstrained matrices and
- * vectors.
- *
  * Finally it offers a starting point for the assemblage of the matrices
  * by offering #begin()# and #end()# functions which return iterators
  * to walk on the DoF structures as well as the triangulation data.
@@ -334,28 +330,38 @@ class DoFHandler  :  public Subscriptor,
                                      * according to the given distribution
                                      * method.
                                      *
-                                     * The additional optional parameter #offset#
-                                     * allows you to reserve space for a finite number
-                                     * of additional vector entries in the beginning
-                                     * of all discretization vectors.
+                                     * The additional optional
+                                     * parameter #offset# allows you
+                                     * to reserve space for a finite
+                                     * number of additional vector
+                                     * entries in the beginning of
+                                     * all discretization vectors, by
+                                     * starting the enumeration of
+                                     * degrees of freedom on the grid
+                                     * at a nonzero value. By
+                                     * default, this value is of
+                                     * course zero.
                                      *
-                                     * A pointer of the transferred finite
-                                     * element is stored. Therefore, the
-                                     * lifetime of the finite element object
-                                     * shall be longer than that of this
-                                     * object. If you don't want this
-                                     * behaviour, you may want to call
-                                     * the #clear# member function which also
-                                     * releases the lock of this object to the
-                                     * finite element.
+                                     * A pointer of the transferred
+                                     * finite element is
+                                     * stored. Therefore, the
+                                     * lifetime of the finite element
+                                     * object shall be longer than
+                                     * that of this object. If you
+                                     * don't want this behaviour, you
+                                     * may want to call the #clear#
+                                     * member function which also
+                                     * releases the lock of this
+                                     * object to the finite element.
                                      *
-                                     * This function uses the user flags of the
-                                     * triangulation object, so make sure you
-                                     * don't need them after calling this
+                                     * This function uses the user
+                                     * flags of the triangulation
+                                     * object, so make sure you don't
+                                     * need them after calling this
                                      * function, or if so store them.
                                      */
-    virtual void distribute_dofs (const FiniteElement<dim> &,
-                                 unsigned int offset = 0);
+    virtual void distribute_dofs (const FiniteElement<dim> &fe,
+                                 const unsigned int        offset = 0);
 
                                     /**
                                      * Clear all data of this object and
@@ -386,43 +392,6 @@ class DoFHandler  :  public Subscriptor,
                                      */
     void renumber_dofs (const vector<int> &new_numbers);
 
-                                    /**
-                                     * Make up the constraints which
-                                     * is result from the use of hanging
-                                     * nodes. The object into which these
-                                     * are inserted is later
-                                     * used to condensate the global
-                                     * system matrices and to prolong
-                                     * the solution vectors from the true
-                                     * degrees of freedom also to the
-                                     * constraint nodes.
-                                     *
-                                     * Since this method does not make sense in
-                                     * one dimension, the function returns
-                                     * immediately. The object is not cleared
-                                     * before use, so you should make sure
-                                     * it containts only constraints you still
-                                     * want; otherwise call the #clear#
-                                     * function.
-                                     *
-                                     * To condense a given sparsity pattern,
-                                     * use #ConstraintMatrix::condense#.
-                                     * Before doing so, you need to close
-                                     * the constraint object, which must be
-                                     * done after all constraints are entered.
-                                     * This function does not close the object
-                                     * since you may want to enter other
-                                     * constraints later on yourself.
-                                     *
-                                     * This function uses the user flags for
-                                     * the faces. If you need the user flags,
-                                     * store them beforehand.
-                                     */
-    void make_hanging_node_constraints (ConstraintMatrix &) const;
-
-
-
-    
                                     /**
                                      * Return the maximum number of
                                      * degrees of freedom a degree of freedom
@@ -459,54 +428,6 @@ class DoFHandler  :  public Subscriptor,
                                      * dimension less.
                                      */
     unsigned int max_couplings_between_boundary_dofs () const;
-    
-                                    /**
-                                     * Take a vector of values which live on
-                                     * cells (e.g. an error per cell) and
-                                     * distribute it to the dofs in such a
-                                     * way that a finite element field results,
-                                     * which can then be further processed,
-                                     * e.g. for output. You should note that
-                                     * the resulting field will not be
-                                     * continuous at hanging nodes. This can,
-                                     * however, easily be arranged by calling
-                                     * the appropraite #distribute# function
-                                     * of a #ConstraintMatrix# object created
-                                     * for this #DoFHandler# object.
-                                     *
-                                     * It is assumed that the number of
-                                     * elements in #cell_data# equals the
-                                     * number of active cells. The size of
-                                     * #dof_data# is adjusted to the right
-                                     * size.
-                                     *
-                                     * Note that the input vector may be
-                                     * a vector of any data type as long
-                                     * as it is convertible to #double#.
-                                     * The output vector, being a data
-                                     * vector on the grid, always consists
-                                     * of elements of type #double#.
-                                     *
-                                     * In case the finite element used by
-                                     * this DoFHandler consists of more than
-                                     * one component, you should give which
-                                     * component in the output vector should
-                                     * be used to store the finite element
-                                     * field in; the default is zero (no other
-                                     * value is allowed if the finite element
-                                     * consists only of one component). All
-                                     * other components of the vector remain
-                                     * untouched, i.e. their contents are
-                                     * not changed.
-                                     *
-                                     * It is assumed that the output vector
-                                     * #dof_data# already has the right size,
-                                     * i.e. #n_dofs()# elements.
-                                     */
-    template <typename Number>
-    void distribute_cell_to_dof_vector (const Vector<Number> &cell_data,
-                                       Vector<double>       &dof_data,
-                                       const unsigned int    component = 0) const;
 
                                     /**
                                      * Create a mapping from degree of freedom
@@ -1160,10 +1081,6 @@ class DoFHandler  :  public Subscriptor,
                                     /**
                                      * Exception
                                      */
-    DeclException0 (ExcInternalError);
-                                    /**
-                                     * Exception
-                                     */
     DeclException1 (ExcMatrixHasWrongSize,
                    int,
                    << "The matrix has the wrong dimension " << arg1);
@@ -1174,26 +1091,10 @@ class DoFHandler  :  public Subscriptor,
                                     /**
                                      * Exception
                                      */
-    DeclException2 (ExcWrongSize,
-                   int, int,
-                   << "The dimension " << arg1 << " of the vector is wrong. "
-                   << "It should be " << arg2);
-                                    /**
-                                     * Exception
-                                     */
     DeclException1 (ExcNewNumbersNotConsecutive,
                    int,
                    << "The given list of new dof indices is not consecutive: "
                    << "the index " << arg1 << " does not exist.");
-                                    /**
-                                     * Exception
-                                     */
-    DeclException2 (ExcInvalidComponent,
-                   int, int,
-                   << "The component you gave (" << arg1 << ") "
-                   << "is invalid with respect to the number "
-                   << "of components in the finite element "
-                   << "(" << arg2 << ")");
 
   protected:
     
@@ -1320,7 +1221,17 @@ class DoFHandler  :  public Subscriptor,
 
 template <int dim>
 inline
-const FiniteElement<dim> & DoFHandler<dim>::get_fe () const {
+unsigned int DoFHandler<dim>::n_dofs () const
+{
+  return used_dofs;
+};
+
+
+
+template <int dim>
+inline
+const FiniteElement<dim> & DoFHandler<dim>::get_fe () const
+{
   return *selected_fe;
 };
 
index b34836d55a7ca3171faf6f5ab3f0f199d3828678..49c05b3676d788c1a0ac11f8e28e925a4a42ff04 100644 (file)
@@ -219,6 +219,93 @@ class DoFTools
     static void make_flux_sparsity_pattern (const DoFHandler<dim> &dof_handler,
                                            SparseMatrixStruct    &sparsity_pattern);
     
+                                    /**
+                                     * Make up the constraints which
+                                     * is result from the use of hanging
+                                     * nodes. The object into which these
+                                     * are inserted is later
+                                     * used to condensate the global
+                                     * system matrices and to prolong
+                                     * the solution vectors from the true
+                                     * degrees of freedom also to the
+                                     * constraint nodes.
+                                     *
+                                     * Since this method does not make sense in
+                                     * one dimension, the function returns
+                                     * immediately. The object is not cleared
+                                     * before use, so you should make sure
+                                     * it containts only constraints you still
+                                     * want; otherwise call the #clear#
+                                     * function.
+                                     *
+                                     * To condense a given sparsity pattern,
+                                     * use #ConstraintMatrix::condense#.
+                                     * Before doing so, you need to close
+                                     * the constraint object, which must be
+                                     * done after all constraints are entered.
+                                     * This function does not close the object
+                                     * since you may want to enter other
+                                     * constraints later on yourself.
+                                     *
+                                     * This function uses the user flags for
+                                     * the faces. If you need the user flags,
+                                     * store them beforehand.
+                                     */
+    template <int dim>
+    static void
+    make_hanging_node_constraints (const DoFHandler<dim> &dof_handler,
+                                  ConstraintMatrix      &constraints);
+
+                                    /**
+                                     * Take a vector of values which live on
+                                     * cells (e.g. an error per cell) and
+                                     * distribute it to the dofs in such a
+                                     * way that a finite element field results,
+                                     * which can then be further processed,
+                                     * e.g. for output. You should note that
+                                     * the resulting field will not be
+                                     * continuous at hanging nodes. This can,
+                                     * however, easily be arranged by calling
+                                     * the appropraite #distribute# function
+                                     * of a #ConstraintMatrix# object created
+                                     * for this #DoFHandler# object.
+                                     *
+                                     * It is assumed that the number of
+                                     * elements in #cell_data# equals the
+                                     * number of active cells. The size of
+                                     * #dof_data# is adjusted to the right
+                                     * size.
+                                     *
+                                     * Note that the input vector may be
+                                     * a vector of any data type as long
+                                     * as it is convertible to #double#.
+                                     * The output vector, being a data
+                                     * vector on the grid, always consists
+                                     * of elements of type #double#.
+                                     *
+                                     * In case the finite element used by
+                                     * this DoFHandler consists of more than
+                                     * one component, you should give which
+                                     * component in the output vector should
+                                     * be used to store the finite element
+                                     * field in; the default is zero (no other
+                                     * value is allowed if the finite element
+                                     * consists only of one component). All
+                                     * other components of the vector remain
+                                     * untouched, i.e. their contents are
+                                     * not changed.
+                                     *
+                                     * It is assumed that the output vector
+                                     * #dof_data# already has the right size,
+                                     * i.e. #n_dofs()# elements.
+                                     */
+    template <int dim, typename Number>
+    static void
+    distribute_cell_to_dof_vector (const DoFHandler<dim> &dof_handler,
+                                  const Vector<Number>  &cell_data,
+                                  Vector<double>        &dof_data,
+                                  const unsigned int     component = 0);
+
                                     /**
                                      * Extract the indices of the degrees
                                      * of freedom belonging to certain
@@ -249,6 +336,23 @@ class DoFTools
                                   const MGDoFHandler<dim> &dof,
                                   const vector<bool>      &select,
                                   vector<bool>            &selected_dofs);
+
+                                    /**
+                                     * Exception
+                                     */
+    DeclException2 (ExcWrongSize,
+                   int, int,
+                   << "The dimension " << arg1 << " of the vector is wrong. "
+                   << "It should be " << arg2);
+                                    /**
+                                     * Exception
+                                     */
+    DeclException2 (ExcInvalidComponent,
+                   int, int,
+                   << "The component you gave (" << arg1 << ") "
+                   << "is invalid with respect to the number "
+                   << "of components in the finite element "
+                   << "(" << arg2 << ")");
 };
 
 
index 1a2b242a79adec892d60ee53a61382e1c5aee2df..edc8009d4d7a9c1bcf666f0e1635e681f4632807 100644 (file)
@@ -1,27 +1,22 @@
 /* $Id$ */
-/* Copyright W. Bangerth, University of Heidelberg, 1998 */
+/* Copyright W. Bangerth, University of Heidelberg, 1998, 1999 */
 
 
 #include <dofs/dof_handler.h>
 #include <dofs/dof_levels.h>
 #include <dofs/dof_accessor.h>
-#include <dofs/dof_constraints.h>
-#include <grid/tria_levels.h>
 #include <grid/tria_accessor.h>
 #include <grid/tria_iterator.h>
+#include <grid/tria_levels.h>
 #include <grid/tria.h>
 #include <grid/geometry_info.h>
 #include <fe/fe.h>
-#include <lac/sparse_matrix.h>
-#include <lac/vector.h>
-#include <lac/vector.h>
 
 #include <set>
 #include <algorithm>
 
 
 
-
 template <int dim>
 DoFHandler<dim>::DoFHandler (Triangulation<dim> *tria) :
                tria(tria),
@@ -1287,13 +1282,6 @@ DoFHandler<dim>::last_active_hex () const {
 
 
 
-template <int dim>
-unsigned int DoFHandler<dim>::n_dofs () const {
-  return used_dofs;
-};
-
-
-
 #if deal_II_dimension == 1
 
 template <>
@@ -1374,7 +1362,7 @@ const Triangulation<dim> & DoFHandler<dim>::get_tria () const {
 
 template <int dim>
 void DoFHandler<dim>::distribute_dofs (const FiniteElement<dim> &ff,
-                                      unsigned int offset)
+                                      const unsigned int        offset)
 {
   Assert (tria->n_levels() > 0, ExcInvalidTriangulation());
   
@@ -1731,254 +1719,6 @@ void DoFHandler<3>::renumber_dofs (const vector<int> &new_numbers) {
 
 
 
-#if deal_II_dimension == 1
-
-template <>
-void DoFHandler<1>::make_hanging_node_constraints (ConstraintMatrix &) const {};
-
-#endif
-
-
-
-#if deal_II_dimension == 2
-
-template <>
-void DoFHandler<2>::make_hanging_node_constraints (ConstraintMatrix &constraints) const {
-  const unsigned int dim = 2;
-  
-                                  // first mark all faces which are subject
-                                  // to constraints. We do so by looping
-                                  // over all active cells and checking
-                                  // whether any of the faces are refined
-                                  // which can only be from the neighboring
-                                  // cell because this one is active. In that
-                                  // case, the face is subject to constraints
-  tria->clear_user_flags ();
-  Triangulation<dim>::active_cell_iterator cell = tria->begin_active(),
-                                          endc = tria->end();
-  for (; cell!=endc; ++cell)
-    for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-      if (cell->face(face)->has_children()) 
-       cell->face(face)->set_user_flag();
-         
-  
-
-  
-  line_iterator line = begin_line(),
-               endl = end_line();
-                                  // loop over all lines; only on lines
-                                  // there can be constraints.
-  for (; line != endl; ++line)
-                                    // if dofs on this line are subject
-                                    // to constraints
-    if (line->user_flag_set() == true)
-      {
-                                        // reserve space to gather
-                                        // the dof numbers. We could
-                                        // get them when we need them,
-                                        // but it seems easier to gather
-                                        // them only once.
-       vector<int> dofs_on_mother;
-       vector<int> dofs_on_children;
-       dofs_on_mother.reserve (2*selected_fe->dofs_per_vertex+
-                               selected_fe->dofs_per_line);
-       dofs_on_children.reserve (selected_fe->dofs_per_vertex+
-                                 2*selected_fe->dofs_per_line);
-
-       Assert(2*selected_fe->dofs_per_vertex+selected_fe->dofs_per_line ==
-              selected_fe->constraints().n(),
-              ExcDimensionMismatch(2*selected_fe->dofs_per_vertex+
-                                     selected_fe->dofs_per_line,
-                                     selected_fe->constraints().n()));
-       Assert(selected_fe->dofs_per_vertex+2*selected_fe->dofs_per_line ==
-              selected_fe->constraints().m(),
-              ExcDimensionMismatch(3*selected_fe->dofs_per_vertex+
-                                     2*selected_fe->dofs_per_line,
-                                     selected_fe->constraints().m()));
-       
-                                        // fill the dofs indices. Use same
-                                        // enumeration scheme as in
-                                        // #FiniteElement::constraints()#
-       for (unsigned int vertex=0; vertex<2; ++vertex)
-         for (unsigned int dof=0; dof!=selected_fe->dofs_per_vertex; ++dof)
-           dofs_on_mother.push_back (line->vertex_dof_index(vertex,dof));
-       for (unsigned int dof=0; dof!=selected_fe->dofs_per_line; ++dof)
-         dofs_on_mother.push_back (line->dof_index(dof));
-
-       for (unsigned int dof=0; dof!=selected_fe->dofs_per_vertex; ++dof)
-         dofs_on_children.push_back (line->child(0)->vertex_dof_index(1,dof));
-       for (unsigned int child=0; child<2; ++child)
-         for (unsigned int dof=0; dof!=selected_fe->dofs_per_line; ++dof)
-           dofs_on_children.push_back (line->child(child)->dof_index(dof));
-
-                                        // for each row in the constraint
-                                        // matrix for this line:
-       for (unsigned int row=0; row!=dofs_on_children.size(); ++row) 
-         {
-           constraints.add_line (dofs_on_children[row]);
-           for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
-             constraints.add_entry (dofs_on_children[row],
-                                    dofs_on_mother[i],
-                                    selected_fe->constraints()(row,i));
-         };
-      };
-};
-
-#endif
-
-
-
-#if deal_II_dimension == 3
-
-template <>
-void DoFHandler<3>::make_hanging_node_constraints (ConstraintMatrix &constraints) const {
-  const unsigned int dim = 3;
-  
-                                  // first mark all faces which are subject
-                                  // to constraints. We do so by looping
-                                  // over all active cells and checking
-                                  // whether any of the faces are refined
-                                  // which can only be from the neighboring
-                                  // cell because this one is active. In that
-                                  // case, the face is subject to constraints
-  tria->clear_user_flags ();
-  Triangulation<dim>::active_cell_iterator cell = tria->begin_active(),
-                                          endc = tria->end();
-  for (; cell!=endc; ++cell)
-    for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-      if (cell->face(face)->has_children()) 
-       cell->face(face)->set_user_flag();
-         
-  
-
-  
-  face_iterator face = begin_face(),
-               endf = end_face();
-                                  // loop over all faces; only on faces
-                                  // there can be constraints.
-  for (; face != endf; ++face)
-                                    // if dofs on this line are subject
-                                    // to constraints
-    if (face->user_flag_set() == true)
-      {
-                                        // reserve space to gather
-                                        // the dof numbers. We could
-                                        // get them when we need them,
-                                        // but it seems easier to gather
-                                        // them only once.
-       vector<int> dofs_on_mother;
-       vector<int> dofs_on_children;
-       dofs_on_mother.reserve (4*selected_fe->dofs_per_vertex+
-                               4*selected_fe->dofs_per_line+
-                               selected_fe->dofs_per_quad);
-       dofs_on_children.reserve (5*selected_fe->dofs_per_vertex+
-                                 12*selected_fe->dofs_per_line+
-                                 4*selected_fe->dofs_per_quad);
-
-       Assert(4*selected_fe->dofs_per_vertex+
-              4*selected_fe->dofs_per_line+
-              selected_fe->dofs_per_quad
-              ==
-              selected_fe->constraints().n(),
-              ExcDimensionMismatch(4*selected_fe->dofs_per_vertex+
-                                     4*selected_fe->dofs_per_line+
-                                     selected_fe->dofs_per_quad,
-                                     selected_fe->constraints().n()));
-       Assert(5*selected_fe->dofs_per_vertex+
-              12*selected_fe->dofs_per_line+
-              4*selected_fe->dofs_per_quad
-              ==
-              selected_fe->constraints().m(),
-              ExcDimensionMismatch(5*selected_fe->dofs_per_vertex+
-                                     12*selected_fe->dofs_per_line+
-                                     4*selected_fe->dofs_per_quad,
-                                     selected_fe->constraints().m()));
-       
-                                        // fill the dofs indices. Use same
-                                        // enumeration scheme as in
-                                        // #FiniteElement::constraints()#
-       for (unsigned int vertex=0; vertex<4; ++vertex)
-         for (unsigned int dof=0; dof!=selected_fe->dofs_per_vertex; ++dof)
-           dofs_on_mother.push_back (face->vertex_dof_index(vertex,dof));
-       for (unsigned int line=0; line<4; ++line)
-         for (unsigned int dof=0; dof!=selected_fe->dofs_per_line; ++dof)
-           dofs_on_mother.push_back (face->line(line)->dof_index(dof));
-       for (unsigned int dof=0; dof!=selected_fe->dofs_per_quad; ++dof)
-         dofs_on_mother.push_back (face->dof_index(dof));
-
-                                        // dof numbers on vertex at the center
-                                        // of the face, which is vertex 2 of
-                                        // child zero, or vertex 3 of child 1
-                                        // or vertex 0 of child 2 or vertex 1
-                                        // of child 3. We're a bit cautious and
-                                        // check this (also an additional safety
-                                        // check for the internal states of the
-                                        // library)
-       Assert ((face->child(0)->vertex_dof_index(2,0) ==
-                face->child(1)->vertex_dof_index(3,0)) &&
-               (face->child(0)->vertex_dof_index(2,0) ==
-                face->child(2)->vertex_dof_index(0,0)) &&
-               (face->child(0)->vertex_dof_index(2,0) ==
-                face->child(3)->vertex_dof_index(1,0)),
-               ExcInternalError());
-       for (unsigned int dof=0; dof!=selected_fe->dofs_per_vertex; ++dof)
-         dofs_on_children.push_back (face->child(0)->vertex_dof_index(2,dof));
-       
-                                        // dof numbers on the centers of
-                                        // the lines bounding this face
-       for (unsigned int line=0; line<4; ++line)
-         for (unsigned int dof=0; dof!=selected_fe->dofs_per_vertex; ++dof)
-           dofs_on_children.push_back (face->line(line)->child(0)->vertex_dof_index(1,dof));
-
-                                        // next the dofs on the lines interior
-                                        // to the face; the order of these
-                                        // lines is laid down in the
-                                        // FiniteElement class documentation
-       for (unsigned int dof=0; dof<selected_fe->dofs_per_line; ++dof)
-         dofs_on_children.push_back (face->child(0)->line(1)->dof_index(dof));
-       for (unsigned int dof=0; dof<selected_fe->dofs_per_line; ++dof)
-         dofs_on_children.push_back (face->child(1)->line(2)->dof_index(dof));
-       for (unsigned int dof=0; dof<selected_fe->dofs_per_line; ++dof)
-         dofs_on_children.push_back (face->child(2)->line(3)->dof_index(dof));
-       for (unsigned int dof=0; dof<selected_fe->dofs_per_line; ++dof)
-         dofs_on_children.push_back (face->child(3)->line(0)->dof_index(dof));
-
-                                        // dofs on the bordering lines
-       for (unsigned int line=0; line<4; ++line)
-         for (unsigned int child=0; child<2; ++child)
-           for (unsigned int dof=0; dof!=selected_fe->dofs_per_line; ++dof)
-             dofs_on_children.push_back (face->line(line)->child(child)->dof_index(dof));
-       
-                                        // finally, for the dofs interior
-                                        // to the four child faces
-       for (unsigned int child=0; child<4; ++child)
-         for (unsigned int dof=0; dof!=selected_fe->dofs_per_quad; ++dof)
-           dofs_on_children.push_back (face->child(child)->dof_index(dof));
-
-       Assert (dofs_on_children.size() ==
-              selected_fe->constraints().m(),
-              ExcDimensionMismatch(dofs_on_children.size(),
-                                     selected_fe->constraints().m()));
-       Assert (dofs_on_mother.size() ==
-              selected_fe->constraints().n(),
-              ExcDimensionMismatch(dofs_on_mother.size(),
-                                     selected_fe->constraints().n()));
-
-                                        // for each row in the constraint
-                                        // matrix for this line:
-       for (unsigned int row=0; row!=dofs_on_children.size(); ++row) 
-         {
-           constraints.add_line (dofs_on_children[row]);
-           for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
-             constraints.add_entry (dofs_on_children[row],
-                                    dofs_on_mother[i],
-                                    selected_fe->constraints()(row,i));
-         };
-      };
-};
-
-#endif
-
 
 #if deal_II_dimension == 1
 
@@ -2125,71 +1865,6 @@ unsigned int DoFHandler<3>::max_couplings_between_boundary_dofs () const {
 
 
 
-template <int dim>
-template <typename Number>
-void DoFHandler<dim>::distribute_cell_to_dof_vector (const Vector<Number> &cell_data,
-                                                    Vector<double>       &dof_data,
-                                                    const unsigned int    component) const {
-  Assert (cell_data.size()==tria->n_active_cells(),
-         ExcWrongSize (cell_data.size(), tria->n_active_cells()));
-  Assert (dof_data.size()==n_dofs(), ExcWrongSize (dof_data.size(), n_dofs()));
-  Assert (component < selected_fe->n_components(),
-         ExcInvalidComponent(component, selected_fe->n_components()));
-
-                                  // store a flag whether we should care
-                                  // about different components. this is
-                                  // just a simplification, we could ask
-                                  // for this at every single place
-                                  // equally well
-  const bool consider_components = (selected_fe->n_components() != 1);
-  
-                                  // count how often we have added a value
-                                  // in the sum for each dof
-  vector<unsigned char> touch_count (n_dofs(), 0);
-
-  active_cell_iterator cell = begin_active(),
-                      endc = end();
-  unsigned int present_cell = 0;
-  const unsigned int dofs_per_cell = selected_fe->dofs_per_cell;
-  vector<int> dof_indices (dofs_per_cell);
-
-  for (; cell!=endc; ++cell, ++present_cell) 
-    {
-      cell->get_dof_indices (dof_indices);
-      for (unsigned int i=0; i<dofs_per_cell; ++i)
-                                        // consider this dof only if it
-                                        // is the right component. if there
-                                        // is only one component, short cut
-                                        // the test
-       if (!consider_components ||
-           (selected_fe->system_to_component_index(i).first == component))
-         {
-                                            // sum up contribution of the
-                                            // present_cell to this dof
-           dof_data(dof_indices[i]) += cell_data(present_cell);
-                                            // note that we added another
-                                            // summand
-           ++touch_count[dof_indices[i]];
-         };
-    };
-  
-                                  // compute the mean value on all the
-                                  // dofs by dividing with the number
-                                  // of summands.
-  for (unsigned int i=0; i<n_dofs(); ++i)
-    {
-                                      // assert that each dof was used
-                                      // at least once. this needs not be
-                                      // the case if the vector has more than
-                                      // one component
-      Assert (consider_components || (touch_count[i]!=0),
-             ExcInternalError());
-      if (touch_count[i] != 0)
-       dof_data(i) /=  touch_count[i];
-    };
-};
-
-
 
 #if deal_II_dimension == 1
 
@@ -2386,15 +2061,3 @@ void DoFHandler<dim>::clear_space () {
 /*-------------- Explicit Instantiations -------------------------------*/
 template class DoFHandler<deal_II_dimension>;
 
-template
-void
-DoFHandler<deal_II_dimension>::distribute_cell_to_dof_vector (const Vector<float>  &cell_data,
-                                                             Vector<double>       &dof_data) const;
-
-template
-void
-DoFHandler<deal_II_dimension>::distribute_cell_to_dof_vector (const Vector<double> &cell_data,
-                                                             Vector<double>       &dof_data) const;
-
-
-
index 97c537e6e70b1e99c595990626c335df30ad6b45..4e7ff00d3953b603e5ce068696b2c39488059b81 100644 (file)
@@ -29,7 +29,7 @@ void DoFRenumbering::Cuthill_McKee (DoFHandler<dim>   &dof_handler,
   if (use_constraints) 
     {
       ConstraintMatrix constraints;
-      dof_handler.make_hanging_node_constraints (constraints);
+      DoFTools::make_hanging_node_constraints (dof_handler, constraints);
       constraints.close ();
       constraints.condense (sparsity);
     };
index 13d44ab7538c61e83592e390bd600a5b8518d945..bf6eca37261698cd92d616419df08932c4d01713 100644 (file)
@@ -1,15 +1,18 @@
 // $Id$
-// Copyright Guido Kanschat, 1999
 
+
+#include <grid/tria.h>
+#include <grid/tria_iterator.h>
 #include <dofs/dof_handler.h>
 #include <dofs/mg_dof_handler.h>
 #include <dofs/dof_accessor.h>
 #include <dofs/mg_dof_accessor.h>
-#include <grid/tria_iterator.h>
+#include <dofs/dof_constraints.h>
 #include <fe/fe.h>
 #include <fe/fe_system.h>
 #include <dofs/dof_tools.h>
 #include <lac/sparse_matrix.h>
+#include <lac/vector.h>
 
 #include <algorithm>
 
@@ -257,6 +260,342 @@ DoFTools::make_flux_sparsity_pattern (const DoFHandler<dim>& dof,
 
 
 
+#if deal_II_dimension == 1
+
+template <>
+void DoFTools::make_hanging_node_constraints (const DoFHandler<1> &,
+                                             ConstraintMatrix &)
+{
+                                  // nothing to be done here
+};
+
+#endif
+
+
+
+#if deal_II_dimension == 2
+
+template <>
+void DoFTools::make_hanging_node_constraints (const DoFHandler<2> &dof_handler,
+                                             ConstraintMatrix    &constraints)
+{
+  const unsigned int dim = 2;
+  const Triangulation<dim> &tria = dof_handler.get_tria();
+  const FiniteElement<dim> &fe   = dof_handler.get_fe();
+  
+                                  // first mark all faces which are subject
+                                  // to constraints. We do so by looping
+                                  // over all active cells and checking
+                                  // whether any of the faces are refined
+                                  // which can only be from the neighboring
+                                  // cell because this one is active. In that
+                                  // case, the face is subject to constraints
+  DoFHandler<dim>::line_iterator line = dof_handler.begin_line(),
+                                endl = dof_handler.end_line();
+  for (; line!=endl; ++line)
+    line->clear_user_flag ();
+  
+  Triangulation<dim>::active_cell_iterator cell = tria.begin_active(),
+                                          endc = tria.end();
+  for (; cell!=endc; ++cell)
+    for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+      if (cell->face(face)->has_children()) 
+       cell->face(face)->set_user_flag();
+         
+  
+
+  
+                                  // loop over all lines; only on lines
+                                  // there can be constraints.
+  for (line = dof_handler.begin_line(); line != endl; ++line)
+                                    // if dofs on this line are subject
+                                    // to constraints
+    if (line->user_flag_set() == true)
+      {
+                                        // reserve space to gather
+                                        // the dof numbers. We could
+                                        // get them when we need them,
+                                        // but it seems easier to gather
+                                        // them only once.
+       vector<int> dofs_on_mother;
+       vector<int> dofs_on_children;
+       dofs_on_mother.reserve (2*fe.dofs_per_vertex+
+                               fe.dofs_per_line);
+       dofs_on_children.reserve (fe.dofs_per_vertex+
+                                 2*fe.dofs_per_line);
+
+       Assert(2*fe.dofs_per_vertex+fe.dofs_per_line ==
+              fe.constraints().n(),
+              ExcDimensionMismatch(2*fe.dofs_per_vertex+
+                                     fe.dofs_per_line,
+                                     fe.constraints().n()));
+       Assert(fe.dofs_per_vertex+2*fe.dofs_per_line ==
+              fe.constraints().m(),
+              ExcDimensionMismatch(3*fe.dofs_per_vertex+
+                                     2*fe.dofs_per_line,
+                                     fe.constraints().m()));
+       
+                                        // fill the dofs indices. Use same
+                                        // enumeration scheme as in
+                                        // #FiniteElement::constraints()#
+       for (unsigned int vertex=0; vertex<2; ++vertex)
+         for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+           dofs_on_mother.push_back (line->vertex_dof_index(vertex,dof));
+       for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+         dofs_on_mother.push_back (line->dof_index(dof));
+
+       for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+         dofs_on_children.push_back (line->child(0)->vertex_dof_index(1,dof));
+       for (unsigned int child=0; child<2; ++child)
+         for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+           dofs_on_children.push_back (line->child(child)->dof_index(dof));
+
+                                        // for each row in the constraint
+                                        // matrix for this line:
+       for (unsigned int row=0; row!=dofs_on_children.size(); ++row) 
+         {
+           constraints.add_line (dofs_on_children[row]);
+           for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
+             constraints.add_entry (dofs_on_children[row],
+                                    dofs_on_mother[i],
+                                    fe.constraints()(row,i));
+         };
+      };
+};
+
+#endif
+
+
+
+#if deal_II_dimension == 3
+
+template <>
+void DoFTools::make_hanging_node_constraints (const DoFHandler<3> &dof_handler,
+                                             ConstraintMatrix    &constraints)
+{
+  const unsigned int dim = 3;
+  const Triangulation<dim> &tria = dof_handler.get_tria();
+  const FiniteElement<dim> &fe   = dof_handler.get_fe();
+  
+                                  // first mark all faces which are subject
+                                  // to constraints. We do so by looping
+                                  // over all active cells and checking
+                                  // whether any of the faces are refined
+                                  // which can only be from the neighboring
+                                  // cell because this one is active. In that
+                                  // case, the face is subject to constraints
+  DoFHandler<dim>::face_iterator face = dof_handler.begin_face(),
+                                endf = dof_handler.end_face();
+  for (; face!=endf; ++face)
+    face->clear_user_flag ();
+
+  Triangulation<dim>::active_cell_iterator cell = tria.begin_active(),
+                                          endc = tria.end();
+  for (; cell!=endc; ++cell)
+    for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+      if (cell->face(face)->has_children()) 
+       cell->face(face)->set_user_flag();
+         
+  
+                                  // loop over all faces; only on faces
+                                  // there can be constraints.
+  for (face=dof_handler.begin_face(); face != endf; ++face)
+                                    // if dofs on this line are subject
+                                    // to constraints
+    if (face->user_flag_set() == true)
+      {
+                                        // reserve space to gather
+                                        // the dof numbers. We could
+                                        // get them when we need them,
+                                        // but it seems easier to gather
+                                        // them only once.
+       vector<int> dofs_on_mother;
+       vector<int> dofs_on_children;
+       dofs_on_mother.reserve (4*fe.dofs_per_vertex+
+                               4*fe.dofs_per_line+
+                               fe.dofs_per_quad);
+       dofs_on_children.reserve (5*fe.dofs_per_vertex+
+                                 12*fe.dofs_per_line+
+                                 4*fe.dofs_per_quad);
+
+       Assert(4*fe.dofs_per_vertex+
+              4*fe.dofs_per_line+
+              fe.dofs_per_quad
+              ==
+              fe.constraints().n(),
+              ExcDimensionMismatch(4*fe.dofs_per_vertex+
+                                     4*fe.dofs_per_line+
+                                     fe.dofs_per_quad,
+                                     fe.constraints().n()));
+       Assert(5*fe.dofs_per_vertex+
+              12*fe.dofs_per_line+
+              4*fe.dofs_per_quad
+              ==
+              fe.constraints().m(),
+              ExcDimensionMismatch(5*fe.dofs_per_vertex+
+                                     12*fe.dofs_per_line+
+                                     4*fe.dofs_per_quad,
+                                     fe.constraints().m()));
+       
+                                        // fill the dofs indices. Use same
+                                        // enumeration scheme as in
+                                        // #FiniteElement::constraints()#
+       for (unsigned int vertex=0; vertex<4; ++vertex)
+         for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+           dofs_on_mother.push_back (face->vertex_dof_index(vertex,dof));
+       for (unsigned int line=0; line<4; ++line)
+         for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+           dofs_on_mother.push_back (face->line(line)->dof_index(dof));
+       for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
+         dofs_on_mother.push_back (face->dof_index(dof));
+
+                                        // dof numbers on vertex at the center
+                                        // of the face, which is vertex 2 of
+                                        // child zero, or vertex 3 of child 1
+                                        // or vertex 0 of child 2 or vertex 1
+                                        // of child 3. We're a bit cautious and
+                                        // check this (also an additional safety
+                                        // check for the internal states of the
+                                        // library)
+       Assert ((face->child(0)->vertex_dof_index(2,0) ==
+                face->child(1)->vertex_dof_index(3,0)) &&
+               (face->child(0)->vertex_dof_index(2,0) ==
+                face->child(2)->vertex_dof_index(0,0)) &&
+               (face->child(0)->vertex_dof_index(2,0) ==
+                face->child(3)->vertex_dof_index(1,0)),
+               ExcInternalError());
+       for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+         dofs_on_children.push_back (face->child(0)->vertex_dof_index(2,dof));
+       
+                                        // dof numbers on the centers of
+                                        // the lines bounding this face
+       for (unsigned int line=0; line<4; ++line)
+         for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+           dofs_on_children.push_back (face->line(line)->child(0)->vertex_dof_index(1,dof));
+
+                                        // next the dofs on the lines interior
+                                        // to the face; the order of these
+                                        // lines is laid down in the
+                                        // FiniteElement class documentation
+       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+         dofs_on_children.push_back (face->child(0)->line(1)->dof_index(dof));
+       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+         dofs_on_children.push_back (face->child(1)->line(2)->dof_index(dof));
+       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+         dofs_on_children.push_back (face->child(2)->line(3)->dof_index(dof));
+       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+         dofs_on_children.push_back (face->child(3)->line(0)->dof_index(dof));
+
+                                        // dofs on the bordering lines
+       for (unsigned int line=0; line<4; ++line)
+         for (unsigned int child=0; child<2; ++child)
+           for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+             dofs_on_children.push_back (face->line(line)->child(child)->dof_index(dof));
+       
+                                        // finally, for the dofs interior
+                                        // to the four child faces
+       for (unsigned int child=0; child<4; ++child)
+         for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
+           dofs_on_children.push_back (face->child(child)->dof_index(dof));
+
+       Assert (dofs_on_children.size() ==
+              fe.constraints().m(),
+              ExcDimensionMismatch(dofs_on_children.size(),
+                                     fe.constraints().m()));
+       Assert (dofs_on_mother.size() ==
+              fe.constraints().n(),
+              ExcDimensionMismatch(dofs_on_mother.size(),
+                                     fe.constraints().n()));
+
+                                        // for each row in the constraint
+                                        // matrix for this line:
+       for (unsigned int row=0; row!=dofs_on_children.size(); ++row) 
+         {
+           constraints.add_line (dofs_on_children[row]);
+           for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
+             constraints.add_entry (dofs_on_children[row],
+                                    dofs_on_mother[i],
+                                    fe.constraints()(row,i));
+         };
+      };
+};
+
+#endif
+
+
+
+
+template <int dim, typename Number>
+void DoFTools::distribute_cell_to_dof_vector (const DoFHandler<dim> &dof_handler,
+                                             const Vector<Number>  &cell_data,
+                                             Vector<double>        &dof_data,
+                                             const unsigned int     component)
+{
+  const Triangulation<dim> &tria = dof_handler.get_tria();
+  const FiniteElement<dim> &fe   = dof_handler.get_fe();
+  
+  Assert (cell_data.size()==tria.n_active_cells(),
+         ExcWrongSize (cell_data.size(), tria.n_active_cells()));
+  Assert (dof_data.size()==dof_handler.n_dofs(),
+         ExcWrongSize (dof_data.size(), dof_handler.n_dofs()));
+  Assert (component < fe.n_components(),
+         ExcInvalidComponent(component, fe.n_components()));
+
+                                  // store a flag whether we should care
+                                  // about different components. this is
+                                  // just a simplification, we could ask
+                                  // for this at every single place
+                                  // equally well
+  const bool consider_components = (fe.n_components() != 1);
+  
+                                  // count how often we have added a value
+                                  // in the sum for each dof
+  vector<unsigned char> touch_count (dof_handler.n_dofs(), 0);
+
+  DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active(),
+                                       endc = dof_handler.end();
+  unsigned int present_cell = 0;
+  const unsigned int dofs_per_cell = fe.dofs_per_cell;
+  vector<int> dof_indices (dofs_per_cell);
+
+  for (; cell!=endc; ++cell, ++present_cell) 
+    {
+      cell->get_dof_indices (dof_indices);
+      for (unsigned int i=0; i<dofs_per_cell; ++i)
+                                        // consider this dof only if it
+                                        // is the right component. if there
+                                        // is only one component, short cut
+                                        // the test
+       if (!consider_components ||
+           (fe.system_to_component_index(i).first == component))
+         {
+                                            // sum up contribution of the
+                                            // present_cell to this dof
+           dof_data(dof_indices[i]) += cell_data(present_cell);
+                                            // note that we added another
+                                            // summand
+           ++touch_count[dof_indices[i]];
+         };
+    };
+  
+                                  // compute the mean value on all the
+                                  // dofs by dividing with the number
+                                  // of summands.
+  for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)
+    {
+                                      // assert that each dof was used
+                                      // at least once. this needs not be
+                                      // the case if the vector has more than
+                                      // one component
+      Assert (consider_components || (touch_count[i]!=0),
+             ExcInternalError());
+      if (touch_count[i] != 0)
+       dof_data(i) /=  touch_count[i];
+    };
+};
+
+
+
 template<int dim>
 void
 DoFTools::extract_dofs(const DoFHandler<dim> &dof,
@@ -348,6 +687,20 @@ DoFTools::make_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
                                 const vector<vector<bool> > &mask,
                                 SparseMatrixStruct          &sparsity);
 
+template
+void
+DoFTools::distribute_cell_to_dof_vector (const DoFHandler<deal_II_dimension> &dof_handler,
+                                        const Vector<float>  &cell_data,
+                                        Vector<double>       &dof_data) const;
+
+template
+void
+DoFTools::distribute_cell_to_dof_vector (const DoFHandler<deal_II_dimension> &dof_handler,
+                                        const Vector<double> &cell_data,
+                                        Vector<double>       &dof_data) const;
+
+
+
 template void DoFTools::extract_dofs(const DoFHandler<deal_II_dimension>& dof,
                                     const vector<bool>& local_select,
                                     vector<bool>& selected_dofs);
index 30c7516540226d441abbb8943acc8a8db28f2e77..67db86386ee5069801cc6942b40ccc6cb49af6fe 100644 (file)
@@ -88,7 +88,7 @@ void ProblemBase<dim>::assemble (const Equation<dim>      &equation,
                                   // make up sparsity pattern and
                                   // compress with constraints
   constraints.clear ();
-  dof_handler->make_hanging_node_constraints (constraints);
+  DoFTools::make_hanging_node_constraints (*dof_handler, constraints);
   constraints.close ();
   DoFTools::make_sparsity_pattern (*dof_handler, system_sparsity);
   constraints.condense (system_sparsity);
index b95a2e8dc679a07ee50efb0d03f35069602c5e82..40ec20423fc59ce3a0fa0079334ad8a862545207 100644 (file)
@@ -3,12 +3,13 @@
 
 
 #include <grid/tria.h>
-#include <dofs/dof_handler.h>
 #include <grid/tria_accessor.h>
-#include <dofs/dof_accessor.h>
 #include <grid/tria_iterator.h>
 #include <grid/tria_boundary_lib.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_accessor.h>
 #include <dofs/dof_constraints.h>
+#include <dofs/dof_tools.h>
 #include <grid/grid_generator.h>
 #include <base/function.h>
 #include <numerics/data_out.h>
@@ -387,13 +388,13 @@ int PoissonProblem<dim>::run (const unsigned int level) {
       Vector<double> linfty_error_per_dof(dof->n_dofs());
       Vector<double> h1_seminorm_error_per_dof(dof->n_dofs());
       Vector<double> h1_error_per_dof(dof->n_dofs());
-      dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof);
-      dof->distribute_cell_to_dof_vector (l2_error_per_cell, l2_error_per_dof);
-      dof->distribute_cell_to_dof_vector (linfty_error_per_cell,
-                                         linfty_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_seminorm_error_per_cell,
-                                         h1_seminorm_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, l1_error_per_cell, l1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, l2_error_per_cell, l2_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, linfty_error_per_cell,
+                                              linfty_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_seminorm_error_per_cell,
+                                              h1_seminorm_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_error_per_cell, h1_error_per_dof);
 
 //       Vector<double> projected_solution;
 //       ConstraintMatrix constraints;
index 594c1c084225e6b1a6066621303641dac5864760..5fe5ecf078b506e94582f9880dc1cf566b21b5ce 100644 (file)
@@ -376,7 +376,7 @@ void TestCases<dim>::run (ParameterHandler &prm) {
                                   // computing constraints
   cout << "    Computing constraints..." << endl;
   ConstraintMatrix constraints;
-  dof->make_hanging_node_constraints (constraints);
+  DoFTools::make_hanging_node_constraints (*dof, constraints);
   constraints.close ();
   constraints.condense (sparsity);
   
index 308df106035b089acd7f1f908f3ecf34965b32a5..9d6b65fdbe96956b2d1f5ccc561bbdabb516c368 100644 (file)
@@ -2,20 +2,21 @@
 /* Copyright W. Bangerth, University of Heidelberg, 1998 */
 
 
+#include <base/function.h>
+#include <base/parameter_handler.h>
+#include <base/quadrature_lib.h>
+#include <grid/grid_generator.h>
+#include <grid/grid_out.h>
 #include <grid/tria.h>
-#include <dofs/dof_handler.h>
 #include <grid/tria_accessor.h>
-#include <dofs/dof_accessor.h>
-#include <grid/tria_iterator.h>
 #include <grid/tria_boundary_lib.h>
+#include <grid/tria_iterator.h>
+#include <dofs/dof_accessor.h>
 #include <dofs/dof_constraints.h>
-#include <grid/grid_generator.h>
-#include <base/function.h>
-#include <numerics/data_out.h>
-#include <grid/grid_out.h>
-#include <base/parameter_handler.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_tools.h>
 #include <fe/fe_lib.lagrange.h>
-#include <base/quadrature_lib.h>
+#include <numerics/data_out.h>
 #include <numerics/base.h>
 #include <numerics/assembler.h>
 #include <numerics/vectors.h>
@@ -559,11 +560,11 @@ void PoissonProblem<dim>::run (ParameterHandler &prm) {
       Vector<double> l2_error_per_dof(dof->n_dofs()), linfty_error_per_dof(dof->n_dofs());
       Vector<double> h1_error_per_dof(dof->n_dofs()), estimated_error_per_dof(dof->n_dofs());
       Vector<double> error_ratio (dof->n_dofs());
-      dof->distribute_cell_to_dof_vector (l2_error_per_cell, l2_error_per_dof);
-      dof->distribute_cell_to_dof_vector (linfty_error_per_cell,
+      DoFTools::distribute_cell_to_dof_vector (*dof, l2_error_per_cell, l2_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, linfty_error_per_cell,
                                          linfty_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof);
-      dof->distribute_cell_to_dof_vector (estimated_error_per_cell,
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_error_per_cell, h1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, estimated_error_per_cell,
                                          estimated_error_per_dof);
       error_ratio.ratio (h1_error_per_dof, estimated_error_per_dof);
   
index 9e13e94fd27af7f732f4c643c21a8c0edbb60d2f..a862bdda17bc3abb27c3f80ee86ee594e2bd8d58 100644 (file)
@@ -353,7 +353,7 @@ void PoissonProblem<dim>::assemble (const Equation<dim>      &equation,
                                   // make up sparsity pattern and
                                   // compress with constraints
   constraints.clear ();
-  dof->DoFHandler<dim>::make_hanging_node_constraints (constraints);
+  DoFTools::make_hanging_node_constraints (*dof, constraints);
   constraints.close ();
   DoFTools::make_sparsity_pattern (*dof, system_sparsity);
   constraints.condense (system_sparsity);
@@ -557,13 +557,13 @@ int PoissonProblem<dim>::run (const unsigned int level) {
       Vector<double> linfty_error_per_dof (dof->DoFHandler<dim>::n_dofs());
       Vector<double> h1_seminorm_error_per_dof (dof->DoFHandler<dim>::n_dofs());
       Vector<double> h1_error_per_dof (dof->DoFHandler<dim>::n_dofs());
-      dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof);
-      dof->distribute_cell_to_dof_vector (l2_error_per_cell, l2_error_per_dof);
-      dof->distribute_cell_to_dof_vector (linfty_error_per_cell,
+      DoFTools::distribute_cell_to_dof_vector (*dof, l1_error_per_cell, l1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, l2_error_per_cell, l2_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, linfty_error_per_cell,
                                          linfty_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_seminorm_error_per_cell,
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_seminorm_error_per_cell,
                                          h1_seminorm_error_per_dof);
-      dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof);
+      DoFTools::distribute_cell_to_dof_vector (*dof, h1_error_per_cell, h1_error_per_dof);
 
 //       Vector<double> projected_solution;
 //       ConstraintMatrix constraints;
index a28e9fa1cbbdcd12681e63999a443e8350fb1ded..5b38fb1744c445ead93a6191a0e3f3f32ecd9b69 100644 (file)
@@ -44,6 +44,15 @@ libdeal1d = -ldeal_II_1d
 flags     = $(CXXFLAGS.o) $(CXXFLAGS)
 endif
 
+
+%.go : %.cc Makefile
+       @echo =====debug========= $<
+       @$(CXX) $(flags) -c $< -o $@
+%.o : %.cc Makefile
+       @echo =====optimized===== $<
+       @$(CXX) $(flags) -c $< -o $@
+
+
 all: grid_test.check dof_test.check fe_tables.check gradients.check \
      constraints.check mg.check mglocal.check wave-test-3.check second_derivatives.check
 
index 76c56ed1d913ba5ee1dc4c67585aca94d8d46119..fcf5b1d58a50fd0f8b7d3d9676def16cb7aab1ec 100644 (file)
@@ -313,7 +313,7 @@ void TestCases<dim>::run (const unsigned int test_case)
                                   // computing constraints
   deallog << "    Computing constraints..." << endl;
   ConstraintMatrix constraints;
-  dof->make_hanging_node_constraints (constraints);
+  DoFTools::make_hanging_node_constraints (*dof, constraints);
   constraints.close ();
   constraints.condense (sparsity);
   
index bb0d86d318887570d63073ec9468da43bac0478d..a3b4da97776d5b3792f67f15cc857877ee0895b1 100644 (file)
@@ -5338,7 +5338,7 @@ void TimeStep_Wave<dim>::wake_up (const unsigned int wakeup_level)
       
 
       constraints.clear ();
-      dof_handler->make_hanging_node_constraints (constraints);
+      DoFTools::make_hanging_node_constraints (*dof_handler, constraints);
       constraints.close ();
 
       sweep_info->get_timers().grid_generation.stop();
@@ -7944,9 +7944,9 @@ void TimeStep_Postprocess<dim>::postprocess_timestep ()
          else
            {
              estimated_error.reinit (get_timestep_primal().dof_handler->n_dofs());
-             get_timestep_primal().dof_handler
-               ->distribute_cell_to_dof_vector (estimated_error_per_cell,
-                                                estimated_error);
+             DoFTools::distribute_cell_to_dof_vector (*get_timestep_primal().dof_handler,
+                                                      estimated_error_per_cell,
+                                                      estimated_error);
            };
       
          out.add_data_vector (estimated_error, "est_error");

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.