Re-enable printing of a preamble to ucd files in data_io.cc.
+Implement coarsening of grids and update docs for that.
+
+
DEAL:
* that of the #quads# vector, etc.
*/
vector<bool> refine_flags;
+
+ /**
+ * Same meaning as the one above, but
+ * specifies whether a cell must be
+ * coarsened.
+ */
+ vector<bool> coarsen_flags;
/**
* Levels and indices of the neighbors
*
* You may write other information to the output file between different sets
* of refinement information, as long as you read it upon re-creation of the
- * grid.
+ * grid. You should make sure that the other information in the new
+ * triangulation which is to be created from the saves flags, matches that of
+ * the old triangulation, for example the smoothing level; if not, the
+ * cells actually created from the flags may be other ones, since smoothing
+ * adds additional cells, but the number depending on the smoothing level.
*
*
* \subsection{User flags}
* This function is dimension specific.
*/
void execute_refinement ();
+
+ /**
+ * Coarsen all cells which were flagged for
+ * coarsening, or rather: delete all
+ * children of those cells of which all
+ * child cells are flagged for coarsening
+ * and several other constraints hold (see
+ * the general doc of this class).
+ *
+ * The function resets all refinement
+ * flags to false.
+ *
+ * This function is dimension specific.
+ */
+ void execute_coarsening ();
/*@}*/
/**
bool refine_flag_set () const;
/**
- * Flag the cell pointed to
- * for refinement.
+ * Flag the cell pointed to fo
+ * refinement. This function is only
+ * allowed for active cells.
*/
void set_refine_flag () const;
*/
void clear_refine_flag () const;
+
+ /**
+ * Return whether the coarsen flag
+ * is set or not.
+ */
+ bool coarsen_flag_set () const;
+
+ /**
+ * Flag the cell pointed to for
+ * coarsening. This function is only
+ * allowed for active cells.
+ */
+ void set_coarsen_flag () const;
+
+ /**
+ * Clear the coarsen flag.
+ */
+ void clear_coarsen_flag () const;
+
/**
* Return a pointer to the #i#th
* child. Overloaded version which returns
#ifdef DEBUG
for (unsigned int level=0; level<levels.size(); ++level)
levels[level]->monitor_memory (1);
+
+ // check whether really all refinement flags
+ // are reset (also of previously non-active
+ // cells which we may not have touched. If
+ // the refinement flag of a non-active cell
+ // is set, something went wrong since the
+ // cell-accessors should have caught this)
+ cell_iterator cell = begin(),
+ endc = end();
+ while (cell != endc)
+ Assert (!(cell++)->refine_flag_set(), ExcInternalError ());
#endif
};
#ifdef DEBUG
for (unsigned int level=0; level<levels.size(); ++level)
levels[level]->monitor_memory (2);
+
+ // check whether really all refinement flags
+ // are reset (also of previously non-active
+ // cells which we may not have touched. If
+ // the refinement flag of a non-active cell
+ // is set, something went wrong since the
+ // cell-accessors should have caught this)
+ cell_iterator cell = begin(),
+ endc = end();
+ while (cell != endc)
+ Assert (!(cell++)->refine_flag_set(), ExcInternalError ());
#endif
};
-
+
+
+
+template <int dim>
+void Triangulation<dim>::execute_coarsening () {
+ Assert (false, ExcInternalError());
+};
+
template <int dim>
refine_flags.insert (refine_flags.end(),
total_cells - refine_flags.size(),
false);
+
+ coarsen_flags.reserve (total_cells);
+ coarsen_flags.insert (coarsen_flags.end(),
+ total_cells - coarsen_flags.size(),
+ false);
neighbors.reserve (total_cells*(2*dimension));
neighbors.insert (neighbors.end(),
// refine_flags.size()<256,
// ExcMemoryWasted ("refine_flags",
// refine_flags.size(), refine_flags.capacity()));
+// Assert (coarsen_flags.size() == coarsen_flags.capacity() ||
+// coarsen_flags.size()<256,
+// ExcMemoryWasted ("coarsen_flags",
+// coarsen_flags.size(), coarsen_flags.capacity()));
// Assert (neighbors.size() == neighbors.capacity() ||
// neighbors.size()<256,
// ExcMemoryWasted ("neighbors",
// neighbors.size(), neighbors.capacity()));
Assert (2*true_dimension*refine_flags.size() == neighbors.size(),
ExcMemoryInexact (refine_flags.size(), neighbors.size()));
+ Assert (2*true_dimension*coarsen_flags.size() == neighbors.size(),
+ ExcMemoryInexact (coarsen_flags.size(), neighbors.size()));
};
template <int dim>
bool CellAccessor<dim>::refine_flag_set () const {
- Assert (used() && active(),
+ Assert (used(), typename TriaSubstructAccessor<dim>::ExcCellNotUsed());
+ // cells flagged for refinement must be active
+ // (the #set_refine_flag# function checks this,
+ // but activity may change when refinement is
+ // executed and for some reason the refine
+ // flag is not cleared).
+ Assert (active() || !tria->levels[present_level]->refine_flags[present_index],
typename TriaSubstructAccessor<dim>::ExcRefineCellNotActive());
return tria->levels[present_level]->refine_flags[present_index];
};
+template <int dim>
+bool CellAccessor<dim>::coarsen_flag_set () const {
+ Assert (used(), typename TriaSubstructAccessor<dim>::ExcCellNotUsed());
+ // cells flagged for coarsening must be active
+ // (the #set_refine_flag# function checks this,
+ // but activity may change when refinement is
+ // executed and for some reason the refine
+ // flag is not cleared).
+ Assert (active() || !tria->levels[present_level]->coarsen_flags[present_index],
+ typename TriaSubstructAccessor<dim>::ExcRefineCellNotActive());
+ return tria->levels[present_level]->coarsen_flags[present_index];
+};
+
+
+
+template <int dim>
+void CellAccessor<dim>::set_coarsen_flag () const {
+ Assert (used() && active(),
+ typename TriaSubstructAccessor<dim>::ExcRefineCellNotActive());
+ tria->levels[present_level]->coarsen_flags[present_index] = true;
+};
+
+
+
+template <int dim>
+void CellAccessor<dim>::clear_coarsen_flag () const {
+ Assert (used() && active(),
+ typename TriaSubstructAccessor<dim>::ExcRefineCellNotActive());
+ tria->levels[present_level]->coarsen_flags[present_index] = false;
+};
+
+
+
template <int dim>
TriaIterator<dim,CellAccessor<dim> >
CellAccessor<dim>::neighbor (const unsigned int i) const {