From: Ralf Hartmann Date: Tue, 20 Mar 2001 10:21:02 +0000 (+0000) Subject: New functions restore(uint step), clear_flags, n_refinement_steps. This allows to... X-Git-Tag: v8.0.0~19525 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cd7b92bb4a62fbcc3ae21403212e3f50c9ed2c3;p=dealii.git New functions restore(uint step), clear_flags, n_refinement_steps. This allows to restore the triangulation step by step. git-svn-id: https://svn.dealii.org/trunk@4247 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/persistent_tria.h b/deal.II/deal.II/include/grid/persistent_tria.h index c0cd5d3f33..ba4fc4f2f2 100644 --- a/deal.II/deal.II/include/grid/persistent_tria.h +++ b/deal.II/deal.II/include/grid/persistent_tria.h @@ -140,19 +140,40 @@ class PersistentTriangulation : public Triangulation virtual void execute_coarsening_and_refinement (); /** - * Restore the grid according to the saved - * data. For this, the coarse grid is - * copied and the grid is stepwise - * rebuilt using the saved flags. + * Restore the grid according to + * the saved data. For this, the + * coarse grid is copied and the + * grid is stepwise rebuilt using + * the saved flags. * - * Note that this function will result in - * an error if the underlying triangulation - * is not empty, i.e. it will only succeed - * if this object is newly created or - * @p{clear()} was called on it before. + * Note that this function will + * result in an error if the + * underlying triangulation is + * not empty, i.e. it will only + * succeed if this object is + * newly created or @p{clear()} + * was called on it before. */ void restore (); + /** + * Differential restore. Performs + * the @p{step}th local + * refinement and coarsening step. + * Step 0 stands for the copying + * of the coarse grid. + */ + void restore (const unsigned int step); + + /** + * Returns the number of + * refinement and coarsening + * steps. This is given by the + * size of the @p{refine_flags} + * vector. + */ + unsigned int n_refinement_steps () const; + /** * Overload this function to use * @p{tria} as a new coarse grid. The @@ -196,6 +217,12 @@ class PersistentTriangulation : public Triangulation */ virtual void read_flags(std::istream &in); + /** + * Clears all flags. Retains the + * same coarse grid. + */ + virtual void clear_flags(); + /** * Determine an estimate for the * memory consumption (in bytes) @@ -211,6 +238,10 @@ class PersistentTriangulation : public Triangulation * Exception. */ DeclException0 (ExcTriaNotEmpty); + /** + * Exception. + */ + DeclException0 (ExcFlagsNotCleared); private: /** diff --git a/deal.II/deal.II/source/grid/persistent_tria.cc b/deal.II/deal.II/source/grid/persistent_tria.cc index 409f79def2..7e3dcc2ddc 100644 --- a/deal.II/deal.II/source/grid/persistent_tria.cc +++ b/deal.II/deal.II/source/grid/persistent_tria.cc @@ -69,26 +69,49 @@ PersistentTriangulation::execute_coarsening_and_refinement () template void -PersistentTriangulation::restore () { - // copy the old triangulation. - // this will yield an error if the - // underlying triangulation was not - // empty - Triangulation::copy_triangulation (*coarse_grid); - - // for each of the previous refinement - // sweeps - for (unsigned int i=0; i::restore () +{ + // for each of the previous + // refinement sweeps + for (unsigned int i=0; i +void +PersistentTriangulation::restore (const unsigned int step) { + + if (step==0) + // copy the old triangulation. + // this will yield an error if + // the underlying triangulation + // was not empty + Triangulation::copy_triangulation (*coarse_grid); + else + // for each of the previous + // refinement sweeps { - // get flags - load_refine_flags (refine_flags[i]); - load_coarsen_flags (coarsen_flags[i]); + Assert(step::execute_coarsening_and_refinement (); }; }; + +template +unsigned int +PersistentTriangulation::n_refinement_steps() const +{ + return refine_flags.size(); +} + + template void PersistentTriangulation::copy_triangulation (const Triangulation &old_grid) @@ -139,10 +162,9 @@ void PersistentTriangulation::read_flags(std::istream &in) { Assert(refine_flags.size()==0 && coarsen_flags.size()==0, - ExcTriaNotEmpty()); - + ExcFlagsNotCleared()); AssertThrow (in, ExcIO()); - + unsigned int magic_number; in >> magic_number; AssertThrow(magic_number==mn_persistent_tria_flags_begin, @@ -168,6 +190,14 @@ PersistentTriangulation::read_flags(std::istream &in) } +template +void +PersistentTriangulation::clear_flags() +{ + refine_flags.clear(); + coarsen_flags.clear(); +} + template unsigned int