MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
pmesh.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_PMESH
13 #define MFEM_PMESH
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 
19 #include "../general/communication.hpp"
20 #include "mesh.hpp"
21 #include "pncmesh.hpp"
22 #include <iostream>
23 
24 namespace mfem
25 {
26 
28 class ParMesh : public Mesh
29 {
30 private:
31  MPI_Comm MyComm;
32  int NRanks, MyRank;
33 
34  Array<Element *> shared_edges;
35  Array<Element *> shared_faces;
36 
38  Table group_svert;
39  Table group_sedge;
40  Table group_sface;
41 
43  Array<int> svert_lvert;
44  Array<int> sedge_ledge;
45  Array<int> sface_lface;
46 
48  ParMesh(const ParNCMesh &pncmesh);
49 
51  int GetEdgeSplittings(Element *edge, const DSTable &v_to_v, int *middle);
53  int GetFaceSplittings(Element *face, const DSTable &v_to_v, int *middle);
54 
55  void GetFaceNbrElementTransformation(
56  int i, IsoparametricTransformation *ElTr);
57 
59  virtual void QuadUniformRefinement();
60 
62  virtual void HexUniformRefinement();
63 
64  virtual void NURBSUniformRefinement();
65 
67  virtual void LocalRefinement(const Array<int> &marked_el, int type = 3);
68 
70  virtual void NonconformingRefinement(const Array<Refinement> &refinements,
71  int nc_limit = 0);
72 
73  void DeleteFaceNbrData();
74 
75 public:
81  explicit ParMesh(const ParMesh &pmesh, bool copy_nodes = true);
82 
83  ParMesh(MPI_Comm comm, Mesh &mesh, int *partitioning_ = NULL,
84  int part_method = 1);
85 
86  MPI_Comm GetComm() const { return MyComm; }
87  int GetNRanks() const { return NRanks; }
88  int GetMyRank() const { return MyRank; }
89 
91 
92  // Face-neighbor elements and vertices
99  // Local face-neighbor elements and vertices ordered by face-neighbor
102 
104 
105  int GetNGroups() { return gtopo.NGroups(); }
106 
107  // next 6 methods do not work for the 'local' group 0
108  int GroupNVertices(int group) { return group_svert.RowSize(group-1); }
109  int GroupNEdges(int group) { return group_sedge.RowSize(group-1); }
110  int GroupNFaces(int group) { return group_sface.RowSize(group-1); }
111 
112  int GroupVertex(int group, int i)
113  { return svert_lvert[group_svert.GetJ()[group_svert.GetI()[group-1]+i]]; }
114  void GroupEdge(int group, int i, int &edge, int &o);
115  void GroupFace(int group, int i, int &face, int &o);
116 
117  void ExchangeFaceNbrData();
118  void ExchangeFaceNbrNodes();
119  int GetNFaceNeighbors() const { return face_nbr_group.Size(); }
120  int GetFaceNbrGroup(int fn) const { return face_nbr_group[fn]; }
121  int GetFaceNbrRank(int fn) const;
125 
130 
132  int GetNSharedFaces() const;
133 
135  int GetSharedFace(int sface) const;
136 
138  virtual void ReorientTetMesh();
139 
141  void RefineGroups(const DSTable &v_to_v, int *middle);
142 
145  virtual void Print(std::ostream &out = std::cout) const;
146 
149  virtual void PrintXG(std::ostream &out = std::cout) const;
150 
155  void PrintAsOne(std::ostream &out = std::cout);
156 
158  void PrintAsOneXG(std::ostream &out = std::cout);
159 
161  virtual void PrintInfo(std::ostream &out = std::cout);
162 
163  virtual ~ParMesh();
164 };
165 
166 }
167 
168 #endif // MFEM_USE_MPI
169 
170 #endif
int GetNFaceNeighbors() const
Definition: pmesh.hpp:119
int Size() const
Logical size of the array.
Definition: array.hpp:109
int * GetJ()
Definition: table.hpp:108
virtual ~ParMesh()
Definition: pmesh.cpp:3859
virtual void ReorientTetMesh()
See the remarks for the serial version in mesh.hpp.
Definition: pmesh.cpp:1432
Array< Element * > face_nbr_elements
Definition: pmesh.hpp:97
int GetNSharedFaces() const
Return the number of shared faces (3D), edges (2D), vertices (1D)
Definition: pmesh.cpp:1409
bool have_face_nbr_data
Definition: pmesh.hpp:93
Array< int > face_nbr_vertices_offset
Definition: pmesh.hpp:96
Array< int > face_nbr_group
Definition: pmesh.hpp:94
A parallel extension of the NCMesh class.
Definition: pncmesh.hpp:66
ParNCMesh * pncmesh
Definition: pmesh.hpp:103
int GetNRanks() const
Definition: pmesh.hpp:87
int GroupVertex(int group, int i)
Definition: pmesh.hpp:112
void ExchangeFaceNbrData()
Definition: pmesh.cpp:843
void PrintAsOne(std::ostream &out=std::cout)
Definition: pmesh.cpp:2976
Array< int > face_nbr_elements_offset
Definition: pmesh.hpp:95
int GetSharedFace(int sface) const
Return the local face index for the given shared face.
Definition: pmesh.cpp:1422
Table send_face_nbr_vertices
Definition: pmesh.hpp:101
int GroupNVertices(int group)
Definition: pmesh.hpp:108
int GetFaceNbrGroup(int fn) const
Definition: pmesh.hpp:120
int GetMyRank() const
Definition: pmesh.hpp:88
void RefineGroups(const DSTable &v_to_v, int *middle)
Update the groups after tet refinement.
Definition: pmesh.cpp:2204
MPI_Comm GetComm() const
Definition: pmesh.hpp:86
Array< Vertex > face_nbr_vertices
Definition: pmesh.hpp:98
virtual void PrintInfo(std::ostream &out=std::cout)
Print various parallel mesh stats.
Definition: pmesh.cpp:3755
virtual void PrintXG(std::ostream &out=std::cout) const
Definition: pmesh.cpp:2656
void GroupFace(int group, int i, int &face, int &o)
Definition: pmesh.cpp:700
void ExchangeFaceNbrNodes()
Definition: pmesh.cpp:1236
int GroupNFaces(int group)
Definition: pmesh.hpp:110
int NGroups() const
void GroupEdge(int group, int i, int &edge, int &o)
Definition: pmesh.cpp:692
int * GetI()
Definition: table.hpp:107
void PrintAsOneXG(std::ostream &out=std::cout)
Old mesh format (Netgen/Truegrid) version of &#39;PrintAsOne&#39;.
Definition: pmesh.cpp:3232
int RowSize(int i) const
Definition: table.hpp:102
Table send_face_nbr_elements
Definition: pmesh.hpp:100
Table * GetFaceToAllElementTable() const
Definition: pmesh.cpp:1303
GroupTopology gtopo
Definition: pmesh.hpp:90
FaceElementTransformations * GetSharedFaceTransformations(int)
Definition: pmesh.cpp:1361
int GetNGroups()
Definition: pmesh.hpp:105
Class for parallel meshes.
Definition: pmesh.hpp:28
Abstract data type element.
Definition: element.hpp:27
int GetFaceNbrRank(int fn) const
Definition: pmesh.cpp:1293
int GroupNEdges(int group)
Definition: pmesh.hpp:109
virtual void Print(std::ostream &out=std::cout) const
Definition: pmesh.cpp:2850