MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
mfem::ParNCMesh Class Reference

A parallel extension of the NCMesh class. More...

#include <pncmesh.hpp>

Inheritance diagram for mfem::ParNCMesh:
[legend]
Collaboration diagram for mfem::ParNCMesh:
[legend]

Classes

class  ElementSet
 
class  NeighborRefinementMessage
 

Public Member Functions

 ParNCMesh (MPI_Comm comm, const NCMesh &ncmesh)
 
virtual void Refine (const Array< Refinement > &refinements)
 
virtual void LimitNCLevel (int max_level)
 To be implemented. More...
 
const NCList & GetSharedVertices ()
 
const NCList & GetSharedEdges ()
 
const NCList & GetSharedFaces ()
 
const NCList & GetSharedList (int type)
 Helper to get shared vertices/edges/faces ('type' == 0/1/2 resp.). More...
 
int GetFaceOrientation (int index) const
 Return (shared) face orientation relative to the owner element. More...
 
int GetOwner (int type, int index) const
 Return vertex/edge/face ('type' == 0/1/2, resp.) owner. More...
 
const int * GetGroup (int type, int index, int &size) const
 
bool RankInGroup (int type, int index, int rank) const
 
bool IsGhost (int type, int index) const
 Returns true if the specified vertex/edge/face is a ghost. More...
 
virtual void GetBoundaryClosure (const Array< int > &bdr_attr_is_ess, Array< int > &bdr_vertices, Array< int > &bdr_edges)
 
void GetDebugMesh (Mesh &debug_mesh) const
 
- Public Member Functions inherited from mfem::NCMesh
 NCMesh (const Mesh *mesh, std::istream *vertex_parents=NULL)
 
 NCMesh (const NCMesh &other)
 Deep copy of 'other'. More...
 
int Dimension () const
 
int SpaceDimension () const
 
const NCListGetFaceList ()
 Return the current list of conforming and nonconforming faces. More...
 
const NCListGetEdgeList ()
 Return the current list of conforming and nonconforming edges. More...
 
void MarkCoarseLevel ()
 
void ClearCoarseLevel ()
 Free the internally stored array of coarse leaf elements. More...
 
FineTransformGetFineTransforms ()
 
int GetEdgeMaster (int v1, int v2) const
 
void PrintVertexParents (std::ostream &out) const
 I/O: Print the "vertex_parents" section of the mesh file (ver. >= 1.1). More...
 
void PrintCoarseElements (std::ostream &out) const
 I/O: Print the "coarse_elements" section of the mesh file (ver. >= 1.1). More...
 
void LoadVertexParents (std::istream &input)
 
void LoadCoarseElements (std::istream &input)
 I/O: Load the element refinement hierarchy from a mesh file. More...
 
void SetVertexPositions (const Array< mfem::Vertex > &vertices)
 I/O: Set positions of all vertices (used by mesh loader). More...
 
long MemoryUsage () const
 Return total number of bytes allocated. More...
 
void PrintMemoryDetail () const
 
virtual ~NCMesh ()
 
void DebugNeighbors (Array< char > &elem_set)
 

Protected Member Functions

virtual void Update ()
 
int InitialPartition (int index) const
 Assigns elements to processors at the initial stage (ParMesh creation). More...
 
virtual void UpdateVertices ()
 update Vertex::index and vertex_nodeId More...
 
virtual void AssignLeafIndices ()
 
virtual bool IsGhost (const Element *elem) const
 
virtual int GetNumGhosts () const
 
virtual void OnMeshUpdated (Mesh *mesh)
 
virtual void BuildEdgeList ()
 
virtual void BuildFaceList ()
 
virtual void ElementSharesEdge (Element *elem, Edge *edge)
 
virtual void ElementSharesFace (Element *elem, Face *face)
 
void BuildSharedVertices ()
 
void CalcFaceOrientations ()
 
void UpdateLayers ()
 
void AddMasterSlaveRanks (int nitems, const NCList &list)
 
void MakeShared (const Table &groups, const NCList &list, NCList &shared)
 
void EncodeMeshIds (std::ostream &os, Array< MeshId > ids[], int dim) const
 Write to 'os' a processor-independent encoding of vertex/edge/face IDs. More...
 
void DecodeMeshIds (std::istream &is, Array< MeshId > ids[], int dim, bool decode_indices) const
 Read from 'is' a processor-independent encoding of vertex/edge/face IDs. More...
 
void ElementNeighborProcessors (Element *elem, Array< int > &ranks)
 
void NeighborProcessors (Array< int > &neighbors)
 
void Prune ()
 
bool PruneTree (Element *elem)
 Internal. Recursive part of Prune(). More...
 
- Protected Member Functions inherited from mfem::NCMesh
void GetMeshComponents (Array< mfem::Vertex > &vertices, Array< mfem::Element * > &elements, Array< mfem::Element * > &boundary) const
 Return the basic Mesh arrays for the current finest level. More...
 
ElementCopyHierarchy (Element *elem)
 
void DeleteHierarchy (Element *elem)
 
void CollectLeafElements (Element *elem)
 
void UpdateLeafElements ()
 
virtual bool IsGhost (const Element *elem) const
 
void RefineElement (Element *elem, char ref_type)
 
void DerefineElement (Element *elem)
 
ElementNewHexahedron (Node *n0, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5, Node *n6, Node *n7, int attr, int fattr0, int fattr1, int fattr2, int fattr3, int fattr4, int fattr5)
 
ElementNewQuadrilateral (Node *n0, Node *n1, Node *n2, Node *n3, int attr, int eattr0, int eattr1, int eattr2, int eattr3)
 
ElementNewTriangle (Node *n0, Node *n1, Node *n2, int attr, int eattr0, int eattr1, int eattr2)
 
VertexNewVertex (Node *v1, Node *v2)
 
NodeGetMidEdgeVertex (Node *v1, Node *v2)
 
NodeGetMidEdgeVertexSimple (Node *v1, Node *v2)
 
NodeGetMidFaceVertex (Node *e1, Node *e2, Node *e3, Node *e4)
 
int FaceSplitType (Node *v1, Node *v2, Node *v3, Node *v4, Node *mid[4]=NULL) const
 
void ForceRefinement (Node *v1, Node *v2, Node *v3, Node *v4)
 
void CheckAnisoFace (Node *v1, Node *v2, Node *v3, Node *v4, Node *mid12, Node *mid34, int level=0)
 
void CheckIsoFace (Node *v1, Node *v2, Node *v3, Node *v4, Node *e1, Node *e2, Node *e3, Node *e4, Node *midf)
 
void RefElementNodes (Element *elem)
 
void UnrefElementNodes (Element *elem)
 
void RegisterFaces (Element *elem, int *fattr=NULL)
 
NodePeekAltParents (Node *v1, Node *v2)
 
bool NodeSetX1 (Node *node, Node **n)
 
bool NodeSetX2 (Node *node, Node **n)
 
bool NodeSetY1 (Node *node, Node **n)
 
bool NodeSetY2 (Node *node, Node **n)
 
bool NodeSetZ1 (Node *node, Node **n)
 
bool NodeSetZ2 (Node *node, Node **n)
 
void ReorderFacePointMat (Node *v0, Node *v1, Node *v2, Node *v3, Element *elem, DenseMatrix &mat) const
 
void TraverseFace (Node *v0, Node *v1, Node *v2, Node *v3, const PointMatrix &pm, int level)
 
void TraverseEdge (Node *v0, Node *v1, double t0, double t1, int level)
 
virtual void ElementSharesEdge (Element *elem, Edge *edge)
 
virtual void ElementSharesFace (Element *elem, Face *face)
 
void FindSetNeighbors (const Array< char > &elem_set, Array< Element * > *neighbors, Array< char > *neighbor_set=NULL)
 
void FindNeighbors (const Element *elem, Array< Element * > &neighbors, const Array< Element * > *search_set=NULL)
 
void CollectEdgeVertices (Node *v0, Node *v1, Array< int > &indices)
 
void CollectFaceVertices (Node *v0, Node *v1, Node *v2, Node *v3, Array< int > &indices)
 
void BuildElementToVertexTable ()
 
void UpdateElementToVertexTable ()
 
void GetFineTransforms (Element *elem, int coarse_index, FineTransform *transforms, const PointMatrix &pm)
 
NodeGetEdgeMaster (Node *node) const
 
int EdgeSplitLevel (Node *v1, Node *v2) const
 
void FaceSplitLevel (Node *v1, Node *v2, Node *v3, Node *v4, int &h_level, int &v_level) const
 
void CountSplits (Element *elem, int splits[3]) const
 
int CountElements (Element *elem) const
 
int PrintElements (std::ostream &out, Element *elem, int &coarse_id) const
 
void CountObjects (int &nelem, int &nvert, int &nedges) const
 

Protected Attributes

MPI_Comm MyComm
 
int NRanks
 
int MyRank
 
int NVertices
 
int NGhostVertices
 
int NEdges
 
int NGhostEdges
 
int NFaces
 
int NGhostFaces
 
int NElements
 
int NGhostElements
 
NCList shared_vertices
 
NCList shared_edges
 
NCList shared_faces
 
Array< int > vertex_owner
 
Array< int > edge_owner
 
Array< int > face_owner
 
Table vertex_group
 
Table edge_group
 
Table face_group
 
Array< char > face_orient
 
Array< char > element_type
 
Array< Element * > ghost_layer
 list of elements whose 'element_type' == 2. More...
 
Array< Connectionindex_rank
 
Array< Element * > tmp_neighbors
 
- Protected Attributes inherited from mfem::NCMesh
int Dim
 
int spaceDim
 dimensions of the elements and the vertex coordinates More...
 
bool Iso
 true if the mesh only contains isotropic refinements More...
 
Array< Element * > root_elements
 
HashTable< Nodenodes
 
HashTable< Facefaces
 
Array< Element * > leaf_elements
 
Array< int > vertex_nodeId
 
NCList face_list
 lazy-initialized list of faces, see GetFaceList More...
 
NCList edge_list
 lazy-initialized list of edges, see GetEdgeList More...
 
Array< Face * > boundary_faces
 subset of all faces, set by BuildFaceList More...
 
Array< Node * > boundary_edges
 subset of all edges, set by BuildEdgeList More...
 
Table element_vertex
 leaf-element to vertex table, see FindSetNeighbors More...
 
int num_vertices
 width of the table More...
 
Array< ElemRefTyperef_stack
 stack of scheduled refinements (temporary) More...
 
Array< Element * > coarse_elements
 state of leaf_elements before Refine(), set by MarkCoarseLevel() More...
 

Friends

class ParMesh
 
class NeighborDofMessage
 

Additional Inherited Members

- Static Public Attributes inherited from mfem::NCMesh
static GeomInfo GI [Geometry::NumGeom]
 
- Static Protected Member Functions inherited from mfem::NCMesh
static int find_node (Element *elem, Node *node)
 
static int find_node (Element *elem, int node_id)
 
static int find_hex_face (int a, int b, int c)
 
static void find_face_nodes (const Face *face, Node *node[4])
 

Detailed Description

A parallel extension of the NCMesh class.

The basic idea (and assumption) is that all processors share the coarsest layer ('root_elements'). This has the advantage that refinements can easily be exchanged between processors when rebalancing. Also individual elements can be uniquely identified by the index of the root element and a path in the refinement tree.

Each leaf element is owned by one of the processors (NCMesh::Element::rank). The underlying NCMesh stores not only elements for the current ('MyRank') processor, but also a minimal layer of adjacent "ghost" elements owned by other processors. The ghost layer is synchronized after refinement.

The ghost layer contains all vertex-, edge- and face-neighbors of the current processor's region. It is used to determine constraining relations and ownership of DOFs on the processor boundary. Ghost elements are never seen by the rest of MFEM as they are skipped when a Mesh is created from the NCMesh.

The processor that owns a vertex, edge or a face (and in turn its DOFs) is currently defined to be the one with the lowest rank in the group of processors that share the entity.

Vertices, edges and faces that are not shared by this ('MyRank') processor are ghosts, and are numbered after all real vertices/edges/faces, i.e., they have indices greater than NVertices, NEdges, NFaces, respectively.

A shared vertex/edge/face is identified in an interprocessor message by a pair of numbers. The first number specifies an element in an ElementSet (typically sent at the beginning of the message) that contains the v/e/f. The second number is the local index of the v/e/f in that element.

The interface of ParNCMesh is designed for its main customer, the ParFiniteElementSpace class, which needs to know everything about the vertices, edges and faces on the processor boundary.

Definition at line 66 of file pncmesh.hpp.

Constructor & Destructor Documentation

mfem::ParNCMesh::ParNCMesh ( MPI_Comm  comm,
const NCMesh ncmesh 
)

Definition at line 26 of file pncmesh.cpp.

Member Function Documentation

void mfem::ParNCMesh::AddMasterSlaveRanks ( int  nitems,
const NCList &  list 
)
protected

Definition at line 242 of file pncmesh.cpp.

void mfem::ParNCMesh::AssignLeafIndices ( )
protectedvirtual

Reimplemented from mfem::NCMesh.

Definition at line 55 of file pncmesh.cpp.

void mfem::ParNCMesh::BuildEdgeList ( )
protectedvirtual

Reimplemented from mfem::NCMesh.

Definition at line 185 of file pncmesh.cpp.

void mfem::ParNCMesh::BuildFaceList ( )
protectedvirtual

Reimplemented from mfem::NCMesh.

Definition at line 209 of file pncmesh.cpp.

void mfem::ParNCMesh::BuildSharedVertices ( )
protected

Definition at line 337 of file pncmesh.cpp.

void mfem::ParNCMesh::CalcFaceOrientations ( )
protected

Definition at line 387 of file pncmesh.cpp.

void mfem::ParNCMesh::DecodeMeshIds ( std::istream &  is,
Array< MeshId ids[],
int  dim,
bool  decode_indices 
) const
protected

Read from 'is' a processor-independent encoding of vertex/edge/face IDs.

Definition at line 861 of file pncmesh.cpp.

void mfem::ParNCMesh::ElementNeighborProcessors ( Element elem,
Array< int > &  ranks 
)
protected

Return a list of processors that own elements in the immediate neighborhood of 'elem' (i.e., vertex, edge and face neighbors), and are not 'MyRank'.

Definition at line 483 of file pncmesh.cpp.

void mfem::ParNCMesh::ElementSharesEdge ( Element elem,
Edge edge 
)
protectedvirtual

Definition at line 163 of file pncmesh.cpp.

void mfem::ParNCMesh::ElementSharesFace ( Element elem,
Face face 
)
protectedvirtual

Definition at line 175 of file pncmesh.cpp.

void mfem::ParNCMesh::EncodeMeshIds ( std::ostream &  os,
Array< MeshId ids[],
int  dim 
) const
protected

Write to 'os' a processor-independent encoding of vertex/edge/face IDs.

Definition at line 819 of file pncmesh.cpp.

void mfem::ParNCMesh::GetBoundaryClosure ( const Array< int > &  bdr_attr_is_ess,
Array< int > &  bdr_vertices,
Array< int > &  bdr_edges 
)
virtual

Extension of NCMesh::GetBoundaryClosure. Filters out ghost vertices and ghost edges from 'bdr_vertices' and 'bdr_edges'.

Reimplemented from mfem::NCMesh.

Definition at line 424 of file pncmesh.cpp.

void mfem::ParNCMesh::GetDebugMesh ( Mesh debug_mesh) const

Extract a debugging Mesh containing all leaf elements, including ghosts. The debug mesh will have element attributes set to 1 for real elements and to 2 for ghost elements.

Definition at line 1187 of file pncmesh.cpp.

int mfem::ParNCMesh::GetFaceOrientation ( int  index) const
inline

Return (shared) face orientation relative to the owner element.

Definition at line 116 of file pncmesh.hpp.

const int* mfem::ParNCMesh::GetGroup ( int  type,
int  index,
int &  size 
) const
inline

Return a list of processors sharing a vertex/edge/face ('type' == 0/1/2, resp.) and the size of the list.

Definition at line 134 of file pncmesh.hpp.

virtual int mfem::ParNCMesh::GetNumGhosts ( ) const
inlineprotectedvirtual

Reimplemented from mfem::NCMesh.

Definition at line 231 of file pncmesh.hpp.

int mfem::ParNCMesh::GetOwner ( int  type,
int  index 
) const
inline

Return vertex/edge/face ('type' == 0/1/2, resp.) owner.

Definition at line 122 of file pncmesh.hpp.

const NCList& mfem::ParNCMesh::GetSharedEdges ( )
inline

Return a list of edges shared by this processor and at least one other processor. (NOTE: this is a subset of the NCMesh::edge_list; slaves are empty.)

Definition at line 90 of file pncmesh.hpp.

const NCList& mfem::ParNCMesh::GetSharedFaces ( )
inline

Return a list of faces shared by this processor and another processor. (NOTE: this is a subset of NCMesh::face_list; slaves are empty.)

Definition at line 98 of file pncmesh.hpp.

const NCList& mfem::ParNCMesh::GetSharedList ( int  type)
inline

Helper to get shared vertices/edges/faces ('type' == 0/1/2 resp.).

Definition at line 105 of file pncmesh.hpp.

const NCList& mfem::ParNCMesh::GetSharedVertices ( )
inline

Return a list of vertices shared by this processor and at least one other processor. (NOTE: only NCList::conforming will be set.)

Definition at line 81 of file pncmesh.hpp.

int mfem::ParNCMesh::InitialPartition ( int  index) const
inlineprotected

Assigns elements to processors at the initial stage (ParMesh creation).

Definition at line 222 of file pncmesh.hpp.

bool mfem::ParNCMesh::IsGhost ( int  type,
int  index 
) const
inline

Returns true if the specified vertex/edge/face is a ghost.

Definition at line 161 of file pncmesh.hpp.

virtual bool mfem::ParNCMesh::IsGhost ( const Element elem) const
inlineprotectedvirtual

Definition at line 228 of file pncmesh.hpp.

void mfem::ParNCMesh::LimitNCLevel ( int  max_level)
virtual

To be implemented.

Reimplemented from mfem::NCMesh.

Definition at line 661 of file pncmesh.cpp.

void mfem::ParNCMesh::MakeShared ( const Table groups,
const NCList &  list,
NCList &  shared 
)
protected

Definition at line 309 of file pncmesh.cpp.

void mfem::ParNCMesh::NeighborProcessors ( Array< int > &  neighbors)
protected

Get a list of ranks that own elements in the neighborhood of our region. NOTE: MyRank is not included.

Definition at line 507 of file pncmesh.cpp.

void mfem::ParNCMesh::OnMeshUpdated ( Mesh mesh)
protectedvirtual

Get edge and face numbering from 'mesh' (i.e., set all Edge::index and Face::index) after a new mesh was created from us.

Reimplemented from mfem::NCMesh.

Definition at line 127 of file pncmesh.cpp.

void mfem::ParNCMesh::Prune ( )
protected

Traverse the (local) refinement tree and determine which subtrees are no longer needed, i.e., their leaves are not owned by us nor are they our ghosts. These subtrees are then derefined.

Definition at line 566 of file pncmesh.cpp.

bool mfem::ParNCMesh::PruneTree ( Element elem)
protected

Internal. Recursive part of Prune().

Definition at line 530 of file pncmesh.cpp.

bool mfem::ParNCMesh::RankInGroup ( int  type,
int  index,
int  rank 
) const
inline

Returns true if 'rank' is in the processor group of a vertex/edge/face ('type' == 0/1/2, resp.).

Definition at line 149 of file pncmesh.hpp.

void mfem::ParNCMesh::Refine ( const Array< Refinement > &  refinements)
virtual

An override of NCMesh::Refine, which is called eventually, after making sure that refinements that occur on the processor boundary are sent to the neighbor processors so they can keep their ghost layers up to date.

Reimplemented from mfem::NCMesh.

Definition at line 588 of file pncmesh.cpp.

void mfem::ParNCMesh::Update ( )
protectedvirtual

Apart from the primary data structure, which is the element/node/face hierarchy, there is secondary data that is derived from the primary data and needs to be updated when the primary data changes. Update() takes care of that and needs to be called after refinement and derefinement. Secondary data includes: leaf_elements, vertex_nodeId, face_list, edge_list, and everything in ParNCMesh.

Reimplemented from mfem::NCMesh.

Definition at line 43 of file pncmesh.cpp.

void mfem::ParNCMesh::UpdateLayers ( )
protected

Definition at line 448 of file pncmesh.cpp.

void mfem::ParNCMesh::UpdateVertices ( )
protectedvirtual

update Vertex::index and vertex_nodeId

Reimplemented from mfem::NCMesh.

Definition at line 81 of file pncmesh.cpp.

Friends And Related Function Documentation

friend class NeighborDofMessage
friend

Definition at line 333 of file pncmesh.hpp.

friend class ParMesh
friend

Definition at line 332 of file pncmesh.hpp.

Member Data Documentation

Table mfem::ParNCMesh::edge_group
protected

Definition at line 204 of file pncmesh.hpp.

Array<int> mfem::ParNCMesh::edge_owner
protected

Definition at line 199 of file pncmesh.hpp.

Array<char> mfem::ParNCMesh::element_type
protected

Type of each leaf element: 1 - our element (rank == MyRank), 3 - our element, and neighbor to the ghost layer, 2 - ghost layer element (existing element, but rank != MyRank), 0 - element beyond the ghost layer, may not be a real element. See also UpdateLayers.

Definition at line 215 of file pncmesh.hpp.

Table mfem::ParNCMesh::face_group
protected

Definition at line 205 of file pncmesh.hpp.

Array<char> mfem::ParNCMesh::face_orient
protected

Definition at line 207 of file pncmesh.hpp.

Array<int> mfem::ParNCMesh::face_owner
protected

Definition at line 200 of file pncmesh.hpp.

Array<Element*> mfem::ParNCMesh::ghost_layer
protected

list of elements whose 'element_type' == 2.

Definition at line 217 of file pncmesh.hpp.

Array<Connection> mfem::ParNCMesh::index_rank
protected

Definition at line 247 of file pncmesh.hpp.

MPI_Comm mfem::ParNCMesh::MyComm
protected

Definition at line 184 of file pncmesh.hpp.

int mfem::ParNCMesh::MyRank
protected

Definition at line 185 of file pncmesh.hpp.

int mfem::ParNCMesh::NEdges
protected

Definition at line 188 of file pncmesh.hpp.

int mfem::ParNCMesh::NElements
protected

Definition at line 190 of file pncmesh.hpp.

int mfem::ParNCMesh::NFaces
protected

Definition at line 189 of file pncmesh.hpp.

int mfem::ParNCMesh::NGhostEdges
protected

Definition at line 188 of file pncmesh.hpp.

int mfem::ParNCMesh::NGhostElements
protected

Definition at line 190 of file pncmesh.hpp.

int mfem::ParNCMesh::NGhostFaces
protected

Definition at line 189 of file pncmesh.hpp.

int mfem::ParNCMesh::NGhostVertices
protected

Definition at line 187 of file pncmesh.hpp.

int mfem::ParNCMesh::NRanks
protected

Definition at line 185 of file pncmesh.hpp.

int mfem::ParNCMesh::NVertices
protected

Definition at line 187 of file pncmesh.hpp.

NCList mfem::ParNCMesh::shared_edges
protected

Definition at line 194 of file pncmesh.hpp.

NCList mfem::ParNCMesh::shared_faces
protected

Definition at line 195 of file pncmesh.hpp.

NCList mfem::ParNCMesh::shared_vertices
protected

Definition at line 193 of file pncmesh.hpp.

Array<Element*> mfem::ParNCMesh::tmp_neighbors
protected

Definition at line 287 of file pncmesh.hpp.

Table mfem::ParNCMesh::vertex_group
protected

Definition at line 203 of file pncmesh.hpp.

Array<int> mfem::ParNCMesh::vertex_owner
protected

Definition at line 198 of file pncmesh.hpp.


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