]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
subdomainids should only work for active cells, enforce this. Also forbid is_artifici...
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 31 May 2013 23:00:36 +0000 (23:00 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 31 May 2013 23:00:36 +0000 (23:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@29702 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/grid/tria_accessor.templates.h
deal.II/source/distributed/tria.cc
deal.II/source/grid/tria.cc
deal.II/source/grid/tria_accessor.cc

index e54d6a4e598e6202d491473e4b164c36c3096a93..481f12e462912d4c1344d3066cb12a6bcf86b40c 100644 (file)
@@ -131,6 +131,13 @@ this function.
 
 <ol>
 
+<li> Changed: subdomainids can now only be queried/set on active cells.
+Consequently, is_artificial(), is_ghost(), and is_locally_owned() is
+now restricted to active cells.
+<br>
+(Timo Heister, 2013/05/31)
+</li>
+
 <li> Improved: Triangulation::begin(level) and Triangulation::end(level) now return an
 empty iterator range if the level is larger than the maximal locally owned level,
 but still in the global level range of a distributed Triangulation.
index 00b9d1215c1fa61ae552765592886751db66988d..2e4d9462ea66f4e7122762f03d418813819ab7ed 100644 (file)
@@ -2891,11 +2891,11 @@ inline
 bool
 CellAccessor<dim,spacedim>::is_locally_owned () const
 {
+  Assert (this->active(), ExcMessage("is_locally_owned() only works on active cells!"));
 #ifndef DEAL_II_WITH_P4EST
   return true;
 #else
-  const types::subdomain_id subdomain = this->subdomain_id();
-  if (subdomain == numbers::artificial_subdomain_id)
+  if (is_artificial())
     return false;
 
   const parallel::distributed::Triangulation<dim,spacedim> *pdt
@@ -2904,7 +2904,7 @@ CellAccessor<dim,spacedim>::is_locally_owned () const
   if (pdt == 0)
     return true;
   else
-    return (subdomain == pdt->locally_owned_subdomain());
+    return (this->subdomain_id() == pdt->locally_owned_subdomain());
 #endif
 }
 
@@ -2914,11 +2914,11 @@ inline
 bool
 CellAccessor<dim,spacedim>::is_ghost () const
 {
+  Assert (this->active(), ExcMessage("is_ghost() only works on active cells!"));
 #ifndef DEAL_II_WITH_P4EST
   return false;
 #else
-  const types::subdomain_id subdomain = this->subdomain_id();
-  if (subdomain == numbers::artificial_subdomain_id)
+  if (is_artificial() || this->has_children())
     return false;
 
   const parallel::distributed::Triangulation<dim,spacedim> *pdt
@@ -2927,7 +2927,7 @@ CellAccessor<dim,spacedim>::is_ghost () const
   if (pdt == 0)
     return false;
   else
-    return (subdomain != pdt->locally_owned_subdomain());
+    return (this->subdomain_id() != pdt->locally_owned_subdomain());
 #endif
 }
 
@@ -2938,10 +2938,11 @@ inline
 bool
 CellAccessor<dim,spacedim>::is_artificial () const
 {
+  Assert (this->active(), ExcMessage("is_artificial() only works on active cells!"));
 #ifndef DEAL_II_WITH_P4EST
   return false;
 #else
-  return (this->subdomain_id() == numbers::artificial_subdomain_id);
+  return this->subdomain_id() == numbers::artificial_subdomain_id;
 #endif
 }
 
index a00309e00e0e12412c599be538cef5ff1a8d87d4..95637b32c4a3b78c9a9e6d13fe458494e4c05817 100644 (file)
@@ -1077,7 +1077,8 @@ namespace
       {
         // yes, cell found in local part of p4est
         delete_all_children<dim,spacedim> (dealii_cell);
-        dealii_cell->set_subdomain_id(my_subdomain);
+        if (!dealii_cell->has_children())
+          dealii_cell->set_subdomain_id(my_subdomain);
       }
     else
       {
@@ -1171,12 +1172,14 @@ namespace
     if (internal::p4est::functions<dim>::quadrant_is_equal(&this_quadrant, &ghost_quadrant))
       {
         // this is the ghostcell
-        dealii_cell->set_subdomain_id(ghost_owner);
 
         if (dealii_cell->has_children())
           delete_all_children<dim,spacedim> (dealii_cell);
         else
-          dealii_cell->clear_coarsen_flag();
+          {
+            dealii_cell->clear_coarsen_flag();
+            dealii_cell->set_subdomain_id(ghost_owner);
+          }
         return;
       }
 
@@ -2591,7 +2594,8 @@ namespace parallel
                   == false)
                 {
                   delete_all_children<dim,spacedim> (cell);
-                  cell->set_subdomain_id (numbers::artificial_subdomain_id);
+                  if (!cell->has_children())
+                    cell->set_subdomain_id (numbers::artificial_subdomain_id);
                 }
 
               else
@@ -2771,21 +2775,19 @@ namespace parallel
               --lvl;
               for (typename Triangulation<dim,spacedim>::cell_iterator cell = this->begin(lvl); cell!=this->end(lvl); ++cell)
                 {
-                  if (cell->has_children() && cell->subdomain_id()!=this->locally_owned_subdomain())
-                    {
-                      //not our cell
-                      for (unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
-                        {
-                          if (cell->child(c)->level_subdomain_id()==this->locally_owned_subdomain())
-                            {
-                              types::subdomain_id mark = numbers::artificial_subdomain_id;
-                              mark = cell->child(0)->level_subdomain_id();
-                              Assert(mark != numbers::artificial_subdomain_id, ExcInternalError()); //we should know the child(0)
-                              cell->set_level_subdomain_id(mark);
-                              break;
-                            }
-                        }
-                    }
+                  if (cell->has_children())
+                    for (unsigned int c=0; c<GeometryInfo<dim>::max_children_per_cell; ++c)
+                      {
+                        if (cell->child(c)->level_subdomain_id()==this->locally_owned_subdomain())
+                          {
+                            //at least one of the children belongs to us, so make sure we set the level subdomain id
+                            types::subdomain_id mark = numbers::artificial_subdomain_id;
+                            mark = cell->child(0)->level_subdomain_id();
+                            Assert(mark != numbers::artificial_subdomain_id, ExcInternalError()); //we should know the child(0)
+                            cell->set_level_subdomain_id(mark);
+                            break;
+                          }
+                      }
                 }
             }
 
index 6f7d4af79bea267be9c2cee75a49c351b0f5f8f0..dbba1eb018524cff8f59b756ef0a6e406a25e77c 100644 (file)
@@ -4230,6 +4230,7 @@ namespace internal
                                             new_lines[5]->index()));
           }
 
+        types::subdomain_id subdomainid = cell->subdomain_id();
 
         for (unsigned int i=0; i<n_children; ++i)
           {
@@ -4241,7 +4242,7 @@ namespace internal
             // inherit material
             // properties
             subcells[i]->set_material_id (cell->material_id());
-            subcells[i]->set_subdomain_id (cell->subdomain_id());
+            subcells[i]->set_subdomain_id (subdomainid);
 
             if (i%2==0)
               subcells[i]->set_parent (cell->index ());
@@ -4437,6 +4438,8 @@ namespace internal
                   second_child->set_used_flag ();
                   second_child->clear_user_data ();
 
+                  types::subdomain_id subdomainid = cell->subdomain_id();
+
                   // insert first child
                   cell->set_children (0, first_child->index());
                   first_child->clear_children ();
@@ -4444,7 +4447,7 @@ namespace internal
                                     ::TriaObject<1> (cell->vertex_index(0),
                                                      next_unused_vertex));
                   first_child->set_material_id (cell->material_id());
-                  first_child->set_subdomain_id (cell->subdomain_id());
+                  first_child->set_subdomain_id (subdomainid);
                   first_child->set_direction_flag (cell->direction_flag());
 
                   first_child->set_parent (cell->index ());
@@ -4504,7 +4507,7 @@ namespace internal
                                                      cell->vertex_index(1)));
                   second_child->set_neighbor (0, first_child);
                   second_child->set_material_id (cell->material_id());
-                  second_child->set_subdomain_id (cell->subdomain_id());
+                  second_child->set_subdomain_id (subdomainid);
                   second_child->set_direction_flag (cell->direction_flag());
 
                   if (cell->neighbor(1).state() != IteratorState::valid)
@@ -6417,6 +6420,8 @@ namespace internal
                         new_quads[i]->set_line_orientation(j,true);
                     }
 
+                  types::subdomain_id subdomainid = hex->subdomain_id();
+
                   // find some space for the newly to
                   // be created hexes and initialize
                   // them.
@@ -6440,7 +6445,7 @@ namespace internal
                       // inherit material
                       // properties
                       new_hexes[i]->set_material_id (hex->material_id());
-                      new_hexes[i]->set_subdomain_id (hex->subdomain_id());
+                      new_hexes[i]->set_subdomain_id (subdomainid);
 
                       if (i%2)
                         new_hexes[i]->set_parent (hex->index ());
index 0661e0369605779a4351f5700f60d04dd7bac827..9bd2a453f4a0a3d4bb65022865bbb2691390ba16 100644 (file)
@@ -1332,6 +1332,7 @@ template <int dim, int spacedim>
 types::subdomain_id CellAccessor<dim, spacedim>::subdomain_id () const
 {
   Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
+  Assert (this->active(), ExcMessage("subdomains only work on active cells!"));
   return this->tria->levels[this->present_level]->subdomain_ids[this->present_index];
 }
 
@@ -1342,6 +1343,7 @@ void
 CellAccessor<dim, spacedim>::set_subdomain_id (const types::subdomain_id new_subdomain_id) const
 {
   Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
+  Assert (this->active(), ExcMessage("subdomains only work on active cells!"));
   this->tria->levels[this->present_level]->subdomain_ids[this->present_index]
     = new_subdomain_id;
 }
@@ -1412,11 +1414,11 @@ void
 CellAccessor<dim, spacedim>::
 recursively_set_subdomain_id (const types::subdomain_id new_subdomain_id) const
 {
-  set_subdomain_id (new_subdomain_id);
-
   if (this->has_children())
     for (unsigned int c=0; c<this->n_children(); ++c)
       this->child(c)->recursively_set_subdomain_id (new_subdomain_id);
+  else
+    set_subdomain_id (new_subdomain_id);
 }
 
 

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.