<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.
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
if (pdt == 0)
return true;
else
- return (subdomain == pdt->locally_owned_subdomain());
+ return (this->subdomain_id() == pdt->locally_owned_subdomain());
#endif
}
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
if (pdt == 0)
return false;
else
- return (subdomain != pdt->locally_owned_subdomain());
+ return (this->subdomain_id() != pdt->locally_owned_subdomain());
#endif
}
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
}
{
// 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
{
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;
}
== 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
--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;
+ }
+ }
}
}
new_lines[5]->index()));
}
+ types::subdomain_id subdomainid = cell->subdomain_id();
for (unsigned int i=0; i<n_children; ++i)
{
// 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 ());
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 ();
::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 ());
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)
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.
// 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 ());
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];
}
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;
}
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);
}