// unless the neighbor is active and coarser. It can end up on a
// different processor. Luckily, the level_subdomain_id can be
// figured out without communication, because the cell is active
- // (and so level_subdomain_id=subdomain_id):
+ // (and so level_subdomain_id=subdomain_id). Finally, also consider
+ // the opposite case: if we are the coarser neighbor for another
+ // processor, also mark them.
for (typename Triangulation<dim,spacedim>::cell_iterator cell = this->begin(); cell!=this->end(); ++cell)
{
- if (cell->level_subdomain_id()!=this->locally_owned_subdomain())
+ if (cell->level_subdomain_id() == numbers::artificial_subdomain_id)
continue;
+ bool cell_level_mine = cell->level_subdomain_id() == this->locally_owned_subdomain();
+
for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
{
- if (cell->face(f)->at_boundary())
+ if (cell->face(f)->at_boundary() || cell->neighbor(f)->level() >= cell->level())
continue;
- if (cell->neighbor(f)->level() < cell->level()
- &&
- cell->neighbor(f)->level_subdomain_id()!=this->locally_owned_subdomain())
+
+ bool neighbor_level_mine = cell->neighbor(f)->level_subdomain_id() == this->locally_owned_subdomain();
+
+ if (cell_level_mine && !neighbor_level_mine)
{
+ // set the neighbor level_id up
Assert(cell->neighbor(f)->active(), ExcInternalError());
Assert(cell->neighbor(f)->subdomain_id() != numbers::artificial_subdomain_id, ExcInternalError());
Assert(cell->neighbor(f)->level_subdomain_id() == numbers::artificial_subdomain_id
|| cell->neighbor(f)->level_subdomain_id() == cell->neighbor(f)->subdomain_id(), ExcInternalError());
cell->neighbor(f)->set_level_subdomain_id(cell->neighbor(f)->subdomain_id());
}
+ else if (!cell_level_mine && neighbor_level_mine)
+ {
+ // set the current cell up because it is a neighbor for us
+ Assert(cell->active(), ExcInternalError());
+ Assert(cell->subdomain_id() != numbers::artificial_subdomain_id, ExcInternalError());
+ Assert(cell->level_subdomain_id() == numbers::artificial_subdomain_id
+ || cell->level_subdomain_id() == cell->subdomain_id(), ExcInternalError());
+ cell->set_level_subdomain_id(cell->subdomain_id());
+ }
}
}
}
+ // Finally, if we are neighboring a coarser cell, add them to
+ // the destination list
+ if (dealii_cell->active())
+ {
+ for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+ {
+ if (dealii_cell->at_boundary(f))
+ continue;
+ typename DoFHandler<dim,spacedim>::level_cell_iterator neighbor = dealii_cell->neighbor(f);
+ if (neighbor->level()>=level)
+ continue;
+
+ dealii::types::subdomain_id dest = neighbor->level_subdomain_id();
+ Assert(dest != dealii::numbers::artificial_subdomain_id, ExcInternalError());
+ if (dest != tria.locally_owned_subdomain())
+ send_to.insert(dest);
+
+ }
+ }
+
// send if we have something to send
if (send_to.size() > 0)
cellmap_t;
cellmap_t needs_to_get_cells;
- if (level < tr->n_levels())
- for (typename DoFHandler<dim,spacedim>::level_cell_iterator
- cell = dof_handler.begin(0);
- cell != dof_handler.end(0);
- ++cell)
- {
- typename dealii::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
- internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
-
- fill_mg_dofindices_recursively<dim,spacedim>
- (*tr,
- coarse_cell_to_p4est_tree_permutation[cell->index()],
- cell,
- p4est_coarse_cell,
- vertices_with_ghost_neighbors,
- needs_to_get_cells,
- level);
- }
+ for (typename DoFHandler<dim,spacedim>::level_cell_iterator
+ cell = dof_handler.begin(0);
+ cell != dof_handler.end(0);
+ ++cell)
+ {
+ typename dealii::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
+ internal::p4est::init_coarse_quadrant<dim>(p4est_coarse_cell);
+
+ fill_mg_dofindices_recursively<dim,spacedim>
+ (*tr,
+ coarse_cell_to_p4est_tree_permutation[cell->index()],
+ cell,
+ p4est_coarse_cell,
+ vertices_with_ghost_neighbors,
+ needs_to_get_cells,
+ level);
+ }
//sending
}
- // mark all own cells, that miss some
- // dof_data and collect the neighbors
- // that are going to send stuff to us
+ // mark all own cells, that miss some dof_data and collect the
+ // neighbors that are going to send stuff to us
std::set<dealii::types::subdomain_id> senders;
- if (level < tr->n_levels())
- {
- std::vector<dealii::types::global_dof_index> local_dof_indices;
- typename DoFHandler<dim,spacedim>::level_cell_iterator
- cell, endc = dof_handler.end(level);
+ {
+ std::vector<dealii::types::global_dof_index> local_dof_indices;
+ typename DoFHandler<dim,spacedim>::level_cell_iterator
+ cell, endc = dof_handler.end(level);
- for (cell = dof_handler.begin(level); cell != endc; ++cell)
- {
- if (cell->level_subdomain_id()==dealii::numbers::artificial_subdomain_id)
- {
- //artificial
- }
- else if (cell->level_subdomain_id()==dof_handler.get_triangulation().locally_owned_subdomain())
- {
- //own
- local_dof_indices.resize (cell->get_fe().dofs_per_cell);
- cell->get_mg_dof_indices (local_dof_indices);
- if (local_dof_indices.end() !=
- std::find (local_dof_indices.begin(),
- local_dof_indices.end(),
- DoFHandler<dim,spacedim>::invalid_dof_index))
- cell->set_user_flag();
- else
- cell->clear_user_flag();
- }
- else
- {
- //ghost
- if (cell->user_flag_set())
- senders.insert(cell->level_subdomain_id());
- }
- }
+ for (cell = dof_handler.begin(level); cell != endc; ++cell)
+ {
+ if (cell->level_subdomain_id()==dealii::numbers::artificial_subdomain_id)
+ {
+ //artificial
+ }
+ else if (cell->level_subdomain_id()==dof_handler.get_triangulation().locally_owned_subdomain())
+ {
+ //own
+ local_dof_indices.resize (cell->get_fe().dofs_per_cell);
+ cell->get_mg_dof_indices (local_dof_indices);
+ if (local_dof_indices.end() !=
+ std::find (local_dof_indices.begin(),
+ local_dof_indices.end(),
+ DoFHandler<dim,spacedim>::invalid_dof_index))
+ cell->set_user_flag();
+ else
+ cell->clear_user_flag();
+ }
+ else
+ {
+ //ghost
+ if (cell->user_flag_set())
+ senders.insert(cell->level_subdomain_id());
+ }
+ }
- }
+ }
//* 5. receive ghostcelldata
DEAL:1::cell=0_2:32 level_subdomain_id=1
DEAL:1::cell=0_2:33 level_subdomain_id=1
DEAL:1::cell=0_3:010 level_subdomain_id=4294967294
-DEAL:1::cell=0_3:011 level_subdomain_id=4294967294
+DEAL:1::cell=0_3:011 level_subdomain_id=0
DEAL:1::cell=0_3:012 level_subdomain_id=4294967294
DEAL:1::cell=0_3:013 level_subdomain_id=0
DEAL:1::cell=0_3:030 level_subdomain_id=0
DEAL:1::cell=0_3:212 level_subdomain_id=1
DEAL:1::cell=0_3:213 level_subdomain_id=1
DEAL:1::cell=0_4:0320 level_subdomain_id=4294967294
-DEAL:1::cell=0_4:0321 level_subdomain_id=4294967294
-DEAL:1::cell=0_4:0322 level_subdomain_id=4294967294
-DEAL:1::cell=0_4:0323 level_subdomain_id=4294967294
+DEAL:1::cell=0_4:0321 level_subdomain_id=0
+DEAL:1::cell=0_4:0322 level_subdomain_id=0
+DEAL:1::cell=0_4:0323 level_subdomain_id=0
DEAL:1::ok