namespace p4est
{
/**
- * A structure whose explicit
- * specializations contain
- * pointers to the relevant
- * p4est_* and p8est_*
- * functions. Using this
- * structure, for example by
- * saying
- * functions<dim>::quadrant_compare,
- * we can write code in a
- * dimension independent way,
- * either calling
- * p4est_quadrant_compare or
- * p8est_quadrant_compare,
- * depending on template
- * argument.
+ * A structure whose explicit specializations contain pointers to the
+ * relevant p4est_* and p8est_* functions. Using this structure, for
+ * example by saying functions<dim>::quadrant_compare, we can write code
+ * in a dimension independent way, either calling p4est_quadrant_compare
+ * or p8est_quadrant_compare, depending on template argument.
*/
template <int dim> struct functions;
/**
- * Set all vertex and cell
- * related information in the
- * p4est connectivity structure.
+ * Set all vertex and cell related information in the p4est connectivity
+ * structure.
*/
template <int dim, int spacedim>
void
const bool set_vertex_info,
typename internal::p4est::types<dim>::connectivity *connectivity)
{
- // copy the vertices into the
- // connectivity structure. the
- // triangulation exports the array of
- // vertices, but some of the entries are
- // sometimes unused; this shouldn't be
- // the case for a newly created
- // triangulation, but make sure
+ // copy the vertices into the connectivity structure. the triangulation
+ // exports the array of vertices, but some of the entries are sometimes
+ // unused; this shouldn't be the case for a newly created triangulation,
+ // but make sure
//
- // note that p4est stores coordinates as
- // a triplet of values even in 2d
+ // note that p4est stores coordinates as a triplet of values even in 2d
Assert (triangulation.get_used_vertices().size() ==
triangulation.get_vertices().size(),
ExcInternalError());
triangulation.get_vertices()[v][2]);
}
- // next store the tree_to_vertex indices
- // (each tree is here only a single cell
- // in the coarse mesh). p4est requires
- // vertex numbering in clockwise
+ // next store the tree_to_vertex indices (each tree is here only a single
+ // cell in the coarse mesh). p4est requires vertex numbering in clockwise
// orientation
//
- // while we're at it, also copy the
- // neighborship information between cells
+ // while we're at it, also copy the neighborship information between cells
typename Triangulation<dim>::active_cell_iterator
cell = triangulation.begin_active(),
endc = triangulation.end();
connectivity->tree_to_corner[index*GeometryInfo<dim>::vertices_per_cell+v] = cell->vertex_index(v);
}
- // neighborship information. if a
- // cell is at a boundary, then enter
+ // neighborship information. if a cell is at a boundary, then enter
// the index of the cell itself here
for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
if (cell->face(f)->at_boundary() == false)
connectivity->tree_to_tree[index*GeometryInfo<dim>::faces_per_cell + f]
= coarse_cell_to_p4est_tree_permutation[cell->index()];
- // fill tree_to_face, which is
- // essentially neighbor_to_neighbor;
- // however, we have to remap the
- // resulting face number as well
+ // fill tree_to_face, which is essentially neighbor_to_neighbor;
+ // however, we have to remap the resulting face number as well
for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
if (cell->face(f)->at_boundary() == false)
{
case 3:
{
/*
- * The values for
- * tree_to_face are in
- * 0..23 where ttf % 6
- * gives the face
- * number and ttf / 6
- * the face orientation
- * code. The
- * orientation is
- * determined as
- * follows. Let
- * my_face and
- * other_face be the
- * two face numbers of
- * the connecting trees
- * in 0..5. Then the
- * first face vertex of
- * the lower of my_face
- * and other_face
- * connects to a face
- * vertex numbered 0..3
- * in the higher of
- * my_face and
- * other_face. The
- * face orientation is
- * defined as this
- * number. If my_face
- * == other_face,
- * treating either of
- * both faces as the
- * lower one leads to
- * the same result.
+ * The values for tree_to_face are in 0..23 where ttf % 6
+ * gives the face number and ttf / 6 the face orientation
+ * code. The orientation is determined as follows. Let
+ * my_face and other_face be the two face numbers of the
+ * connecting trees in 0..5. Then the first face vertex of
+ * the lower of my_face and other_face connects to a face
+ * vertex numbered 0..3 in the higher of my_face and
+ * other_face. The face orientation is defined as this
+ * number. If my_face == other_face, treating either of
+ * both faces as the lower one leads to the same result.
*/
connectivity->tree_to_face[index*6 + f]
unsigned int v = 0;
- // global vertex index of
- // vertex 0 on face of
- // cell with smaller
- // local face index
+ // global vertex index of vertex 0 on face of cell with
+ // smaller local face index
unsigned int g_idx =
cell_list[smaller_idx]->vertex_index(
GeometryInfo<dim>::face_to_cell_vertices(
cell_list[smaller_idx]->face_rotation(face_idx_list[smaller_idx]))
);
- // loop over vertices on
- // face from other cell
- // and compare global
- // vertex numbers
+ // loop over vertices on face from other cell and compare
+ // global vertex numbers
for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_face; ++i)
{
unsigned int idx
const typename internal::p4est::types<dim>::forest &forest,
const types::subdomain_id my_subdomain)
{
- // check if this cell exists in
- // the local p4est cell
+ // check if this cell exists in the local p4est cell
if (sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
&p4est_cell,
internal::p4est::functions<dim>::quadrant_compare)
}
else
{
- // no, cell not found in
- // local part of
- // p4est. this means that
- // the local part is more
- // refined than the current
- // cell. if this cell has
- // no children of its own,
- // we need to refine it,
- // and if it does already
- // have children then loop
- // over all children and
- // see if they are locally
- // available as well
+ // no, cell not found in local part of p4est. this means that the
+ // local part is more refined than the current cell. if this cell has
+ // no children of its own, we need to refine it, and if it does
+ // already have children then loop over all children and see if they
+ // are locally available as well
if (dealii_cell->has_children () == false)
dealii_cell->set_refine_flag ();
else
&p4est_child[c])
== false)
{
- // no, this child
- // is locally not
- // available in
- // the p4est.
- // delete all
- // its children
- // but, because this
- // may not be successfull,
- // make sure to mark all
- // children recursively as
- // not local.
+ // no, this child is locally not available in the p4est.
+ // delete all its children but, because this may not be
+ // successfull, make sure to mark all children recursively
+ // as not local.
delete_all_children<dim,spacedim> (dealii_cell->child(c));
dealii_cell->child(c)
->recursively_set_subdomain_id(numbers::artificial_subdomain_id);
}
else
{
- // at least some
- // part of the
- // tree rooted in
- // this child is
- // locally
- // available
+ // at least some part of the tree rooted in this child is
+ // locally available
match_tree_recursively<dim,spacedim> (tree,
dealii_cell->child(c),
p4est_child[c],
{
//this cell got refined
- //attach to the first child, because
- // we can only attach to active
+ //attach to the first child, because we can only attach to active
// quadrants
typename internal::p4est::types<dim>::quadrant
p4est_child[GeometryInfo<dim>::max_children_per_cell];
}
else
{
- //it's children got coarsened into
- //this cell
+ //it's children got coarsened into this cell
typename internal::p4est::types<dim>::quadrant *q;
q = static_cast<typename internal::p4est::types<dim>::quadrant *> (
sc_array_index (const_cast<sc_array_t *>(&tree.quadrants), idx)
quadrant_overlaps_tree (const_cast<typename internal::p4est::types<dim>::tree *>(&tree),
&p4est_cell)
== false))
- // this quadrant and none of
- // it's children belong to us.
+ // this quadrant and none of it's children belong to us.
return;
/**
- * A data structure that we use to store
- * which cells (indicated by
- * internal::p4est::types<dim>::quadrant objects) shall be
- * refined and which shall be coarsened.
+ * A data structure that we use to store which cells (indicated by
+ * internal::p4est::types<dim>::quadrant objects) shall be refined and which
+ * shall be coarsened.
*/
template <int dim, int spacedim>
class RefineAndCoarsenList
typename internal::p4est::types<dim>::forest &forest);
/**
- * A callback function that we
- * pass to the p4est data
- * structures when a forest is
- * to be refined. The p4est
- * functions call it back with
- * a tree (the index of the
- * tree that grows out of a
- * given coarse cell) and a
- * refinement path from that
- * coarse cell to a
- * terminal/leaf cell. The
- * function returns whether the
- * corresponding cell in the
- * deal.II triangulation has
- * the refined flag set.
+ * A callback function that we pass to the p4est data structures when a
+ * forest is to be refined. The p4est functions call it back with a tree
+ * (the index of the tree that grows out of a given coarse cell) and a
+ * refinement path from that coarse cell to a terminal/leaf cell. The
+ * function returns whether the corresponding cell in the deal.II
+ * triangulation has the refined flag set.
*/
static
int
typename internal::p4est::types<dim>::quadrant *quadrant);
/**
- * Same as the refine_callback
- * function, but return whether
- * all four of the given
- * children of a non-terminal
- * cell are to be coarsened
- * away.
+ * Same as the refine_callback function, but return whether all four of
+ * the given children of a non-terminal cell are to be coarsened away.
*/
static
int
:
forest(forest)
{
- // count how many flags are set and
- // allocate that much memory
+ // count how many flags are set and allocate that much memory
unsigned int n_refine_flags = 0,
n_coarsen_flags = 0;
for (typename Triangulation<dim,spacedim>::active_cell_iterator
coarsen_list.reserve (n_coarsen_flags);
- // now build the lists of cells that
- // are flagged. note that p4est will
- // traverse its cells in the order in
- // which trees appear in the
- // forest. this order is not the same
- // as the order of coarse cells in the
- // deal.II Triangulation because we
- // have translated everything by the
- // coarse_cell_to_p4est_tree_permutation
- // permutation. in order to make sure
- // that the output array is already in
- // the correct order, traverse our
- // coarse cells in the same order in
- // which p4est will:
+ // now build the lists of cells that are flagged. note that p4est will
+ // traverse its cells in the order in which trees appear in the
+ // forest. this order is not the same as the order of coarse cells in the
+ // deal.II Triangulation because we have translated everything by the
+ // coarse_cell_to_p4est_tree_permutation permutation. in order to make
+ // sure that the output array is already in the correct order, traverse
+ // our coarse cells in the same order in which p4est will:
for (unsigned int c=0; c<triangulation.n_cells(0); ++c)
{
unsigned int coarse_cell_index =
Assert(coarsen_list.size() == n_coarsen_flags,
ExcInternalError());
- // make sure that our ordering in fact
- // worked
+ // make sure that our ordering in fact worked
for (unsigned int i=1; i<refine_list.size(); ++i)
Assert (refine_list[i].p.which_tree >=
refine_list[i-1].p.which_tree,
RefineAndCoarsenList<dim,spacedim> *this_object
= reinterpret_cast<RefineAndCoarsenList<dim,spacedim>*>(forest->user_pointer);
- // if there are no more cells in our
- // list the current cell can't be
+ // if there are no more cells in our list the current cell can't be
// flagged for refinement
if (this_object->current_refine_pointer == this_object->refine_list.end())
return false;
this_object->current_refine_pointer->p.which_tree,
ExcInternalError());
- // if p4est hasn't yet reached the tree
- // of the next flagged cell the current
- // cell can't be flagged for refinement
+ // if p4est hasn't yet reached the tree of the next flagged cell the
+ // current cell can't be flagged for refinement
if (coarse_cell_index <
this_object->current_refine_pointer->p.which_tree)
return false;
- // now we're in the right tree in the
- // forest
+ // now we're in the right tree in the forest
Assert (coarse_cell_index <=
this_object->current_refine_pointer->p.which_tree,
ExcInternalError());
- // make sure that the p4est loop over
- // cells hasn't gotten ahead of our own
+ // make sure that the p4est loop over cells hasn't gotten ahead of our own
// pointer
Assert (internal::p4est::functions<dim>::
quadrant_compare (quadrant,
&*this_object->current_refine_pointer) <= 0,
ExcInternalError());
- // now, if the p4est cell is one in the
- // list, it is supposed to be refined
+ // now, if the p4est cell is one in the list, it is supposed to be refined
if (internal::p4est::functions<dim>::
quadrant_is_equal (quadrant, &*this_object->current_refine_pointer))
{
RefineAndCoarsenList<dim,spacedim> *this_object
= reinterpret_cast<RefineAndCoarsenList<dim,spacedim>*>(forest->user_pointer);
- // if there are no more cells in our
- // list the current cell can't be
+ // if there are no more cells in our list the current cell can't be
// flagged for coarsening
if (this_object->current_coarsen_pointer ==
this_object->coarsen_list.end())
this_object->current_coarsen_pointer->p.which_tree,
ExcInternalError());
- // if p4est hasn't yet reached the tree
- // of the next flagged cell the current
- // cell can't be flagged for coarsening
+ // if p4est hasn't yet reached the tree of the next flagged cell the
+ // current cell can't be flagged for coarsening
if (coarse_cell_index <
this_object->current_coarsen_pointer->p.which_tree)
return false;
- // now we're in the right tree in the
- // forest
+ // now we're in the right tree in the forest
Assert (coarse_cell_index <=
this_object->current_coarsen_pointer->p.which_tree,
ExcInternalError());
- // make sure that the p4est loop over
- // cells hasn't gotten ahead of our own
+ // make sure that the p4est loop over cells hasn't gotten ahead of our own
// pointer
Assert (internal::p4est::functions<dim>::
quadrant_compare (children[0],
&*this_object->current_coarsen_pointer) <= 0,
ExcInternalError());
- // now, if the p4est cell is one in the
- // list, it is supposed to be coarsened
+ // now, if the p4est cell is one in the list, it is supposed to be
+ // coarsened
if (internal::p4est::functions<dim>::
quadrant_is_equal (children[0],
&*this_object->current_coarsen_pointer))
// move current pointer one up
++this_object->current_coarsen_pointer;
- // note that the next 3 cells in
- // our list need to correspond to
- // the other siblings of the cell
- // we have just found
+ // note that the next 3 cells in our list need to correspond to the
+ // other siblings of the cell we have just found
for (unsigned int c=1; c<GeometryInfo<dim>::max_children_per_cell; ++c)
{
Assert (internal::p4est::functions<dim>::
{
Singleton ()
{
- // ensure that the
- // initialization
- // code is run only
- // once, even if we
- // link with 1d, 2d,
- // and 3d libraries
+ // ensure that the initialization code is run only once, even if we
+ // link with 1d, 2d, and 3d libraries
static bool initialized = false;
if (initialized == false)
if (deinitialized == false)
{
- // p4est has no
- // p4est_finalize
- // function
+ // p4est has no p4est_finalize function
sc_finalize ();
deinitialized = true;
};
public:
- // do run the initialization code, at least the first time around we
- // get to this function
+ // do run the initialization code, at least the first time around we get
+ // to this function
static void do_initialize ()
{
static Singleton singleton;
const typename dealii::Triangulation<dim,spacedim>::MeshSmoothing smooth_grid,
const Settings settings_)
:
- // do not check
- // for distorted
- // cells
+ // do not check for distorted cells
dealii::Triangulation<dim,spacedim>
(smooth_grid,
false),
n_attached_datas(0),
n_attached_deserialize(0)
{
- // initialize p4est. do this in a separate function since it has
- // to happen only once, even if we have triangulation objects
- // for several different space dimensions
+ // initialize p4est. do this in a separate function since it has to
+ // happen only once, even if we have triangulation objects for several
+ // different space dimensions
dealii::internal::p4est::InitFinalize::do_initialize ();
parallel_ghost = 0;
Assert (parallel_forest == 0, ExcInternalError());
Assert (refinement_in_progress == false, ExcInternalError());
- // get rid of the unique
- // communicator used here again
+ // get rid of the unique communicator used here again
MPI_Comm_free (&mpi_communicator);
}
}
catch (const typename dealii::Triangulation<dim,spacedim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
- // distorted cells
+ // the underlying triangulation should not be checking for distorted
+ // cells
AssertThrow (false, ExcInternalError());
}
- // note that now we have some content in
- // the p4est objects and call the
- // functions that do the actual work
- // (which are dimension dependent, so
+ // note that now we have some content in the p4est objects and call the
+ // functions that do the actual work (which are dimension dependent, so
// separate)
triangulation_has_content = true;
}
catch (const typename Triangulation<dim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
- // distorted cells
+ // the underlying triangulation should not be checking for distorted
+ // cells
AssertThrow (false, ExcInternalError());
}
Assert (this->n_cells(0) > 0, ExcInternalError());
Assert (this->n_levels() == 1, ExcInternalError());
- // data structures that counts how many
- // cells touch each vertex
- // (vertex_touch_count), and which cells
- // touch a given vertex (together with
- // the local numbering of that vertex
- // within the cells that touch it)
+ // data structures that counts how many cells touch each vertex
+ // (vertex_touch_count), and which cells touch a given vertex (together
+ // with the local numbering of that vertex within the cells that touch
+ // it)
std::vector<unsigned int> vertex_touch_count;
std::vector<
std::list<
vertex_touch_count.end(),
0);
- // now create a connectivity
- // object with the right sizes
- // for all arrays. set vertex
- // information only in debug
- // mode (saves a few bytes in
- // optimized mode)
+ // now create a connectivity object with the right sizes for all
+ // arrays. set vertex information only in debug mode (saves a few bytes
+ // in optimized mode)
const bool set_vertex_info
#ifdef DEBUG
= true
Assert (p4est_connectivity_is_valid (connectivity) == 1,
ExcInternalError());
- // now create a forest out of the
- // connectivity data structure
+ // now create a forest out of the connectivity data structure
parallel_forest
= dealii::internal::p4est::functions<2>::
new_forest (mpi_communicator,
- // TODO: This is a verbatim copy of the 2,2
- // case. However, we can't just specialize the
- // dim template argument, but let spacedim open
+ // TODO: This is a verbatim copy of the 2,2 case. However, we can't just
+ // specialize the dim template argument, but let spacedim open
template <>
void
Triangulation<2,3>::copy_new_triangulation_to_p4est (dealii::internal::int2type<2>)
Assert (this->n_cells(0) > 0, ExcInternalError());
Assert (this->n_levels() == 1, ExcInternalError());
- // data structures that counts how many
- // cells touch each vertex
- // (vertex_touch_count), and which cells
- // touch a given vertex (together with
- // the local numbering of that vertex
- // within the cells that touch it)
+ // data structures that counts how many cells touch each vertex
+ // (vertex_touch_count), and which cells touch a given vertex (together
+ // with the local numbering of that vertex within the cells that touch
+ // it)
std::vector<unsigned int> vertex_touch_count;
std::vector<
std::list<
vertex_touch_count.end(),
0);
- // now create a connectivity
- // object with the right sizes
- // for all arrays. set vertex
- // information only in debug
- // mode (saves a few bytes in
- // optimized mode)
+ // now create a connectivity object with the right sizes for all
+ // arrays. set vertex information only in debug mode (saves a few bytes
+ // in optimized mode)
const bool set_vertex_info
#ifdef DEBUG
= true
Assert (p4est_connectivity_is_valid (connectivity) == 1,
ExcInternalError());
- // now create a forest out of the
- // connectivity data structure
+ // now create a forest out of the connectivity data structure
parallel_forest
= dealii::internal::p4est::functions<2>::
new_forest (mpi_communicator,
Assert (this->n_cells(0) > 0, ExcInternalError());
Assert (this->n_levels() == 1, ExcInternalError());
- // data structures that counts how many
- // cells touch each vertex
- // (vertex_touch_count), and which cells
- // touch a given vertex (together with
- // the local numbering of that vertex
- // within the cells that touch it)
+ // data structures that counts how many cells touch each vertex
+ // (vertex_touch_count), and which cells touch a given vertex (together
+ // with the local numbering of that vertex within the cells that touch
+ // it)
std::vector<unsigned int> vertex_touch_count;
std::vector<
std::list<
num_ett = std::accumulate (edge_touch_count.begin(),
edge_touch_count.end(),
0);
- // now create a connectivity object with
- // the right sizes for all arrays
-
+
+ // now create a connectivity object with the right sizes for all arrays
const bool set_vertex_info
#ifdef DEBUG
= true
Assert (p8est_connectivity_is_valid (connectivity) == 1,
ExcInternalError());
- // now create a forest out of the
- // connectivity data structure
+ // now create a forest out of the connectivity data structure
parallel_forest
= dealii::internal::p4est::functions<3>::
new_forest (mpi_communicator,
void
Triangulation<dim,spacedim>::copy_local_forest_to_triangulation ()
{
- // disable mesh smoothing for
- // recreating the deal.II
- // triangulation, otherwise we might
- // not be able to reproduce the p4est
- // mesh exactly. We restore the
- // original smoothing at the end of
- // this function. Note that the
- // smoothing flag is used in the normal
+ // disable mesh smoothing for recreating the deal.II triangulation,
+ // otherwise we might not be able to reproduce the p4est mesh
+ // exactly. We restore the original smoothing at the end of this
+ // function. Note that the smoothing flag is used in the normal
// refinement process.
typename Triangulation<dim,spacedim>::MeshSmoothing
save_smooth = this->smooth_grid;
}
catch (const typename Triangulation<dim, spacedim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
+ // the underlying triangulation should not be checking for
// distorted cells
AssertThrow (false, ExcInternalError());
}
cell != this->end(0);
++cell)
{
- // if this processor
- // stores no part of the
- // forest that comes out
- // of this coarse grid
- // cell, then we need to
- // delete all children of
- // this cell (the coarse
- // grid cell remains)
+ // if this processor stores no part of the forest that comes out
+ // of this coarse grid cell, then we need to delete all children
+ // of this cell (the coarse grid cell remains)
if (tree_exists_locally<dim,spacedim>(parallel_forest,
coarse_cell_to_p4est_tree_permutation[cell->index()])
== false)
else
{
-
- // this processor
- // stores at least a
- // part of the tree
- // that comes out of
- // this cell.
-
+ // this processor stores at least a part of the tree that
+ // comes out of this cell.
typename dealii::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
typename dealii::internal::p4est::types<dim>::tree *tree =
}
}
- // check mesh for ghostcells,
- // refine as necessary.
- // iterate over every ghostquadrant,
- // find corresponding deal coarsecell
- // and recurse.
+ // check mesh for ghostcells, refine as necessary. iterate over
+ // every ghostquadrant, find corresponding deal coarsecell and
+ // recurse.
typename dealii::internal::p4est::types<dim>::quadrant *quadr;
unsigned int ghost_owner=0;
typename dealii::internal::p4est::types<dim>::topidx ghost_tree=0;
match_quadrant<dim,spacedim> (this, coarse_cell_index, *quadr, ghost_owner);
}
- // fix all the flags to make
- // sure we have a consistent
- // mesh
+ // fix all the flags to make sure we have a consistent mesh
this->prepare_coarsening_and_refinement ();
// see if any flags are still set
break;
}
- // actually do the refinement
- // but prevent the refinement
- // hook below from taking
- // over
+ // actually do the refinement but prevent the refinement hook below
+ // from taking over
const bool saved_refinement_in_progress = refinement_in_progress;
refinement_in_progress = true;
}
catch (const typename Triangulation<dim,spacedim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
+ // the underlying triangulation should not be checking for
// distorted cells
AssertThrow (false, ExcInternalError());
}
// we need this information for all our ancestors and the same-level neighbors of our own cells (=level ghosts)
if (settings & construct_multigrid_hierarchy)
{
- // step 1: We set our own ids all the way down and all the others to -1. Note that we do not fill
- // other cells we could figure out the same way, because we might accidentally set an id for a
- // cell that is not a ghost cell.
+ // step 1: We set our own ids all the way down and all the others to
+ // -1. Note that we do not fill other cells we could figure out the
+ // same way, because we might accidentally set an id for a cell that
+ // is not a ghost cell.
for (unsigned int lvl=this->n_levels(); lvl>0;)
{
--lvl;
}
}
- //step 2: make sure all the neighbors to our level_cells exist. Need to look up in p4est...
+ //step 2: make sure all the neighbors to our level_cells exist. Need
+ //to look up in p4est...
std::vector<std::vector<bool> > marked_vertices(this->n_levels());
for (unsigned int lvl=0; lvl<this->n_levels(); ++lvl)
{
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
+ //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)
}
}
- //step 4: Special case: on each level we need all the face neighbors of our own level cells
- // these are normally on the same level, 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):
+ //step 4: Special case: on each level we need all the face neighbors
+ // of our own level cells these are normally on the same level,
+ // 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):
for (typename Triangulation<dim,spacedim>::cell_iterator cell = this->begin(); cell!=this->end(); ++cell)
{
if (cell->level_subdomain_id()!=this->locally_owned_subdomain())
- // check that our local copy has
- // exactly as many cells as the
- // p4est original (at least if we
- // are on only one processor);
- // for parallel computations, we
- // want to check that we have at
- // least as many as p4est stores
- // locally (in the future we
- // should check that we have
- // exactly as many non-artificial
- // cells as
- // parallel_forest->local_num_quadrants)
+ // check that our local copy has exactly as many cells as the p4est
+ // original (at least if we are on only one processor); for parallel
+ // computations, we want to check that we have at least as many as p4est
+ // stores locally (in the future we should check that we have exactly as
+ // many non-artificial cells as parallel_forest->local_num_quadrants)
{
const unsigned int total_local_cells = this->n_active_cells();
total_local_cells,
ExcInternalError());
- // count the number of owned, active
- // cells and compare with p4est.
+ // count the number of owned, active cells and compare with p4est.
unsigned int n_owned = 0;
for (typename Triangulation<dim,spacedim>::active_cell_iterator
cell = this->begin_active();
void
Triangulation<dim, spacedim>::execute_coarsening_and_refinement ()
{
- // first make sure that recursive
- // calls are handled correctly
+ // first make sure that recursive calls are handled correctly
if (refinement_in_progress == true)
{
dealii::Triangulation<dim,spacedim>::execute_coarsening_and_refinement ();
}
}
- // now do the work we're
- // supposed to do when we are
- // in charge
+ // now do the work we're supposed to do when we are in charge
refinement_in_progress = true;
this->prepare_coarsening_and_refinement ();
- // make sure all flags are
- // cleared on cells we don't
- // own, since nothing good can
- // come of that if they are
- // still around
+ // make sure all flags are cleared on cells we don't own, since nothing
+ // good can come of that if they are still around
for (typename Triangulation<dim,spacedim>::active_cell_iterator
cell = this->begin_active();
cell != this->end(); ++cell)
}
- // count how many cells will be refined
- // and coarsened, and allocate that much
- // memory
+ // count how many cells will be refined and coarsened, and allocate that
+ // much memory
RefineAndCoarsenList<dim,spacedim>
refine_and_coarsen_list (*this,
p4est_tree_to_coarse_cell_permutation,
my_subdomain,
*parallel_forest);
- // copy refine and coarsen flags into
- // p4est and execute the refinement and
- // coarsening. this uses the
- // refine_and_coarsen_list just built,
- // which is communicated to the callback
- // functions through the
+ // copy refine and coarsen flags into p4est and execute the refinement
+ // and coarsening. this uses the refine_and_coarsen_list just built,
+ // which is communicated to the callback functions through the
// user_pointer
Assert (parallel_forest->user_pointer == this,
ExcInternalError());
&RefineAndCoarsenList<dim,spacedim>::coarsen_callback,
/*init_callback=*/NULL);
- // make sure all cells in the lists have
- // been consumed
+ // make sure all cells in the lists have been consumed
Assert (refine_and_coarsen_list.pointers_are_at_end(),
ExcInternalError());
/*init_callback=*/NULL);
- // before repartitioning the mesh let
- // others attach mesh related info
- // (such as SolutionTransfer data) to
- // the p4est
+ // before repartitioning the mesh let others attach mesh related info
+ // (such as SolutionTransfer data) to the p4est
attach_mesh_data();
- // partition the new mesh between
- // all processors
+ // partition the new mesh between all processors
dealii::internal::p4est::functions<dim>::
partition (parallel_forest,
/* prepare coarsening */ 1,
/* weight_callback */ NULL);
- // finally copy back from local
- // part of tree to deal.II
- // triangulation. before doing
- // so, make sure there are no
- // refine or coarsen flags
- // pending
+ // finally copy back from local part of tree to deal.II
+ // triangulation. before doing so, make sure there are no refine or
+ // coarsen flags pending
for (typename Triangulation<dim,spacedim>::active_cell_iterator
cell = this->begin_active();
cell != this->end(); ++cell)
}
catch (const typename Triangulation<dim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
- // distorted cells
+ // the underlying triangulation should not be checking for distorted
+ // cells
AssertThrow (false, ExcInternalError());
}
number_cache.n_global_active_cells
= std::accumulate (number_cache.n_locally_owned_active_cells.begin(),
number_cache.n_locally_owned_active_cells.end(),
- /* ensure sum is
- computed with
- correct data
- type:*/
+ /* ensure sum is computed with correct data type:*/
static_cast<types::global_dof_index>(0));
number_cache.n_global_levels = Utilities::MPI::max(this->n_levels(), mpi_communicator);
}
dealii::internal::p4est::init_coarse_quadrant<dim> (p4est_coarse_cell);
- // parent_cell is not correct here,
- // but is only used in a refined
+ // parent_cell is not correct here, but is only used in a refined
// cell
post_mesh_data_recursively<dim, spacedim> (*tree,
cell,
}
// important: only remove data if we are not in the deserialization
- // process. There, each SolutionTransfer registers and unpacks
- // before the next one does this, so n_attached_datas is only 1 here.
- // This would destroy the saved data before the second SolutionTransfer
- // can get it. This created a bug that is documented in
+ // process. There, each SolutionTransfer registers and unpacks before
+ // the next one does this, so n_attached_datas is only 1 here. This
+ // would destroy the saved data before the second SolutionTransfer can
+ // get it. This created a bug that is documented in
// tests/mpi/p4est_save_03 with more than one SolutionTransfer.
if (!n_attached_datas && n_attached_deserialize == 0)
{
(connectivity) == 1,
ExcInternalError());
- // now create a forest out of the
- // connectivity data structure
+ // now create a forest out of the connectivity data structure
dealii::internal::p4est::functions<dim>::destroy (parallel_forest);
parallel_forest
= dealii::internal::p4est::functions<dim>::
}
catch (const typename dealii::Triangulation<dim,spacedim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
- // distorted cells
+ // the underlying triangulation should not be checking for distorted
+ // cells
AssertThrow (false, ExcInternalError());
}
- // note that now we have some content in
- // the p4est objects and call the
- // functions that do the actual work
- // (which are dimension dependent, so
+ // note that now we have some content in the p4est objects and call the
+ // functions that do the actual work (which are dimension dependent, so
// separate)
triangulation_has_content = true;
}
catch (const typename Triangulation<dim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
- // distorted cells
+ // the underlying triangulation should not be checking for distorted
+ // cells
AssertThrow (false, ExcInternalError());
}
Triangulation<dim,spacedim>::
attach_mesh_data()
{
- // determine size of memory in bytes to
- // attach to each cell. This needs to
- // be constant because of p4est.
+ // determine size of memory in bytes to attach to each cell. This needs
+ // to be constant because of p4est.
if (attached_data_size==0)
{
Assert(n_attached_datas==0, ExcInternalError());
- // TODO: again problems with specialization in
- // only one template argument
+ // TODO: again problems with specialization in only one template argument
template <>
Triangulation<1,1>::Triangulation (MPI_Comm)
{