COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Public Member Functions | Private Attributes | List of all members
MeshAdaptor Class Reference

Class to adapt the mesh. More...

#include <MeshAdaptor.hpp>

Public Member Functions

 MeshAdaptor (mesh::Mesh &mesh)
 Constructor. More...
 
virtual ~MeshAdaptor ()
 Destructor. More...
 
void prepare ()
 Prepare the mesh adaptor for changes. More...
 
void finish ()
 Apply the changes the mesh adaptor for changes and fix inconsistent state. More...
 
Elementary operations, should not be called usually
void add_element (const PackedElement &packed_element)
 Add element to the mesh. More...
 
void remove_element (const PackedElement &packed_element)
 Remove element from the mesh. More...
 
void remove_element (const Uint entities_idx, const Uint elem_loc_idx)
 Remove element from the mesh. More...
 
void flush_elements ()
 Apply all changes to elements. More...
 
void add_node (const PackedNode &packed_node)
 Add node from the mesh. More...
 
void remove_node (const PackedNode &packed_node)
 Remove node from the mesh. More...
 
void remove_node (const Uint dict_idx, const Uint node_loc_idx)
 Remove node from the mesh. More...
 
void flush_nodes ()
 Apply all changes to nodes. More...
 
Fine Level functions, should not be called usually
void create_element_buffers ()
 Creates buffers for element changes. More...
 
void create_node_buffers ()
 Creates buffers for node changes. More...
 
void clear_element_buffers ()
 Creates buffers for element changes. More...
 
void clear_node_buffers ()
 Creates buffers for node changes. More...
 
void make_element_node_connectivity_global ()
 Element-node connectivity is replaced with global indices. More...
 
void restore_element_node_connectivity ()
 Element-node connectivity is restored with local indices. More...
 
void rebuild_node_glb_to_loc_map ()
 rebuild dictionary.glb_to_loc() map with flushed nodes included More...
 
void rebuild_node_to_element_connectivity ()
 rebuild dictionary.connectivity() map with flushed nodes and elements included More...
 
High-level API
void move_elements (const std::vector< std::vector< std::vector< Uint > > > &exported_elements_loc_id)
 Move elements and attached nodes between processors, according to an elements_changeset. More...
 
void grow_overlap ()
 Create an additional cell-layer of overlap between pid's. More...
 
void combine_mesh (const Mesh &other_mesh)
 Add another mesh to this mesh. More...
 
void remove_duplicate_elements_and_nodes ()
 Add another mesh to this mesh. More...
 
Low-level API
void find_nodes_to_export (const std::vector< std::vector< std::vector< Uint > > > &exported_elements_loc_id, std::vector< std::vector< std::vector< Uint > > > &exported_nodes_loc_id)
 Assemble a change-set of nodes to be sent together with elements. More...
 
void send_elements (const std::vector< std::vector< std::vector< Uint > > > &exported_elements_loc_id, std::vector< std::vector< std::vector< boost::uint64_t > > > &imported_elements_glb_id)
 Send/Receive elements according to an elements-changeset. More...
 
void send_nodes (const std::vector< std::vector< std::vector< Uint > > > &exported_nodes_loc_id, std::vector< std::vector< std::vector< boost::uint64_t > > > &imported_nodes_glb_id)
 Send/Receive nodes according to an nodes-changeset. More...
 
void fix_node_ranks ()
 Correct ranks of nodes to be unique in all pid's. More...
 
void assign_global_numbering_and_rank_to_unknown_elems ()
 Exactly what it says new elements have a rank and glb_idx to be Uint::max or std::numeric_limits<boost::uint64_t>::max() More...
 
void remove_ghost_nodes ()
 remove ghost nodes More...
 
void remove_ghost_elements ()
 remove ghost elements More...
 
void assign_partition_agnostic_global_indices_to_dict (Dictionary &dict)
 

Private Attributes

Handle< Meshm_mesh
 Handle to the mesh. More...
 
bool is_node_connectivity_global
 boolean that says if mesh has element-node connectivities with global node-indices More...
 
std::vector< boost::shared_ptr< common::List< Uint >::Buffer > > element_glb_idx
 Element buffers for global index. More...
 
std::vector< boost::shared_ptr< common::List< Uint >::Buffer > > element_rank
 Element buffers for rank. More...
 
std::vector< std::vector< boost::shared_ptr< common::Table< Uint >::Buffer > > > element_connected_nodes
 Element buffers for element-node connectivity. More...
 
std::vector< boost::shared_ptr< common::List< Uint >::Buffer > > node_glb_idx
 Node buffers for global index. More...
 
std::vector< boost::shared_ptr< common::List< Uint >::Buffer > > node_rank
 Node buffers for rank. More...
 
std::vector< std::vector< boost::shared_ptr< common::Table< Real >::Buffer > > > node_field_values
 Node buffers for field values. More...
 
bool node_glb_to_loc_needs_rebuild
 flag if dictionary.glb_to_loc() must be rebuilt More...
 
bool node_elem_connectivity_needs_rebuild
 flag if dictionary.connectivity() must be rebuilt More...
 
bool elem_flush_required
 flag if there are still elements that need to be flush More...
 
bool node_flush_required
 flag if there are still nodes that need to be flush More...
 
std::vector< std::set< boost::uint64_t > > added_elements
 bookkeeping of added and removed elements More...
 
std::vector< std::set< boost::uint64_t > > added_nodes
 bookkeeping of added and removed nodes More...
 
bool has_element_buffers
 
bool has_node_buffers
 

Detailed Description

Class to adapt the mesh.

First call prepare(). This puts mesh in inconsistent state, but allows it to be changed more easily. Then indicate all the changes with functions like

Definition at line 45 of file MeshAdaptor.hpp.

Constructor & Destructor Documentation

MeshAdaptor ( mesh::Mesh mesh)

Constructor.

Definition at line 171 of file MeshAdaptor.cpp.

~MeshAdaptor ( )
virtual

Destructor.

Definition at line 186 of file MeshAdaptor.cpp.

Member Function Documentation

void add_element ( const PackedElement packed_element)

Add element to the mesh.

Note
Changes are only applied after flush_elements() or finish() is called
Precondition
make_element_node_connectivity_global() must be called
create_element_buffers() must have been called before

Definition at line 372 of file MeshAdaptor.cpp.

void add_node ( const PackedNode packed_node)

Add node from the mesh.

Note
Changes are only applied after flush_nodes() or finish() is called
Precondition
make_element_node_connectivity_global() must be called
create_node_buffers() must have been called before

Definition at line 421 of file MeshAdaptor.cpp.

void assign_global_numbering_and_rank_to_unknown_elems ( )

Exactly what it says new elements have a rank and glb_idx to be Uint::max or std::numeric_limits<boost::uint64_t>::max()

Definition at line 1803 of file MeshAdaptor.cpp.

void assign_partition_agnostic_global_indices_to_dict ( Dictionary dict)

Nodes found on pid 0 will be numbered from 0 to nb_nodes(pid0) NEW nodes found on pid 1 will be numbered from nb_nodes(pid0) to nb_nodes(pid0+pid1) NEW nodes found on pid 2 will be numbered from nb_nodes(pid0+pid1) to nb_nodes(pid0+pid1+pid2) ... Any ownership is not claimed! It is still possible that a node with glb_idx between nb_nodes(pid0) and nb_nodes(pid0+pid1) is owned by pid0 or pid1 or pid2. Only when a call to fix_node_ranks() is done, will ownership be claimed by the proc that found the node, with the lowest pid.

Definition at line 1696 of file MeshAdaptor.cpp.

void clear_element_buffers ( )

Creates buffers for element changes.

Definition at line 247 of file MeshAdaptor.cpp.

void clear_node_buffers ( )

Creates buffers for node changes.

Definition at line 292 of file MeshAdaptor.cpp.

void combine_mesh ( const Mesh other_mesh)

Add another mesh to this mesh.

Definition at line 1330 of file MeshAdaptor.cpp.

void create_element_buffers ( )

Creates buffers for element changes.

Definition at line 222 of file MeshAdaptor.cpp.

void create_node_buffers ( )

Creates buffers for node changes.

Definition at line 267 of file MeshAdaptor.cpp.

void find_nodes_to_export ( const std::vector< std::vector< std::vector< Uint > > > &  exported_elements_loc_id,
std::vector< std::vector< std::vector< Uint > > > &  exported_nodes_loc_id 
)

Assemble a change-set of nodes to be sent together with elements.

Parameters
[in]exported_elements_loc_idA set with 3 indices: send_element[to_pid][from_entities_idx][local_elem_idx]
[out]exported_nodes_loc_idA set with 3 indices: send_node[to_pid][from_dict_idx][local_node_idx]

Definition at line 549 of file MeshAdaptor.cpp.

void finish ( )

Apply the changes the mesh adaptor for changes and fix inconsistent state.

Postcondition
Mesh is back in consistent state!

Definition at line 205 of file MeshAdaptor.cpp.

void fix_node_ranks ( )

Correct ranks of nodes to be unique in all pid's.

Definition at line 1044 of file MeshAdaptor.cpp.

void flush_elements ( )

Apply all changes to elements.

Definition at line 467 of file MeshAdaptor.cpp.

void flush_nodes ( )

Apply all changes to nodes.

Definition at line 492 of file MeshAdaptor.cpp.

void grow_overlap ( )

Create an additional cell-layer of overlap between pid's.

Postcondition
nodes and elements are flushed, and node-ranks are uniquely defined in all pid's. Call finish() to notify the mesh of updates.

Definition at line 1178 of file MeshAdaptor.cpp.

void make_element_node_connectivity_global ( )

Element-node connectivity is replaced with global indices.

This is to allow elements from other ranks to be added, in which case local indices are meaningless

Postcondition
Mesh is in inconsistent state! Call restore_element_node_connectivity() to fix it, after element modifications are done.

Definition at line 312 of file MeshAdaptor.cpp.

void move_elements ( const std::vector< std::vector< std::vector< Uint > > > &  exported_elements_loc_id)

Move elements and attached nodes between processors, according to an elements_changeset.

Parameters
[in]exported_elements_loc_idA set with 3 indices: move_element[to_pid][from_entities_idx][local_elem_idx]
Postcondition
nodes and elements are flushed, and node-ranks are uniquely defined in all pid's. Call finish() to notify the mesh of updates.

Definition at line 844 of file MeshAdaptor.cpp.

void prepare ( )

Prepare the mesh adaptor for changes.

Prepare the mesh adaptor for changes to add/remove nodes and elements The element-node connectivity tables are replaced with global node indices instead of local indices, so that elements from other processes can be added.

Note
All changes that are given (remove_node(), add_element(), ...) are not applied until finish() or flush_nodes() and/or flush_elements() is called.
Postcondition
Mesh is in inconsistent state after this! Call finish() to fix it, after modifications

Definition at line 192 of file MeshAdaptor.cpp.

void rebuild_node_glb_to_loc_map ( )

rebuild dictionary.glb_to_loc() map with flushed nodes included

Definition at line 811 of file MeshAdaptor.cpp.

void rebuild_node_to_element_connectivity ( )

rebuild dictionary.connectivity() map with flushed nodes and elements included

Definition at line 827 of file MeshAdaptor.cpp.

void remove_duplicate_elements_and_nodes ( )

Add another mesh to this mesh.

Definition at line 1537 of file MeshAdaptor.cpp.

void remove_element ( const PackedElement packed_element)

Remove element from the mesh.

Note
Changes are only applied after flush_elements() or finish() is called
Precondition
create_element_buffers() must have been called before

Definition at line 395 of file MeshAdaptor.cpp.

void remove_element ( const Uint  entities_idx,
const Uint  elem_loc_idx 
)

Remove element from the mesh.

Note
Changes are only applied after flush_elements() or finish() is called
Precondition
create_element_buffers() must have been called before

Definition at line 402 of file MeshAdaptor.cpp.

void remove_ghost_elements ( )

remove ghost elements

Postcondition
Elements are not flushed yet, so additional operations can be performed

Definition at line 518 of file MeshAdaptor.cpp.

void remove_ghost_nodes ( )

remove ghost nodes

Postcondition
Nodes are not flushed yet, so additional operations can be performed

Definition at line 534 of file MeshAdaptor.cpp.

void remove_node ( const PackedNode packed_node)

Remove node from the mesh.

Note
Changes are only applied after flush_nodes() or finish() is called
Precondition
create_node_buffers() must have been called before

Definition at line 444 of file MeshAdaptor.cpp.

void remove_node ( const Uint  dict_idx,
const Uint  node_loc_idx 
)

Remove node from the mesh.

Note
Changes are only applied after flush_nodes() or finish() is called
Precondition
create_node_buffers() must have been called before

Definition at line 451 of file MeshAdaptor.cpp.

void restore_element_node_connectivity ( )

Element-node connectivity is restored with local indices.

Postcondition
Mesh is in inconsistent state! Call restore_element_node_connectivity() to fix it, after element modifications are done.

Definition at line 341 of file MeshAdaptor.cpp.

void send_elements ( const std::vector< std::vector< std::vector< Uint > > > &  exported_elements_loc_id,
std::vector< std::vector< std::vector< boost::uint64_t > > > &  imported_elements_glb_id 
)

Send/Receive elements according to an elements-changeset.

Parameters
[in]exported_elements_loc_idA set with 3 indices: send_element[to_pid][from_entities_idx][local_elem_idx]
[out]imported_elements_glb_idA set with 3 indices: received_element[from_pid][from_entities_idx][glb_elem_idx]
Postcondition
Elements are not flushed yet, so additional operations can be performed

Definition at line 620 of file MeshAdaptor.cpp.

void send_nodes ( const std::vector< std::vector< std::vector< Uint > > > &  exported_nodes_loc_id,
std::vector< std::vector< std::vector< boost::uint64_t > > > &  imported_nodes_glb_id 
)

Send/Receive nodes according to an nodes-changeset.

Parameters
[in]exported_nodes_loc_idA set with 3 indices: send_node[to_pid][from_dict_idx][local_node_idx]
[out]imported_nodes_glb_idA set with 3 indices: received_node[from_pid][from_dict_idx][glb_node_idx]
Postcondition
Nodes are not flushed yet, so additional operations can be performed

Definition at line 726 of file MeshAdaptor.cpp.

Member Data Documentation

std::vector< std::set<boost::uint64_t> > added_elements
private

bookkeeping of added and removed elements

Definition at line 256 of file MeshAdaptor.hpp.

std::vector< std::set<boost::uint64_t> > added_nodes
private

bookkeeping of added and removed nodes

Definition at line 259 of file MeshAdaptor.hpp.

bool elem_flush_required
private

flag if there are still elements that need to be flush

Definition at line 250 of file MeshAdaptor.hpp.

std::vector< std::vector< boost::shared_ptr<common::Table<Uint>::Buffer> > > element_connected_nodes
private

Element buffers for element-node connectivity.

Definition at line 232 of file MeshAdaptor.hpp.

std::vector< boost::shared_ptr<common::List<Uint>::Buffer> > element_glb_idx
private

Element buffers for global index.

Definition at line 226 of file MeshAdaptor.hpp.

std::vector< boost::shared_ptr<common::List<Uint>::Buffer> > element_rank
private

Element buffers for rank.

Definition at line 229 of file MeshAdaptor.hpp.

bool has_element_buffers
private

Definition at line 261 of file MeshAdaptor.hpp.

bool has_node_buffers
private

Definition at line 263 of file MeshAdaptor.hpp.

bool is_node_connectivity_global
private

boolean that says if mesh has element-node connectivities with global node-indices

Definition at line 223 of file MeshAdaptor.hpp.

Handle<Mesh> m_mesh
private

Handle to the mesh.

Definition at line 220 of file MeshAdaptor.hpp.

bool node_elem_connectivity_needs_rebuild
private

flag if dictionary.connectivity() must be rebuilt

Definition at line 247 of file MeshAdaptor.hpp.

std::vector< std::vector< boost::shared_ptr<common::Table<Real>::Buffer> > > node_field_values
private

Node buffers for field values.

Definition at line 241 of file MeshAdaptor.hpp.

bool node_flush_required
private

flag if there are still nodes that need to be flush

Definition at line 253 of file MeshAdaptor.hpp.

std::vector< boost::shared_ptr<common::List<Uint>::Buffer> > node_glb_idx
private

Node buffers for global index.

Definition at line 235 of file MeshAdaptor.hpp.

bool node_glb_to_loc_needs_rebuild
private

flag if dictionary.glb_to_loc() must be rebuilt

Definition at line 244 of file MeshAdaptor.hpp.

std::vector< boost::shared_ptr<common::List<Uint>::Buffer> > node_rank
private

Node buffers for rank.

Definition at line 238 of file MeshAdaptor.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin