Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
parallel::distributed::Triangulation< dim, spacedim > Class Template Reference
Inheritance diagram for parallel::distributed::Triangulation< dim, spacedim >:
Inheritance graph
[legend]

List of all members.

Classes

struct  NumberCache

Public Types

enum  CellStatus { CELL_PERSIST, CELL_REFINE, CELL_COARSEN, CELL_INVALID }
typedef ::Triangulation< dim,
spacedim >
::active_cell_iterator 
active_cell_iterator
typedef ::Triangulation< dim,
spacedim >::cell_iterator 
cell_iterator
typedef ::Triangulation< dim,
spacedim >::raw_cell_iterator 
raw_cell_iterator

Public Member Functions

 Triangulation (MPI_Comm mpi_communicator, const typename::Triangulation< dim, spacedim >::MeshSmoothing smooth_grid=(::Triangulation< dim, spacedim >::none))
virtual ~Triangulation ()
virtual void clear ()
virtual void copy_triangulation (const ::Triangulation< dim, spacedim > &old_tria)
virtual void create_triangulation (const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
virtual void execute_coarsening_and_refinement ()
types::subdomain_id_t locally_owned_subdomain () const
unsigned int n_locally_owned_active_cells () const
unsigned int n_global_active_cells () const
const std::vector< unsigned int > & n_locally_owned_active_cells_per_processor () const
MPI_Comm get_communicator () const
virtual unsigned int memory_consumption () const
virtual unsigned int memory_consumption_p4est () const
void write_mesh_vtk (const char *file_basename) const
unsigned int get_checksum () const
unsigned int register_data_attach (const size_t size, const std_cxx1x::function< void(const cell_iterator &, const CellStatus, void *)> &pack_callback)
void notify_ready_to_unpack (const unsigned int offset, const std_cxx1x::function< void(const cell_iterator &, const CellStatus, const void *)> &unpack_callback)

Private Types

typedef std_cxx1x::function
< void(typename Triangulation
< dim, spacedim >
::cell_iterator, CellStatus,
void *) 
pack_callback_t )
typedef std::pair< unsigned
int, pack_callback_t > 
callback_pair_t
typedef std::list
< callback_pair_t > 
callback_list_t

Private Member Functions

typename::internal::p4est::types
< dim >::tree * 
init_tree (const int dealii_coarse_cell_index) const
void setup_coarse_cell_to_p4est_tree_permutation ()
void copy_new_triangulation_to_p4est (::internal::int2type< 2 >)
void copy_new_triangulation_to_p4est (::internal::int2type< 3 >)
void copy_local_forest_to_triangulation ()
void update_number_cache ()
void attach_mesh_data ()

Private Attributes

MPI_Comm mpi_communicator
types::subdomain_id_t my_subdomain
bool triangulation_has_content
NumberCache number_cache
typename::internal::p4est::types
< dim >::connectivity * 
connectivity
typename::internal::p4est::types
< dim >::forest * 
parallel_forest
bool refinement_in_progress
unsigned int attached_data_size
unsigned int n_attached_datas
callback_list_t attached_data_pack_callbacks
std::vector< unsigned int > coarse_cell_to_p4est_tree_permutation
std::vector< unsigned int > p4est_tree_to_coarse_cell_permutation

Friends

class ::internal::DoFHandler::Policy::ParallelDistributed

Detailed Description

template<int dim, int spacedim = dim>
class parallel::distributed::Triangulation< dim, spacedim >

This class acts like the Triangulation class, but it distributes the mesh across a number of different processors when using MPI. The class's interface does not add a lot to the Triangulation class but there are a number of difficult algorithms under the hood that ensure we always have a load-balanced, fully distributed mesh. Use of this class is explained in step-40, step-32, the Parallel computing with multiple processors using distributed memory documentation module, as well as the distributed_paper . See there for more information.

Note:
This class does not support anisotropic refinement, because it relies on the p4est library that does not support this. Attempts to refine cells anisotropically will result in errors.
Author:
Wolfgang Bangerth, Timo Heister 2008, 2009, 2010

Member Typedef Documentation

template<int dim, int spacedim = dim>
typedef ::Triangulation<dim,spacedim>::active_cell_iterator parallel::distributed::Triangulation< dim, spacedim >::active_cell_iterator

Import the various iterator typedefs from the base class.

Reimplemented from Triangulation< dim, spacedim >.

template<int dim, int spacedim = dim>
typedef ::Triangulation<dim,spacedim>::cell_iterator parallel::distributed::Triangulation< dim, spacedim >::cell_iterator

Reimplemented from Triangulation< dim, spacedim >.

template<int dim, int spacedim = dim>
typedef ::Triangulation<dim,spacedim>::raw_cell_iterator parallel::distributed::Triangulation< dim, spacedim >::raw_cell_iterator

Reimplemented from Triangulation< dim, spacedim >.

template<int dim, int spacedim = dim>
typedef std_cxx1x::function< void(typename Triangulation<dim,spacedim>::cell_iterator, CellStatus, void*) parallel::distributed::Triangulation< dim, spacedim >::pack_callback_t) [private]
template<int dim, int spacedim = dim>
typedef std::pair<unsigned int, pack_callback_t> parallel::distributed::Triangulation< dim, spacedim >::callback_pair_t [private]
template<int dim, int spacedim = dim>
typedef std::list<callback_pair_t> parallel::distributed::Triangulation< dim, spacedim >::callback_list_t [private]

Member Enumeration Documentation

template<int dim, int spacedim = dim>
enum parallel::distributed::Triangulation::CellStatus

Used to inform in the callbacks of register_data_attach() and notify_ready_to_unpack() how the cell with the given cell_iterator is going to change. Note that this may me different then the refine_flag() and coarsen_flag() in the cell_iterator because of refinement constraints that this machine does not see.

Enumerator:
CELL_PERSIST 
CELL_REFINE 
CELL_COARSEN 
CELL_INVALID 

Constructor & Destructor Documentation

template<int dim, int spacedim = dim>
parallel::distributed::Triangulation< dim, spacedim >::Triangulation ( MPI_Comm  mpi_communicator,
const typename::Triangulation< dim, spacedim >::MeshSmoothing  smooth_grid = (::Triangulation< dim, spacedim >::none) 
)

Constructor.

Parameters:
mpi_communicatordenotes the MPI communicator to be used for the triangulation.
smooth_gridDegree and kind of mesh smoothing to be applied to the mesh. See the Triangulation class for a description of the kinds of smoothing operations that can be applied.
Note:
This class does not currently support the check_for_distorted_cells argument provided by the base class.
template<int dim, int spacedim = dim>
virtual parallel::distributed::Triangulation< dim, spacedim >::~Triangulation ( ) [virtual]

Destructor.

Reimplemented from Triangulation< dim, spacedim >.


Member Function Documentation

template<int dim, int spacedim = dim>
virtual void parallel::distributed::Triangulation< dim, spacedim >::clear ( ) [virtual]

Reset this triangulation into a virgin state by deleting all data.

Note that this operation is only allowed if no subscriptions to this object exist any more, such as DoFHandler objects using it.

Reimplemented from Triangulation< dim, spacedim >.

template<int dim, int spacedim = dim>
virtual void parallel::distributed::Triangulation< dim, spacedim >::copy_triangulation ( const ::Triangulation< dim, spacedim > &  old_tria) [virtual]

Implementation of the same function as in the base class.

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

Create a triangulation as documented in the base class.

This function also sets up the various data structures necessary to distribute a mesh across a number of processors. This will be necessary once the mesh is being refined, though we will always keep the entire coarse mesh that is generated by this function on all processors.

Reimplemented from Triangulation< dim, spacedim >.

template<int dim, int spacedim = dim>
virtual void parallel::distributed::Triangulation< dim, spacedim >::execute_coarsening_and_refinement ( ) [virtual]

Coarsen and refine the mesh according to refinement and coarsening flags set.

Since the current processor only has control over those cells it owns (i.e. the ones for which cell->subdomain_id() == this->locally_owned_subdomain()), refinement and coarsening flags are only respected for those locally owned cells. Flags may be set on other cells as well (and may often, in fact, if you call Triangulation::prepare_coarsening_and_refinement) but will be largely ignored: the decision to refine the global mesh will only be affected by flags set on locally owned cells.

Reimplemented from Triangulation< dim, spacedim >.

template<int dim, int spacedim = dim>
types::subdomain_id_t parallel::distributed::Triangulation< dim, spacedim >::locally_owned_subdomain ( ) const

Return the subdomain id of those cells that are owned by the current processor. All cells in the triangulation that do not have this subdomain id are either owned by another processor or have children that only exist on other processors.

template<int dim, int spacedim = dim>
unsigned int parallel::distributed::Triangulation< dim, spacedim >::n_locally_owned_active_cells ( ) const

Return the number of active cells in the triangulation that are locally owned, i.e. that have a subdomain_id equal to locally_owned_subdomain(). Note that there may be more active cells in the triangulation stored on the present processor, such as for example ghost cells, or cells further away from the locally owned block of cells but that are needed to ensure that the triangulation that stores this processor's set of active cells still remains balanced with respect to the 2:1 size ratio of adjacent cells.

As a consequence of the remark above, the result of this function is always smaller or equal to the result of Triangulation::n_active_cells() which includes the active ghost and artificial cells (see also GlossArtificialCell and GlossGhostCell).

template<int dim, int spacedim = dim>
unsigned int parallel::distributed::Triangulation< dim, spacedim >::n_global_active_cells ( ) const

Return the sum over all processors of the number of active cells owned by each processor. This equals the overall number of active cells in the distributed triangulation.

template<int dim, int spacedim = dim>
const std::vector<unsigned int>& parallel::distributed::Triangulation< dim, spacedim >::n_locally_owned_active_cells_per_processor ( ) const

Return the number of active cells owned by each of the MPI processes that contribute to this triangulation. The element of this vector indexed by locally_owned_subdomain() equals the result of n_locally_owned_active_cells().

template<int dim, int spacedim = dim>
MPI_Comm parallel::distributed::Triangulation< dim, spacedim >::get_communicator ( ) const

Return the MPI communicator used by this triangulation.

template<int dim, int spacedim = dim>
virtual unsigned int parallel::distributed::Triangulation< dim, spacedim >::memory_consumption ( ) const [virtual]

Return the local memory consumption in bytes.

Reimplemented from Triangulation< dim, spacedim >.

template<int dim, int spacedim = dim>
virtual unsigned int parallel::distributed::Triangulation< dim, spacedim >::memory_consumption_p4est ( ) const [virtual]

Return the local memory consumption contained in the p4est data structures alone. This is already contained in memory_consumption() but made available separately for debugging purposes.

template<int dim, int spacedim = dim>
void parallel::distributed::Triangulation< dim, spacedim >::write_mesh_vtk ( const char *  file_basename) const

A collective operation that produces a sequence of output files with the given file base name that contain the mesh in VTK format.

More than anything else, this function is useful for debugging the interface between deal.II and p4est.

template<int dim, int spacedim = dim>
unsigned int parallel::distributed::Triangulation< dim, spacedim >::get_checksum ( ) const

Produce a check sum of the triangulation. This is a collective operation and is mostly useful for debugging purposes.

template<int dim, int spacedim = dim>
unsigned int parallel::distributed::Triangulation< dim, spacedim >::register_data_attach ( const size_t  size,
const std_cxx1x::function< void(const cell_iterator &, const CellStatus, void *)> &  pack_callback 
)

Register a function with the current Triangulation object that will be used to attach data to active cells before execute_coarsening_and_refinement(). In execute_coarsening_and_refinement() the Triangulation will call the given function pointer and provide size bytes to store data. If necessary, this data will be transferred to the new owner of that cell during repartitioning the tree. See notify_ready_to_unpack() on how to retrieve the data.

Callers need to store the return value. It specifies an offset of the position at which data can later be retrieved during a call to notify_ready_to_unpack().

template<int dim, int spacedim = dim>
void parallel::distributed::Triangulation< dim, spacedim >::notify_ready_to_unpack ( const unsigned int  offset,
const std_cxx1x::function< void(const cell_iterator &, const CellStatus, const void *)> &  unpack_callback 
)

The given function is called for each new active cell and supplies a pointer to the data saved with register_data_attach().

template<int dim, int spacedim = dim>
typename ::internal::p4est::types<dim>::tree* parallel::distributed::Triangulation< dim, spacedim >::init_tree ( const int  dealii_coarse_cell_index) const [private]

Return a pointer to the p4est tree that belongs to the given dealii_coarse_cell_index()

template<int dim, int spacedim = dim>
void parallel::distributed::Triangulation< dim, spacedim >::setup_coarse_cell_to_p4est_tree_permutation ( ) [private]

The function that computes the permutation between the two data storage schemes.

template<int dim, int spacedim = dim>
void parallel::distributed::Triangulation< dim, spacedim >::copy_new_triangulation_to_p4est ( ::internal::int2type< 2 >  ) [private]

Take the contents of a newly created triangulation we are attached to and copy it to p4est data structures.

This function exists in 2d and 3d variants.

template<int dim, int spacedim = dim>
void parallel::distributed::Triangulation< dim, spacedim >::copy_new_triangulation_to_p4est ( ::internal::int2type< 3 >  ) [private]
template<int dim, int spacedim = dim>
void parallel::distributed::Triangulation< dim, spacedim >::copy_local_forest_to_triangulation ( ) [private]

Copy the local part of the refined forest from p4est into the attached triangulation.

template<int dim, int spacedim = dim>
void parallel::distributed::Triangulation< dim, spacedim >::update_number_cache ( ) [private]

Update the number_cache variable after mesh creation or refinement.

template<int dim, int spacedim = dim>
void parallel::distributed::Triangulation< dim, spacedim >::attach_mesh_data ( ) [private]

Internal function notifying all registered classes to attach their data before repartitioning occurs. Called from execute_coarsening_and_refinement().


Friends And Related Function Documentation

template<int dim, int spacedim = dim>
friend class ::internal::DoFHandler::Policy::ParallelDistributed [friend]

Member Data Documentation

template<int dim, int spacedim = dim>
MPI_Comm parallel::distributed::Triangulation< dim, spacedim >::mpi_communicator [private]

MPI communicator to be used for the triangulation. We create a unique communicator for this class, which is a duplicate of the one passed to the constructor.

template<int dim, int spacedim = dim>
types::subdomain_id_t parallel::distributed::Triangulation< dim, spacedim >::my_subdomain [private]

The subdomain id to be used for the current processor.

template<int dim, int spacedim = dim>
bool parallel::distributed::Triangulation< dim, spacedim >::triangulation_has_content [private]

A flag that indicates whether the triangulation has actual content.

template<int dim, int spacedim = dim>
NumberCache parallel::distributed::Triangulation< dim, spacedim >::number_cache [private]

Cache to hold the numbers of lines, quads, hexes, etc. These numbers are set at the end of the refinement and coarsening functions and enable faster access later on. In the old days, whenever one wanted to access one of these numbers, one had to perform a loop over all lines, e.g., and count the elements until we hit the end iterator. This is time consuming and since access to the number of lines etc is a rather frequent operation, this was not an optimal solution.

Reimplemented from Triangulation< dim, spacedim >.

template<int dim, int spacedim = dim>
typename ::internal::p4est::types<dim>::connectivity* parallel::distributed::Triangulation< dim, spacedim >::connectivity [private]

A data structure that holds the connectivity between trees. Since each tree is rooted in a coarse grid cell, this data structure holds the connectivity between the cells of the coarse grid.

template<int dim, int spacedim = dim>
typename ::internal::p4est::types<dim>::forest* parallel::distributed::Triangulation< dim, spacedim >::parallel_forest [private]

A data structure that holds the local part of the global triangulation.

template<int dim, int spacedim = dim>
bool parallel::distributed::Triangulation< dim, spacedim >::refinement_in_progress [private]

A flag that indicates whether refinement of a triangulation is currently in progress. We need this flag because the refinement_notification() function is called from Triangulation::execute_coarsening_and_refinement(), but refinement_notification() itself also calls Triangulation::execute_coarsening_and_refinement() and therefore gets called recursively again. While the first time we want to take over work to copy things from a refined p4est, the other times we don't want to get in the way as these latter calls to Triangulation::execute_coarsening_and_refinement() are simply there in order to re-create a triangulation that matches the p4est.

template<int dim, int spacedim = dim>
unsigned int parallel::distributed::Triangulation< dim, spacedim >::attached_data_size [private]
template<int dim, int spacedim = dim>
unsigned int parallel::distributed::Triangulation< dim, spacedim >::n_attached_datas [private]
template<int dim, int spacedim = dim>
callback_list_t parallel::distributed::Triangulation< dim, spacedim >::attached_data_pack_callbacks [private]
template<int dim, int spacedim = dim>
std::vector<unsigned int> parallel::distributed::Triangulation< dim, spacedim >::coarse_cell_to_p4est_tree_permutation [private]

Two arrays that store which p4est tree corresponds to which coarse grid cell and vice versa. We need these arrays because p4est goes with the original order of coarse cells when it sets up its forest, and then applies the Morton ordering within each tree. But if coarse grid cells are badly ordered this may mean that individual parts of the forest stored on a local machine may be split across coarse grid cells that are not geometrically close. Consequently, we apply a Cuthill-McKee preordering to ensure that the part of the forest stored by p4est is located on geometrically close coarse grid cells.

template<int dim, int spacedim = dim>
std::vector<unsigned int> parallel::distributed::Triangulation< dim, spacedim >::p4est_tree_to_coarse_cell_permutation [private]

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

deal.II documentation generated on Fri Aug 12 2011 15:01:09 by doxygen 1.7.4