escript  Revision_
finley/src/NodeFile.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16 
17 #ifndef __FINLEY_NODEFILE_H__
18 #define __FINLEY_NODEFILE_H__
19 
20 #define MAX_numDim 3
21 
22 #include "Finley.h"
23 #include "NodeMapping.h"
24 
25 #include <escript/Distribution.h>
26 
27 #ifdef ESYS_HAVE_PASO
28 #include <paso/Coupler.h>
29 #endif
30 #ifdef ESYS_HAVE_TRILINOS
31 #include <trilinoswrap/types.h>
32 #endif
33 
34 namespace escript {
35  struct IndexList;
36 }
37 
38 namespace finley {
39 
40 class NodeFile
41 {
42 public:
43 
46  NodeFile(int nDim, escript::JMPI MPIInfo);
47 
49  ~NodeFile();
50 
52  void allocTable(dim_t numNodes);
53 
55  void freeTable();
56 
57  void print() const;
58 
59  inline index_t getFirstNode() const;
60  inline index_t getLastNode() const;
61  inline dim_t getGlobalNumNodes() const;
62  inline const index_t* borrowGlobalNodesIndex() const;
63 
64  inline index_t getFirstReducedNode() const;
65  inline index_t getLastReducedNode() const;
66  inline index_t getGlobalNumReducedNodes() const;
67  inline const index_t* borrowGlobalReducedNodesIndex() const;
68 
70  inline dim_t getNumNodes() const;
71 
73  inline dim_t getNumReducedNodes() const;
74 
76  inline dim_t getNumDegreesOfFreedom() const;
77 
79  inline dim_t getNumReducedDegreesOfFreedom() const;
80 
82  inline dim_t getNumDegreesOfFreedomTargets() const;
83 
85  inline dim_t getNumReducedDegreesOfFreedomTargets() const;
86 
87  inline const IndexVector& borrowReducedNodesTarget() const;
88  inline const IndexVector& borrowDegreesOfFreedomTarget() const;
89  inline const IndexVector& borrowNodesTarget() const;
90  inline const IndexVector& borrowReducedDegreesOfFreedomTarget() const;
91 
92  inline const index_t* borrowTargetReducedNodes() const;
93  inline const index_t* borrowTargetDegreesOfFreedom() const;
94 
96  inline const index_t* borrowTargetNodes() const;
97  inline const index_t* borrowTargetReducedDegreesOfFreedom() const;
98 
99  inline void updateTagList();
100 
103  dim_t createDenseDOFLabeling();
104 
105  dim_t createDenseNodeLabeling(IndexVector& nodeDistribution,
106  const IndexVector& dofDistribution);
107 
108  dim_t createDenseReducedLabeling(const std::vector<short>& reducedMask,
109  bool useNodes);
110 
111  void createNodeMappings(const IndexVector& indexReducedNodes,
112  const IndexVector& dofDistribution,
113  const IndexVector& nodeDistribution);
114 
115 
116  void assignMPIRankToDOFs(std::vector<int>& mpiRankOfDOF,
117  const IndexVector& distribution);
118 
119  void copyTable(index_t offset, index_t idOffset, index_t dofOffset,
120  const NodeFile* in);
121 
125  void gather(const index_t* index, const NodeFile* in);
126 
127  void gather_global(const index_t* index, const NodeFile* in);
128  void scatter(const index_t* index, const NodeFile* in);
129 
130  void setCoordinates(const escript::Data& newX);
131 
133  void setTags(int newTag, const escript::Data& mask);
134 
135  std::pair<index_t,index_t> getDOFRange() const;
136 
137 private:
138  std::pair<index_t,index_t> getGlobalIdRange() const;
139  std::pair<index_t,index_t> getGlobalDOFRange() const;
140  std::pair<index_t,index_t> getGlobalNodeIDIndexRange() const;
141  dim_t prepareLabeling(const std::vector<short>& mask, IndexVector& buffer,
142  IndexVector& distribution, bool useNodes);
143  void createDOFMappingAndCoupling(bool reduced);
144 
148 
151 
152 public:
154  // these should be private as well.
155 
157 
161  int numDim;
165  int* Tag;
167  std::vector<int> tagsInUse;
168 
174  double* Coordinates;
183 
189 
190 #ifdef ESYS_HAVE_PASO
191  paso::Connector_ptr degreesOfFreedomConnector;
192  paso::Connector_ptr reducedDegreesOfFreedomConnector;
193 #endif
194 #ifdef ESYS_HAVE_TRILINOS
195  esys_trilinos::const_TrilinosMap_ptr trilinosRowMap;
196  esys_trilinos::const_TrilinosMap_ptr trilinosReducedRowMap;
197  esys_trilinos::const_TrilinosMap_ptr trilinosColMap;
198  esys_trilinos::const_TrilinosMap_ptr trilinosReducedColMap;
199 #endif
200 
201  // these are the packed versions of Id
205 
208  int status;
209 };
210 
211 //
212 // implementation of inline methods
213 //
214 
215 inline index_t NodeFile::getFirstNode() const
216 {
217  return nodesDistribution->getFirstComponent();
218 }
219 
220 inline index_t NodeFile::getLastNode() const
221 {
222  return nodesDistribution->getLastComponent();
223 }
224 
225 inline dim_t NodeFile::getGlobalNumNodes() const
226 {
227  return nodesDistribution->getGlobalNumComponents();
228 }
229 
230 inline const index_t* NodeFile::borrowGlobalNodesIndex() const
231 {
232  return globalNodesIndex;
233 }
234 
235 inline index_t NodeFile::getFirstReducedNode() const
236 {
237  return reducedNodesDistribution->getFirstComponent();
238 }
239 
240 inline index_t NodeFile::getLastReducedNode() const
241 {
242  return reducedNodesDistribution->getLastComponent();
243 }
244 
245 inline dim_t NodeFile::getGlobalNumReducedNodes() const
246 {
247  return reducedNodesDistribution->getGlobalNumComponents();
248 }
249 
250 inline const index_t* NodeFile::borrowGlobalReducedNodesIndex() const
251 {
252  return globalReducedNodesIndex;
253 }
254 
255 inline dim_t NodeFile::getNumNodes() const
256 {
257  return numNodes;
258 }
259 
260 inline dim_t NodeFile::getNumReducedNodes() const
261 {
262  return reducedNodesMapping.getNumTargets();
263 }
264 
265 inline dim_t NodeFile::getNumDegreesOfFreedom() const
266 {
267  return degreesOfFreedomDistribution->getMyNumComponents();
268 }
269 
270 inline dim_t NodeFile::getNumReducedDegreesOfFreedom() const
271 {
272  return reducedDegreesOfFreedomDistribution->getMyNumComponents();
273 }
274 
275 inline dim_t NodeFile::getNumDegreesOfFreedomTargets() const
276 {
277  return degreesOfFreedomMapping.getNumTargets();
278 }
279 
280 inline dim_t NodeFile::getNumReducedDegreesOfFreedomTargets() const
281 {
282  return reducedDegreesOfFreedomMapping.getNumTargets();
283 }
284 
285 inline const IndexVector& NodeFile::borrowNodesTarget() const
286 {
287  return nodesMapping.map;
288 }
289 
290 inline const IndexVector& NodeFile::borrowReducedNodesTarget() const
291 {
292  return reducedNodesMapping.map;
293 }
294 
295 inline const IndexVector& NodeFile::borrowDegreesOfFreedomTarget() const
296 {
297  return degreesOfFreedomMapping.map;
298 }
299 
300 inline const IndexVector& NodeFile::borrowReducedDegreesOfFreedomTarget() const
301 {
302  return reducedDegreesOfFreedomMapping.map;
303 }
304 
305 inline const index_t* NodeFile::borrowTargetNodes() const
306 {
307  return &nodesMapping.target[0];
308 }
309 
310 inline const index_t* NodeFile::borrowTargetReducedNodes() const
311 {
312  return &reducedNodesMapping.target[0];
313 }
314 
315 inline const index_t* NodeFile::borrowTargetDegreesOfFreedom() const
316 {
317  return &degreesOfFreedomMapping.target[0];
318 }
319 
320 inline const index_t* NodeFile::borrowTargetReducedDegreesOfFreedom() const
321 {
322  return &reducedDegreesOfFreedomMapping.target[0];
323 }
324 
325 inline void NodeFile::updateTagList()
326 {
327  util::setValuesInUse(Tag, numNodes, tagsInUse, MPIInfo);
328 }
329 
330 
331 } // namespace finley
332 
333 #endif // __FINLEY_NODEFILE_H__
334 
index_t * degreesOfFreedomId
Definition: finley/src/NodeFile.h:203
index_t * Id
Id[i] is the unique ID number of FEM node i.
Definition: finley/src/NodeFile.h:163
escript::Distribution_ptr nodesDistribution
MPI distribution of nodes.
Definition: finley/src/NodeFile.h:185
NodeMapping nodesMapping
Definition: finley/src/NodeFile.h:145
std::vector< int > tagsInUse
vector of tags which are actually used
Definition: finley/src/NodeFile.h:167
int numDim
number of spatial dimensions
Definition: finley/src/NodeFile.h:161
int status
Definition: finley/src/NodeFile.h:208
escript::Distribution_ptr degreesOfFreedomDistribution
Definition: finley/src/NodeFile.h:187
Definition: AbstractContinuousDomain.cpp:22
escript::Distribution_ptr reducedDegreesOfFreedomDistribution
Definition: finley/src/NodeFile.h:188
boost::shared_ptr< Distribution > Distribution_ptr
Definition: Distribution.h:24
NodeMapping degreesOfFreedomMapping
Definition: finley/src/NodeFile.h:146
std::vector< index_t > IndexVector
Definition: DataTypes.h:62
index_t * globalReducedNodesIndex
Definition: finley/src/NodeFile.h:180
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:71
index_t * globalDegreesOfFreedom
Definition: finley/src/NodeFile.h:172
escript::Distribution_ptr reducedNodesDistribution
Definition: finley/src/NodeFile.h:186
A suite of factory methods for creating various finley domains.
Definition: finley/src/Assemble.h:31
index_t * reducedNodesId
Definition: finley/src/NodeFile.h:202
void setValuesInUse(const int *values, dim_t numValues, std::vector< int > &valuesInUse, escript::JMPI mpiinfo)
Definition: dudley/src/Util.cpp:215
index_t * globalReducedDOFIndex
Definition: finley/src/NodeFile.h:177
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:59
Definition: finley/src/NodeMapping.h:29
Data represents a collection of datapoints.
Definition: Data.h:63
Definition: finley/src/NodeFile.h:40
index_t * reducedDegreesOfFreedomId
Definition: finley/src/NodeFile.h:204
escript::JMPI MPIInfo
MPI information.
Definition: finley/src/NodeFile.h:159
void gather(int len, const index_t *index, int numData, const double *in, double *out)
Definition: dudley/src/Util.cpp:43
boost::shared_ptr< Connector > Connector_ptr
Definition: Coupler.h:37
NodeMapping reducedNodesMapping
Definition: finley/src/NodeFile.h:156
NodeMapping reducedDegreesOfFreedomMapping
Definition: finley/src/NodeFile.h:147
dim_t numNodes
number of nodes
Definition: finley/src/NodeFile.h:150
double * Coordinates
Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i.
Definition: finley/src/NodeFile.h:174
int * Tag
Tag[i] is the tag of node i.
Definition: finley/src/NodeFile.h:165
index_t * globalNodesIndex
assigns each local node a global unique ID in a dense labeling
Definition: finley/src/NodeFile.h:182
index_t dim_t
Definition: DataTypes.h:64