MFEM  v3.2
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 protected:
31  ParMesh() : MyComm(0), NRanks(0), MyRank(-1),
32  have_face_nbr_data(false), pncmesh(NULL) {}
33 
34  MPI_Comm MyComm;
35  int NRanks, MyRank;
36 
39 
44 
49 
51  ParMesh(const ParNCMesh &pncmesh);
52 
54  int GetEdgeSplittings(Element *edge, const DSTable &v_to_v, int *middle);
56  int GetFaceSplittings(Element *face, const DSTable &v_to_v, int *middle);
57 
59  int i, IsoparametricTransformation *ElTr);
60 
62  FaceElementTransformations* FETr, int face_type, int face_geom);
63 
65  virtual void QuadUniformRefinement();
66 
68  virtual void HexUniformRefinement();
69 
70  virtual void NURBSUniformRefinement();
71 
73  virtual void LocalRefinement(const Array<int> &marked_el, int type = 3);
74 
76  virtual void NonconformingRefinement(const Array<Refinement> &refinements,
77  int nc_limit = 0);
78 
79  virtual bool NonconformingDerefinement(Array<double> &elem_error,
80  double threshold, int nc_limit = 0,
81  int op = 1);
82  void DeleteFaceNbrData();
83 
84  bool WantSkipSharedMaster(const NCMesh::Master &master) const;
85 
86 public:
91  explicit ParMesh(const ParMesh &pmesh, bool copy_nodes = true);
92 
93  ParMesh(MPI_Comm comm, Mesh &mesh, int *partitioning_ = NULL,
94  int part_method = 1);
95 
96  MPI_Comm GetComm() const { return MyComm; }
97  int GetNRanks() const { return NRanks; }
98  int GetMyRank() const { return MyRank; }
99 
101 
102  // Face-neighbor elements and vertices
109  // Local face-neighbor elements and vertices ordered by face-neighbor
112 
114 
115  int GetNGroups() { return gtopo.NGroups(); }
116 
117  // next 6 methods do not work for the 'local' group 0
118  int GroupNVertices(int group) { return group_svert.RowSize(group-1); }
119  int GroupNEdges(int group) { return group_sedge.RowSize(group-1); }
120  int GroupNFaces(int group) { return group_sface.RowSize(group-1); }
121 
122  int GroupVertex(int group, int i)
123  { return svert_lvert[group_svert.GetJ()[group_svert.GetI()[group-1]+i]]; }
124  void GroupEdge(int group, int i, int &edge, int &o);
125  void GroupFace(int group, int i, int &face, int &o);
126 
127  void GenerateOffsets(int N, HYPRE_Int loc_sizes[],
128  Array<HYPRE_Int> *offsets[]) const;
129 
130  void ExchangeFaceNbrData();
131  void ExchangeFaceNbrNodes();
132 
133  int GetNFaceNeighbors() const { return face_nbr_group.Size(); }
134  int GetFaceNbrGroup(int fn) const { return face_nbr_group[fn]; }
135  int GetFaceNbrRank(int fn) const;
136 
140 
145  GetSharedFaceTransformations(int sf, bool fill2 = true);
146 
148  int GetNSharedFaces() const;
149 
151  int GetSharedFace(int sface) const;
152 
154  virtual void ReorientTetMesh();
155 
157  virtual long ReduceInt(int value) const;
158 
160  void RefineGroups(const DSTable &v_to_v, int *middle);
161 
163  void Rebalance();
164 
167  virtual void Print(std::ostream &out = std::cout) const;
168 
171  virtual void PrintXG(std::ostream &out = std::cout) const;
172 
177  void PrintAsOne(std::ostream &out = std::cout);
178 
180  void PrintAsOneXG(std::ostream &out = std::cout);
181 
183  virtual void PrintInfo(std::ostream &out = std::cout);
184 
185  virtual ~ParMesh();
186 };
187 
188 }
189 
190 #endif // MFEM_USE_MPI
191 
192 #endif
int GetNFaceNeighbors() const
Definition: pmesh.hpp:133
int Size() const
Logical size of the array.
Definition: array.hpp:109
int * GetJ()
Definition: table.hpp:108
virtual ~ParMesh()
Definition: pmesh.cpp:3964
int NRanks
Definition: pmesh.hpp:35
virtual void ReorientTetMesh()
See the remarks for the serial version in mesh.hpp.
Definition: pmesh.cpp:1588
Array< Element * > face_nbr_elements
Definition: pmesh.hpp:107
int GetNSharedFaces() const
Return the number of shared faces (3D), edges (2D), vertices (1D)
Definition: pmesh.cpp:1547
Array< int > sface_lface
Definition: pmesh.hpp:48
virtual void LocalRefinement(const Array< int > &marked_el, int type=3)
This function is not public anymore. Use GeneralRefinement instead.
Definition: pmesh.cpp:1632
ElementTransformation * GetGhostFaceTransformation(FaceElementTransformations *FETr, int face_type, int face_geom)
Definition: pmesh.cpp:1432
bool have_face_nbr_data
Definition: pmesh.hpp:103
Array< int > face_nbr_vertices_offset
Definition: pmesh.hpp:106
Array< int > face_nbr_group
Definition: pmesh.hpp:104
Array< int > sedge_ledge
Definition: pmesh.hpp:47
bool WantSkipSharedMaster(const NCMesh::Master &master) const
Definition: pmesh.cpp:2914
A parallel extension of the NCMesh class.
Definition: pncmesh.hpp:65
ParNCMesh * pncmesh
Definition: pmesh.hpp:113
int GetNRanks() const
Definition: pmesh.hpp:97
int GroupVertex(int group, int i)
Definition: pmesh.hpp:122
void ExchangeFaceNbrData()
Definition: pmesh.cpp:896
void PrintAsOne(std::ostream &out=std::cout)
Definition: pmesh.cpp:3055
void Rebalance()
Load balance the mesh. NC meshes only.
Definition: pmesh.cpp:2255
Array< int > face_nbr_elements_offset
Definition: pmesh.hpp:105
MPI_Comm MyComm
Definition: pmesh.hpp:34
Array< Element * > shared_edges
Definition: pmesh.hpp:37
virtual void NonconformingRefinement(const Array< Refinement > &refinements, int nc_limit=0)
This function is not public anymore. Use GeneralRefinement instead.
Definition: pmesh.cpp:2155
int GetSharedFace(int sface) const
Return the local face index for the given shared face.
Definition: pmesh.cpp:1566
FaceElementTransformations * GetSharedFaceTransformations(int sf, bool fill2=true)
Definition: pmesh.cpp:1462
Table send_face_nbr_vertices
Definition: pmesh.hpp:111
int GetFaceSplittings(Element *face, const DSTable &v_to_v, int *middle)
Return a number(0-4) identifying how the given face has been split.
Definition: pmesh.cpp:744
Array< Element * > shared_faces
Definition: pmesh.hpp:38
int GroupNVertices(int group)
Definition: pmesh.hpp:118
virtual void QuadUniformRefinement()
Refine quadrilateral mesh.
Definition: pmesh.cpp:2475
virtual void HexUniformRefinement()
Refine a hexahedral mesh.
Definition: pmesh.cpp:2562
int GetFaceNbrGroup(int fn) const
Definition: pmesh.hpp:134
int GetMyRank() const
Definition: pmesh.hpp:98
void RefineGroups(const DSTable &v_to_v, int *middle)
Update the groups after tet refinement.
Definition: pmesh.cpp:2288
MPI_Comm GetComm() const
Definition: pmesh.hpp:96
virtual bool NonconformingDerefinement(Array< double > &elem_error, double threshold, int nc_limit=0, int op=1)
NC version of GeneralDerefinement.
Definition: pmesh.cpp:2207
Array< Vertex > face_nbr_vertices
Definition: pmesh.hpp:108
virtual long ReduceInt(int value) const
Utility function: sum integers from all processors (Allreduce).
Definition: pmesh.cpp:3957
virtual void PrintInfo(std::ostream &out=std::cout)
Print various parallel mesh stats.
Definition: pmesh.cpp:3853
virtual void PrintXG(std::ostream &out=std::cout) const
Definition: pmesh.cpp:2719
void GetFaceNbrElementTransformation(int i, IsoparametricTransformation *ElTr)
Definition: pmesh.cpp:824
void GroupFace(int group, int i, int &face, int &o)
Definition: pmesh.cpp:705
Table group_sedge
Definition: pmesh.hpp:42
void ExchangeFaceNbrNodes()
Definition: pmesh.cpp:1299
Table group_svert
Shared objects in each group.
Definition: pmesh.hpp:41
int GroupNFaces(int group)
Definition: pmesh.hpp:120
int NGroups() const
int GetEdgeSplittings(Element *edge, const DSTable &v_to_v, int *middle)
Return a number(0-1) identifying how the given edge has been split.
Definition: pmesh.cpp:722
void GroupEdge(int group, int i, int &edge, int &o)
Definition: pmesh.cpp:697
void GenerateOffsets(int N, HYPRE_Int loc_sizes[], Array< HYPRE_Int > *offsets[]) const
Definition: pmesh.cpp:781
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:3330
Array< int > svert_lvert
Shared to local index mapping.
Definition: pmesh.hpp:46
int MyRank
Definition: pmesh.hpp:35
int RowSize(int i) const
Definition: table.hpp:102
Table group_sface
Definition: pmesh.hpp:43
Table send_face_nbr_elements
Definition: pmesh.hpp:110
Table * GetFaceToAllElementTable() const
Definition: pmesh.cpp:1374
void DeleteFaceNbrData()
Definition: pmesh.cpp:875
GroupTopology gtopo
Definition: pmesh.hpp:100
int GetNGroups()
Definition: pmesh.hpp:115
Class for parallel meshes.
Definition: pmesh.hpp:28
Abstract data type element.
Definition: element.hpp:27
int GetFaceNbrRank(int fn) const
Definition: pmesh.cpp:1357
int GroupNEdges(int group)
Definition: pmesh.hpp:119
virtual void NURBSUniformRefinement()
Refine NURBS mesh.
Definition: pmesh.cpp:2711
virtual void Print(std::ostream &out=std::cout) const
Definition: pmesh.cpp:2927