ESScript  Revision_
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 <paso/Distribution.h>
24 
25 struct Esys_MPIInfo;
26 struct Paso_Connector;
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  void print() const;
40  inline int getFirstNode() const;
41  inline int getLastNode() const;
42  inline int getGlobalNumNodes() const;
43  inline int* borrowGlobalNodesIndex() const;
44 
45  inline int getFirstReducedNode() const;
46  inline int getLastReducedNode() const;
47  inline int getGlobalNumReducedNodes() const;
48  inline int* borrowGlobalReducedNodesIndex() const;
49 
51  inline int getNumNodes() const;
52  inline int getNumReducedNodes() const;
53  inline int getNumDegreesOfFreedom() const;
54  inline int getNumReducedDegreesOfFreedom() const;
55 
56  inline const std::vector<int>& borrowReducedNodesTarget() const;
57  inline const std::vector<int>& borrowDegreesOfFreedomTarget() const;
58  inline const std::vector<int>& borrowNodesTarget() const;
59  inline const std::vector<int>& borrowReducedDegreesOfFreedomTarget() const;
60 
61  inline const int* borrowTargetReducedNodes() const;
62  inline const int* borrowTargetDegreesOfFreedom() const;
63  inline const int* borrowTargetNodes() const;
64  inline const int* borrowTargetReducedDegreesOfFreedom() const;
65 
66  void createNodeMappings(const std::vector<int>& indexReducedNodes,
67  const std::vector<int>& dofDistribution,
68  const std::vector<int>& nodeDistribution);
70  int createDenseNodeLabeling(std::vector<int>& nodeDistribution,
71  const std::vector<int>& dofDistribution);
72  int createDenseReducedLabeling(const std::vector<short>& reducedMask,
73  bool useNodes);
74  void assignMPIRankToDOFs(std::vector<int>& mpiRankOfDOF, const std::vector<int>& distribution);
75 
76  void copyTable(int offset, int idOffset, int dofOffset, const NodeFile* in);
77  void gather(int* index, const NodeFile* in);
78  void gather_global(const std::vector<int>& index, const NodeFile* in);
79  void scatter(int* index, const NodeFile* in);
80 
81  void setCoordinates(const escript::Data& newX);
82  void setTags(const int newTag, const escript::Data& mask);
83  inline void updateTagList();
84 
85  std::pair<int,int> getDOFRange() const;
86 
87 private:
88  std::pair<int,int> getGlobalIdRange() const;
89  std::pair<int,int> getGlobalDOFRange() const;
90  std::pair<int,int> getGlobalNodeIDIndexRange() const;
91  int prepareLabeling(const std::vector<short>& mask,
92  std::vector<int>& buffer,
93  std::vector<int>& distribution, bool useNodes);
94  void createDOFMappingAndCoupling(bool reduced);
95 
97 
98 public:
100  // these should be private as well.
101 
105 
109  int numNodes;
111  int numDim;
113  int *Id;
115  int *Tag;
117  std::vector<int> tagsInUse;
123  double *Coordinates;
132 
137 
140 
145 
148  int status;
149 };
150 
151 //
152 // implementation of inline methods
153 //
154 
155 inline int NodeFile::getFirstNode() const
156 {
158 }
159 
160 inline int NodeFile::getLastNode() const
161 {
163 }
164 
165 inline int NodeFile::getGlobalNumNodes() const
166 {
168 }
169 
171 {
172  return globalNodesIndex;
173 }
174 
176 {
178 }
179 
181 {
183 }
184 
186 {
188 }
189 
191 {
193 }
194 
195 inline int NodeFile::getNumNodes() const
196 {
197  return numNodes;
198 }
199 
201 {
203 }
204 
206 {
208 }
209 
211 {
213 }
214 
215 inline const std::vector<int>& NodeFile::borrowNodesTarget() const
216 {
217  return nodesMapping.map;
218 }
219 
220 inline const std::vector<int>& NodeFile::borrowReducedNodesTarget() const
221 {
222  return reducedNodesMapping.map;
223 }
224 
225 inline const std::vector<int>& NodeFile::borrowDegreesOfFreedomTarget() const
226 {
228 }
229 
230 inline const std::vector<int>& NodeFile::borrowReducedDegreesOfFreedomTarget() const
231 {
233 }
234 
235 inline const int* NodeFile::borrowTargetNodes() const
236 {
237  return &nodesMapping.target[0];
238 }
239 
240 inline const int* NodeFile::borrowTargetReducedNodes() const
241 {
242  return &reducedNodesMapping.target[0];
243 }
244 
245 inline const int* NodeFile::borrowTargetDegreesOfFreedom() const
246 {
247  return &degreesOfFreedomMapping.target[0];
248 }
249 
251 {
253 }
254 
256 {
258 }
259 
260 
261 } // namespace finley
262 
263 #endif // __FINLEY_NODEFILE_H__
264