Memosa-FVM  0.2
PartMesh.h
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #ifndef PARTMESH_H
6 #define PARTMESH_H
7 #include <mpi.h>
8 #include <vector>
9 #include <map>
10 #include <string>
11 #include "Mesh.h"
12 #include "Array.h"
13 #include "Vector.h"
14 #include<set>
15 using namespace std;
16 
17 //Warning globalToLocal seems have a bug..........
18 
19 
20 class PartMesh{
21 
22 public:
23  //typedef map<const StorageSite*, shared_ptr<OneToOneIndexMap> > MappersMap;
24  typedef shared_ptr< StorageSite > StorageSitePtr;
25  typedef shared_ptr< CRConnectivity > CRConnectivityPtr;
26  typedef shared_ptr< Array<int> > ArrayIntPtr;
27  typedef shared_ptr< Array<Mesh::VecD3> > ArrayVecD3Ptr;
28  typedef shared_ptr< Mesh > MeshPtr;
29 
30  enum ETYPE{ TRI = 1, QUAD = 2, TETRA = 3, HEXA = 4 };
31  enum WTYPE{ NOWEIGHTS = 0, WEIGHTS_ONLY_EDGES = 1, WEIGTHS_ONLY_VERTICES = 2,
32  WEIGHTS_BOTH_VERTICES_EDGES = 3};
33  enum NUMFLAG{ C_STYLE = 0, FORTRAN_STYLE = 1 };
34  enum CELLTYPE{ INTERIOR = 1, GHOST_BOUNDARY_CELL = 2, GHOST_INTERFACE_CELL};
35 
36  explicit PartMesh(const MeshList& mesh_list, vector<int> npart, vector<int> eType);
37  ~PartMesh();
38 
39  void partition();
40  void mesh();
41  const MeshList& meshList() const { return _meshListLocal;};
42 
43 
44  void debug_print();
45  void dumpTecplot();
46  void mesh_debug();
47  void mesh_xdmfplot();
48 
49  // set property methods
50  void setWeightType( int weight_type );
51  void setNumFlag( int num_flag);
52 
53  //clean up memory
54  void cleanup();
55  void isCleanup(bool clean_up) { _cleanup = clean_up; cout << " cleanup = " << _cleanup << endl; }
56 
57 private:
58 
59  PartMesh( const PartMesh& part_mesh ); //dont allow copy constructor
60 
61  void init();
62  void compute_elem_dist();
63  void elem_connectivity();
64  void parmetis_mesh();
65  int local_nodes(int id);
66  void set_eptr_eind(int id);
67  void map_part_elms();
68  void count_elems_part();
69  void exchange_part_elems();
70  void shift_sum_row();
71  void mesh_setup();
72 
73  void CRConnectivity_cellParts();
74  void mapBounIDAndCell(int id);
75  void resize_elem(int id);
76  void CRConnectivity_faceParts();
77  void faceCells_faceNodes();
78 
79  void interfaces();
80  void coordinates();
81  int count_interior_faces( int id );
82  void order_faceCells_faceNodes();
83  void non_interior_cells();
84  void non_interior_cells2();
85  void local_number_elems();
86  void exchange_interface_meshes();
87  void mappers();
88  void create_window( int id );
89  void free_window( );
90  void fence_window();
91  int get_window_displ( int id, int neigh_mesh_id );
92  void construct_mesh( int id );
93  void setMeshColors();
94 
95  void mesh_xdmf_header();
96  void mesh_file();
97  void mesh_tecplot();
98 
99 
100  void cleanup_follow_exchange_part_elems();
101  void cleanup_follow_faceCells_faceNodes();
102  void cleanup_follow_mappers();
103 
104 
106  vector<int> _nPart;
107  vector<int> _totElems;
108  vector<int> _totElemsAndGhosts;
109  vector< Array<int>* > _elemDist; //store dist element number for each Mesh
110  vector< Array<int>* > _globalIndx; //store where partition starts in glbal array
111  vector< int* > _ePtr;
112  vector< int* > _eInd;
113  vector< int* > _eElm;
114  vector< int* > _elmWght;
115  vector< int > _wghtFlag;
116  vector< int > _numFlag;
117  vector< int > _ncon;
118  vector< int > _ncommonNodes;
119  vector< int > _eType;
120  vector< float* > _tpwgts;
121  vector< float* > _ubvec;
122  int _options;
123  int _procID;
124  //output variables
125  vector< int > _edgecut;
126  vector< int* > _part;
127 
128  //
129  vector< multimap<int,int> > _mapPartAndElms;
130  vector< int* > _row;
131  vector< int* > _col;
132  vector< int* > _elem; //just interior (local)
133  vector< set<int> > _elemSet;
134  vector< set<int> > _elemLocal; //local numbering
135  vector< int* > _elemWithGhosts; //interior+boundary (local)
136 
137 
138  vector<int> _nelems;
139  vector<int> _nelemsWithGhosts;
140  vector<int> _colDim;
141  int _nmesh;
142 
143  vector< StorageSitePtr > _cellSiteGlobal;
144  vector< StorageSitePtr > _cellSite;
145  vector< StorageSitePtr > _nodeSite;
146  vector< StorageSitePtr > _faceSite;
147  vector< StorageSitePtr > _partSite;
148 
149 
150  vector< const CRConnectivity* > _faceCellsGlobal; //global mesh
151  vector< const CRConnectivity* > _faceNodesGlobal; //global mesh
152 
153  vector< CRConnectivityPtr > _faceCells; //belongs to this partition
154  vector< CRConnectivityPtr > _faceNodes; //belongs to this partition
155  vector< CRConnectivityPtr > _cellCells; //belongs to this partition
156  vector< CRConnectivityPtr > _cellNodes; //belongs to this partition
157  vector< CRConnectivityPtr > _faceCellsOrdered;
158  vector< CRConnectivityPtr > _faceNodesOrdered;
159 
160  vector< CRConnectivityPtr > _cellParts;
161  vector< CRConnectivityPtr > _partCells;
162  vector< CRConnectivityPtr > _faceParts;
163  vector< CRConnectivityPtr > _partFaces; //transpose of _faceParts
164  vector< CRConnectivityPtr > _partNodes;
165 
166 
167  vector< set<int> > _boundarySet;
168  vector< multimap<int,int> > _mapBounIDAndCell; //belongs to this partition (global numbering)
169  vector< map<int,string> > _mapBounIDAndBounType; //belongs to this partition
170 
171  vector< ArrayVecD3Ptr > _coord; //belongs to this partition
172  vector< set<int> > _interfaceSet;
173  vector< multimap<int,int> > _interfaceMap; //belongs to this partition (local numbering)
174 
175  vector< set<int> > _nonInteriorCells; //local numbering
176 
177  vector< map<int,int> > _bndryOffsets;
178  vector< map<int,int> > _interfaceOffsets;
179  vector< vector<int> > _cellToOrderedCell;
180  vector< multimap<int,int> > _globalToLocalMappers;
181  vector< map<int,int> > _localToGlobalMappers;
182 
183  vector< ArrayIntPtr > _localToGlobalMap;
184 
185  //variables aglomorated for MPI communications
186  vector< ArrayIntPtr > _interfaceMeshCounts; //ArrayIntPtr[0] = value , 0th mesh has total "value" neigh interfaced meshes
187  vector< ArrayIntPtr > _offsetInterfaceCells; //this start location of interfaces, need at communuctation a lot
188  vector< ArrayIntPtr > _procTotalInterfaces; //store total interfaces for each process
189  vector< ArrayIntPtr > _interfaceMeshIDs; //
190  vector< ArrayIntPtr > _ghostCellsGlobal; //stored in contigous memory (global numbering) local data
191  vector< ArrayIntPtr > _ghostCellsLocal; //local numbering local data
192  vector< int > _windowSize;
193 
194 
195  vector< vector< ArrayIntPtr > > _fromIndices;
196  vector< vector< ArrayIntPtr > > _toIndices;
197 
198  MPI::Win _winGlobal;
199  MPI::Win _winLocal;
200  bool _cleanup;
201  vector< Mesh* > _meshListLocal; //all is for you
202 };
203 
204 #endif
vector< int > _eType
Definition: PartMesh.h:119
vector< map< int, string > > _mapBounIDAndBounType
Definition: PartMesh.h:169
vector< StorageSitePtr > _partSite
Definition: PartMesh.h:147
vector< StorageSitePtr > _nodeSite
Definition: PartMesh.h:145
vector< map< int, int > > _localToGlobalMappers
Definition: PartMesh.h:181
vector< CRConnectivityPtr > _cellCells
Definition: PartMesh.h:155
vector< CRConnectivityPtr > _partNodes
Definition: PartMesh.h:164
vector< int * > _elem
Definition: PartMesh.h:132
vector< int > _totElemsAndGhosts
Definition: PartMesh.h:108
vector< CRConnectivityPtr > _faceParts
Definition: PartMesh.h:162
MPI::Win _winLocal
Definition: PartMesh.h:199
shared_ptr< Mesh > MeshPtr
Definition: PartMesh.h:28
vector< int > _ncommonNodes
Definition: PartMesh.h:118
int _options
Definition: PartMesh.h:122
vector< set< int > > _interfaceSet
Definition: PartMesh.h:172
vector< int > _nelems
Definition: PartMesh.h:138
shared_ptr< StorageSite > StorageSitePtr
Definition: PartMesh.h:24
vector< vector< int > > _cellToOrderedCell
Definition: PartMesh.h:179
vector< int * > _eElm
Definition: PartMesh.h:113
bool _cleanup
Definition: PartMesh.h:200
vector< CRConnectivityPtr > _faceNodes
Definition: PartMesh.h:154
vector< set< int > > _elemSet
Definition: PartMesh.h:133
vector< int > _nPart
Definition: PartMesh.h:106
vector< ArrayIntPtr > _ghostCellsLocal
Definition: PartMesh.h:191
vector< Mesh * > _meshListLocal
Definition: PartMesh.h:201
vector< int > _windowSize
Definition: PartMesh.h:192
shared_ptr< Array< Mesh::VecD3 > > ArrayVecD3Ptr
Definition: PartMesh.h:27
vector< int * > _elmWght
Definition: PartMesh.h:114
vector< int * > _elemWithGhosts
Definition: PartMesh.h:135
vector< int > _numFlag
Definition: PartMesh.h:116
vector< Array< int > * > _elemDist
Definition: PartMesh.h:109
int _nmesh
Definition: PartMesh.h:141
vector< int * > _col
Definition: PartMesh.h:131
vector< float * > _tpwgts
Definition: PartMesh.h:120
vector< multimap< int, int > > _globalToLocalMappers
Definition: PartMesh.h:180
vector< ArrayIntPtr > _interfaceMeshCounts
Definition: PartMesh.h:186
vector< ArrayIntPtr > _interfaceMeshIDs
Definition: PartMesh.h:189
vector< int > _totElems
Definition: PartMesh.h:107
int _procID
Definition: PartMesh.h:123
vector< int > _nelemsWithGhosts
Definition: PartMesh.h:139
void isCleanup(bool clean_up)
Definition: PartMesh.h:55
vector< ArrayIntPtr > _procTotalInterfaces
Definition: PartMesh.h:188
vector< ArrayIntPtr > _ghostCellsGlobal
Definition: PartMesh.h:190
vector< multimap< int, int > > _mapBounIDAndCell
Definition: PartMesh.h:168
vector< int * > _part
Definition: PartMesh.h:126
vector< map< int, int > > _interfaceOffsets
Definition: PartMesh.h:178
const MeshList _meshList
Definition: PartMesh.h:105
vector< StorageSitePtr > _cellSite
Definition: PartMesh.h:144
vector< multimap< int, int > > _mapPartAndElms
Definition: PartMesh.h:129
vector< CRConnectivityPtr > _faceNodesOrdered
Definition: PartMesh.h:158
vector< set< int > > _elemLocal
Definition: PartMesh.h:134
MPI::Win _winGlobal
Definition: PartMesh.h:198
vector< set< int > > _boundarySet
Definition: PartMesh.h:167
vector< float * > _ubvec
Definition: PartMesh.h:121
vector< CRConnectivityPtr > _partCells
Definition: PartMesh.h:161
vector< int > _edgecut
Definition: PartMesh.h:125
vector< int * > _ePtr
Definition: PartMesh.h:111
vector< map< int, int > > _bndryOffsets
Definition: PartMesh.h:177
vector< vector< ArrayIntPtr > > _toIndices
Definition: PartMesh.h:196
vector< CRConnectivityPtr > _cellParts
Definition: PartMesh.h:160
vector< int > _ncon
Definition: PartMesh.h:117
vector< int * > _eInd
Definition: PartMesh.h:112
vector< Array< int > * > _globalIndx
Definition: PartMesh.h:110
vector< int > _wghtFlag
Definition: PartMesh.h:115
vector< StorageSitePtr > _cellSiteGlobal
Definition: PartMesh.h:143
shared_ptr< Array< int > > ArrayIntPtr
Definition: PartMesh.h:26
vector< set< int > > _nonInteriorCells
Definition: PartMesh.h:175
vector< int > _colDim
Definition: PartMesh.h:140
vector< ArrayIntPtr > _offsetInterfaceCells
Definition: PartMesh.h:187
const MeshList & meshList() const
Definition: PartMesh.h:41
vector< StorageSitePtr > _faceSite
Definition: PartMesh.h:146
vector< CRConnectivityPtr > _cellNodes
Definition: PartMesh.h:156
vector< vector< ArrayIntPtr > > _fromIndices
Definition: PartMesh.h:195
vector< CRConnectivityPtr > _faceCellsOrdered
Definition: PartMesh.h:157
vector< const CRConnectivity * > _faceCellsGlobal
Definition: PartMesh.h:150
vector< multimap< int, int > > _interfaceMap
Definition: PartMesh.h:173
vector< const CRConnectivity * > _faceNodesGlobal
Definition: PartMesh.h:151
shared_ptr< CRConnectivity > CRConnectivityPtr
Definition: PartMesh.h:25
vector< ArrayVecD3Ptr > _coord
Definition: PartMesh.h:171
vector< Mesh * > MeshList
Definition: Mesh.h:439
vector< ArrayIntPtr > _localToGlobalMap
Definition: PartMesh.h:183
vector< int * > _row
Definition: PartMesh.h:130
vector< CRConnectivityPtr > _partFaces
Definition: PartMesh.h:163
vector< CRConnectivityPtr > _faceCells
Definition: PartMesh.h:153