PersistentTriangulation< dim > Class Template Reference
[Grid classes]

Inheritance diagram for PersistentTriangulation< dim >:

Inheritance graph
[legend]

List of all members.

Classes

class  ExcFlagsNotCleared
class  ExcTriaNotEmpty

Public Member Functions

 PersistentTriangulation (const Triangulation< dim > &coarse_grid)
 PersistentTriangulation (const PersistentTriangulation< dim > &old_tria)
virtual ~PersistentTriangulation ()
virtual void execute_coarsening_and_refinement ()
void restore ()
void restore (const unsigned int step_no)
unsigned int n_refinement_steps () const
virtual void copy_triangulation (const Triangulation< dim > &tria)
virtual void create_triangulation (const std::vector< Point< dim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
virtual void create_triangulation_compatibility (const std::vector< Point< dim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
virtual void write_flags (std::ostream &out) const
virtual void read_flags (std::istream &in)
virtual void clear_flags ()
virtual unsigned int memory_consumption () const

Static Public Attributes

static const unsigned int dimension = dim

Private Attributes

SmartPointer< const
Triangulation< dim > > 
coarse_grid
std::vector< std::vector< bool > > refine_flags
std::vector< std::vector< bool > > coarsen_flags


Detailed Description

template<int dim>
class PersistentTriangulation< dim >

This class handles the history of a triangulation and can rebuild it after it was deleted some time before. Its main purpose is support for time-dependent problems where one frequently deletes a triangulation due to memory pressure and later wants to rebuild it; this class has all the information to rebuild it exactly as it was before including the mapping of cell numbers to the geometrical cells.

Basically, this is a drop-in replacement for the triangulation. Since it is derived from the Triangulation class, it shares all the functionality, but it overrides some virtual functions and adds some functions, too. The main change to the base class is that it overrides the execute_coarsening_and_refinement function, where the new version first stores all refinement and coarsening flags and only then calls the respective function of the base class. The stored flags may later be used to restore the grid just as it was before. Some other functions have been extended slightly as well, see their documentation for more information.

We note that since the triangulation is created in exactly the same state as it was before, other objects working on it should result in the same state as well. This holds in particular for the DoFHandler object, which will assign the same degrees of freedom to the original cells and the ones after reconstruction of the triangulation. You can therefore safely use data vectors computed on the original grid on the reconstructed grid as well.

Usage

You can use objects of this class almost in the same way as objects of the Triangulation class. One of the few differences is that you can only construct such an object by giving a coarse grid to the constructor. The coarse grid will be used to base the triangulation on, and therefore the lifetime of the coarse grid has to be longer than the lifetime of the object of this class.

Basically, usage looks like this:

 *   Triangulation<dim> coarse_grid;
 *   ...                     // initialize coarse grid
 *
 *   PersistentTriangulation<dim> grid (coarse_grid);
 *
 *   for (...) 
 *     {
 *                           // restore grid from coarse grid
 *                           // and stored refinement flags
 *       grid.restore ();
 *       ...                 // do something with the grid
 *
 *       ...                 // flag some cells for refinement
 *                           // or coarsening
 *       grid.execute_coarsening_and_refinement ();
 *                           // actually refine grid and store
 *                           // the flags
 *
 *       ...                 // so something more with the grid
 *
 *       grid.clear ();      // delete the grid, but keep the
 *                           // refinement flags for later use
 *                           // in grid.restore() above
 *
 *       ...                 // do something where the grid
 *                           // is not needed anymore, e.g.
 *                           // working with another grid
 *     };
 * 

Note that initially, the PersistentTriangulation object does not constitute a triangulation; it only becomes one after restore is first called. Note also that the execute_coarsening_and_refinement stores all necessary flags for later reconstruction using the restore function. Triangulation::clear() resets the underlying triangulation to a virgin state, but does not affect the stored refinement flags needed for later reconstruction and does also not touch the coarse grid which is used within restore().

Author:
Wolfgang Bangerth, 1999

Constructor & Destructor Documentation

template<int dim>
PersistentTriangulation< dim >::PersistentTriangulation ( const Triangulation< dim > &  coarse_grid  ) 

Build up the triangulation from the coarse grid in future. Copy smoothing flags, etc from that grid as well. Note that the initial state of the triangulation is empty, until restore_grid is called for the first time.

The coarse grid must persist until the end of this object, since it will be used upon reconstruction of the grid.

template<int dim>
PersistentTriangulation< dim >::PersistentTriangulation ( const PersistentTriangulation< dim > &  old_tria  ) 

Copy constructor. This operation is only allowed, if the triangulation underlying the object to be copied is presently empty. Refinement flags as well as the pointer to the coarse grid are copied, however.

template<int dim>
virtual PersistentTriangulation< dim >::~PersistentTriangulation (  )  [virtual]

Destructor.


Member Function Documentation

template<int dim>
virtual void PersistentTriangulation< dim >::execute_coarsening_and_refinement (  )  [virtual]

Overloaded version of the same function in the base class which stores the refinement and coarsening flags for later reconstruction of the triangulation and after that calls the respective function of the base class.

Reimplemented from Triangulation< dim >.

template<int dim>
void PersistentTriangulation< dim >::restore (  ) 

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 the clear() function of the base class was called on it before.

Repeatedly calls the restore(unsigned int) function in a loop over all refinement steps.

template<int dim>
void PersistentTriangulation< dim >::restore ( const unsigned int  step_no  ) 

Differential restore. Performs the step_noth local refinement and coarsening step. Step 0 stands for the copying of the coarse grid.

This function will only succeed if the triangulation is in just the state it were if restore would have been called from step=0...step_no-1 before.

template<int dim>
unsigned int PersistentTriangulation< dim >::n_refinement_steps (  )  const

Returns the number of refinement and coarsening steps. This is given by the size of the refine_flags vector.

template<int dim>
virtual void PersistentTriangulation< dim >::copy_triangulation ( const Triangulation< dim > &  tria  )  [virtual]

Overload this function to use tria as a new coarse grid. The present triangulation and all refinement and coarsening flags storing its history are deleted, and the state of the underlying triangulation is reset to be empty, until restore_grid is called the next time.

The coarse grid must persist until the end of this object, since it will be used upon reconstruction of the grid.

template<int dim>
virtual void PersistentTriangulation< dim >::create_triangulation ( const std::vector< Point< dim > > &  vertices,
const std::vector< CellData< dim > > &  cells,
const SubCellData subcelldata 
) [virtual]

Throw an error, since this function is not useful in the context of this class.

Reimplemented from Triangulation< dim >.

template<int dim>
virtual void PersistentTriangulation< dim >::create_triangulation_compatibility ( const std::vector< Point< dim > > &  vertices,
const std::vector< CellData< dim > > &  cells,
const SubCellData subcelldata 
) [virtual]

An overload of the respective function of the base class.

Throw an error, since this function is not useful in the context of this class.

Reimplemented from Triangulation< dim >.

template<int dim>
virtual void PersistentTriangulation< dim >::write_flags ( std::ostream &  out  )  const [virtual]

Writes all refine and coarsen flags to the ostream out.

template<int dim>
virtual void PersistentTriangulation< dim >::read_flags ( std::istream &  in  )  [virtual]

Reads all refine and coarsen flags that previously were written by write_flags(...). This is especially useful for rebuilding the triangulation after the end or breakdown of a program and its restart.

template<int dim>
virtual void PersistentTriangulation< dim >::clear_flags (  )  [virtual]

Clears all flags. Retains the same coarse grid.

template<int dim>
virtual unsigned int PersistentTriangulation< dim >::memory_consumption (  )  const [virtual]

Determine an estimate for the memory consumption (in bytes) of this object.

Reimplemented from Triangulation< dim >.


Member Data Documentation

template<int dim>
const unsigned int PersistentTriangulation< dim >::dimension = dim [static]

Make the dimension available in function templates.

Reimplemented from Triangulation< dim >.

template<int dim>
SmartPointer<const Triangulation<dim> > PersistentTriangulation< dim >::coarse_grid [private]

This grid shall be used as coarse grid.

template<int dim>
std::vector<std::vector<bool> > PersistentTriangulation< dim >::refine_flags [private]

Vectors holding the refinement and coarsening flags of the different sweeps on this time level. The vectors therefore hold the history of the grid.

template<int dim>
std::vector<std::vector<bool> > PersistentTriangulation< dim >::coarsen_flags [private]


The documentation for this class was generated from the following file:

deal.II documentation generated on Sat Aug 15 16:52:11 2009 by doxygen 1.5.9