]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Work around a lose end left over from when we wrote the MG code initially back in...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 1 Mar 2005 18:04:59 +0000 (18:04 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 1 Mar 2005 18:04:59 +0000 (18:04 +0000)
git-svn-id: https://svn.dealii.org/trunk@9932 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_dof_handler.h
deal.II/deal.II/source/multigrid/mg_dof_handler.cc

index 39d1f090643cb1016ae6e48386390788d5637c0a..0904913095d1f496006e8265f7f7eecf24e4ad8e 100644 (file)
@@ -949,7 +949,8 @@ class MGDoFHandler : public DoFHandler<dim>
                                      * needed and need not handle
                                      * growing arrays and the like.
                                      */
-    class MGVertexDoFs {
+    class MGVertexDoFs
+    {
       public:
        
                                         /**
@@ -968,6 +969,14 @@ class MGDoFHandler : public DoFHandler<dim>
                                         /**
                                          * Allocate memory and set
                                          * all indices to @p -1.
+                                         *
+                                         * If @p coarsest_level is
+                                         * greater than @p
+                                         * finest_level, then no
+                                         * memory is allocated and
+                                         * the object is left in an
+                                         * invalid state. This is
+                                         * used for unused vertices.
                                          */
        void init (const unsigned int coarsest_level,
                   const unsigned int finest_level,
@@ -978,6 +987,14 @@ class MGDoFHandler : public DoFHandler<dim>
                                          */
        ~MGVertexDoFs ();
 
+                                        /**
+                                         * Assignment operator. Will
+                                         * throw an exception since
+                                         * it can't do the work that
+                                         * @p init is supposed to do.
+                                         */
+       MGVertexDoFs & operator = (const MGVertexDoFs &vertex);
+       
                                         /**
                                          * Set the index with number
                                          * @p dof_number of this
index 1b7576ad76bb703a64997aa078038a9e729b9877..0ef87681728f79de0458e7c959ffae623a6310ad 100644 (file)
@@ -32,8 +32,9 @@
 /* ------------------------ MGVertexDoFs ----------------------------------- */
 
 template <int dim>
-MGDoFHandler<dim>::MGVertexDoFs::MGVertexDoFs () :
-               coarsest_level (1<<30),
+MGDoFHandler<dim>::MGVertexDoFs::MGVertexDoFs ()
+               :
+               coarsest_level (deal_II_numbers::invalid_unsigned_int),
                finest_level (0),
                indices (0)
 {}
@@ -42,12 +43,23 @@ MGDoFHandler<dim>::MGVertexDoFs::MGVertexDoFs () :
 template <int dim>
 void MGDoFHandler<dim>::MGVertexDoFs::init (const unsigned int cl,
                                            const unsigned int fl,
-                                           const unsigned int dofs_per_vertex) {
-  Assert (indices == 0, ExcInternalError());
+                                           const unsigned int dofs_per_vertex)
+{
+  if (indices != 0)
+    {
+      delete[] indices;
+      indices = 0;
+    }
 
   coarsest_level = cl;
   finest_level   = fl;
 
+                                  // in the case where an invalid
+                                  // entry is requested, just leave
+                                  // everything else alone
+  if (cl > fl)
+    return;
+  
   const unsigned int n_levels = finest_level-coarsest_level + 1;
   
   indices = new unsigned int[n_levels * dofs_per_vertex];
@@ -64,6 +76,18 @@ MGDoFHandler<dim>::MGVertexDoFs::~MGVertexDoFs () {
 }
 
 
+template <int dim>
+typename MGDoFHandler<dim>::MGVertexDoFs &
+MGDoFHandler<dim>::MGVertexDoFs::operator = (const MGVertexDoFs &)
+{
+  Assert (false,
+         ExcMessage ("We don't know how many dofs per vertex there are, so there's "
+                     "no way we can copy the 'indices' array"));
+  return *this;
+}
+
+
+
 template <int dim>
 inline
 unsigned int MGDoFHandler<dim>::MGVertexDoFs::get_coarsest_level () const {
@@ -1640,6 +1664,8 @@ void MGDoFHandler<2>::reserve_space () {
                                   // vertex we pass by  belongs to
   mg_vertex_dofs.resize (this->tria->vertices.size());
 
+                                  // initialize these arrays with
+                                  // invalid values (min>max)
   std::vector<unsigned int> min_level (this->tria->vertices.size(),
                                       this->tria->n_levels());
   std::vector<unsigned int> max_level (this->tria->vertices.size(), 0);
@@ -1655,20 +1681,28 @@ void MGDoFHandler<2>::reserve_space () {
          min_level[vertex_index] = cell->level();
        if (max_level[vertex_index] < static_cast<unsigned int>(cell->level()))
          max_level[vertex_index] = cell->level();
-      };
+      }
 
 
                                    // now allocate the needed space
   for (unsigned int vertex=0; vertex<this->tria->vertices.size(); ++vertex)
-    {
-//TODO:[WB,GK] These conditions are violated on unused vertices
-      Assert (min_level[vertex] < this->tria->n_levels(),   ExcInternalError());
-      Assert (max_level[vertex] >= min_level[vertex], ExcInternalError());
+    if (this->tria->vertices_used[vertex])
+      {
+       Assert (min_level[vertex] < this->tria->n_levels(),   ExcInternalError());
+       Assert (max_level[vertex] >= min_level[vertex], ExcInternalError());
+
+       mg_vertex_dofs[vertex].init (min_level[vertex],
+                                    max_level[vertex],
+                                    this->selected_fe->dofs_per_vertex);
+      }
+    else
+      {
+       Assert (min_level[vertex] == this->tria->n_levels(),   ExcInternalError());
+       Assert (max_level[vertex] == 0, ExcInternalError());
 
-      mg_vertex_dofs[vertex].init (min_level[vertex],
-                                  max_level[vertex],
-                                  this->selected_fe->dofs_per_vertex);
-    };
+                                        // reset to original state
+       mg_vertex_dofs[vertex].init (1, 0, 0);
+      }
 }
 
 #endif

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.