ESScript  Revision_4488
finley/src/NodeFile.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15 
16 #ifndef __FINLEY_NODEFILE_H__
17 #define __FINLEY_NODEFILE_H__
18 
19 #define MAX_numDim 3
20 
21 #include "Finley.h"
22 #include "NodeMapping.h"
23 #include "Util.h"
24 #include "paso/Distribution.h"
25 #include "paso/Coupler.h"
26 #include "esysUtils/Esys_MPI.h"
27 
28 namespace finley {
29 
30 class NodeFile
31 {
32 public:
33  NodeFile(int nDim, Esys_MPIInfo *mpiInfo);
34  ~NodeFile();
35 
36  void allocTable(int numNodes);
37  void freeTable();
38 
39  inline int getFirstReducedNode();
40  inline int getLastReducedNode();
41  inline int getGlobalNumReducedNodes();
42  inline int* borrowGlobalReducedNodesIndex();
43 
44  inline int getFirstNode();
45  inline int getLastNode();
46  inline int getGlobalNumNodes();
47  inline int* borrowGlobalNodesIndex();
48 
49  inline int getNumReducedNodes();
50  inline int getNumDegreesOfFreedom();
51  inline int getNumNodes();
52  inline int getNumReducedDegreesOfFreedom();
53 
54  inline int* borrowTargetReducedNodes();
55  inline int* borrowTargetDegreesOfFreedom();
56  inline int* borrowTargetNodes();
58 
59  inline int* borrowReducedNodesTarget();
60  inline int* borrowDegreesOfFreedomTarget();
61  inline int* borrowNodesTarget();
63 
65  int createDenseNodeLabeling(int* node_distribution, const int* dof_distribution);
66  int createDenseReducedLabeling(int* reducedMask, bool useNodes);
67  void assignMPIRankToDOFs(int* mpiRankOfDOF, int *distribution);
68 
69  void copyTable(int offset, int idOffset, int dofOffset, const NodeFile* in);
70  void gather(int* index, const NodeFile* in);
71  void gather_global(int* index, const NodeFile* in);
72  void scatter(int* index, const NodeFile* in);
73 
74  void setCoordinates(const escript::Data& newX);
75  void setTags(const int newTag, const escript::Data& mask);
76  inline void updateTagList();
77 
78  std::pair<int,int> getDOFRange() const;
79 
80 private:
81  std::pair<int,int> getGlobalIdRange() const;
82  std::pair<int,int> getGlobalDOFRange() const;
83  std::pair<int,int> getGlobalNodeIDIndexRange() const;
84  int prepareLabeling(int* mask, std::vector<int>& buffer,
85  std::vector<int>& distribution, bool useNodes);
86 
87 public:
89 
93  int numNodes;
95  int numDim;
97  int *Id;
99  int *Tag;
101  std::vector<int> tagsInUse;
107  double *Coordinates;
116 
121 
126 
129 
134 
137  int status;
138 };
139 
140 //
141 // implementation of inline methods
142 //
143 
145 {
147 }
148 
150 {
152 }
153 
155 {
157 }
158 
160 {
162 }
163 
165 {
167 }
168 
170 {
172 }
173 
175 {
177 }
178 
180 {
181  return globalNodesIndex;
182 }
183 
185 {
187 }
188 
190 {
192 }
193 
195 {
196  return nodesMapping->numNodes;
197 }
198 
200 {
202 }
203 
205 {
206  return reducedNodesMapping->target;
207 }
208 
210 {
212 }
213 
215 {
216  return nodesMapping->target;
217 }
218 
220 {
222 }
223 
225 {
226  return reducedNodesMapping->map;
227 }
228 
230 {
232 }
233 
235 {
236  return nodesMapping->map;
237 }
238 
240 {
242 }
243 
245 {
247 }
248 
249 
250 } // namespace finley
251 
252 #endif // __FINLEY_NODEFILE_H__
253