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 #include <paso/Coupler.h>
25 #include <paso/Distribution.h>
26 
27 
28 namespace finley {
29 
30 class NodeFile
31 {
32 public:
33  NodeFile(int nDim, esysUtils::JMPI& mpiInfo);
34  ~NodeFile();
35 
37  void freeTable();
38 
39  void print() const;
40  inline index_t getFirstNode() const;
41  inline index_t getLastNode() const;
42  inline index_t getGlobalNumNodes() const;
43  inline index_t* borrowGlobalNodesIndex() const;
44 
45  inline index_t getFirstReducedNode() const;
46  inline index_t getLastReducedNode() const;
47  inline index_t getGlobalNumReducedNodes() const;
48  inline index_t* borrowGlobalReducedNodesIndex() const;
49 
51  inline dim_t getNumNodes() const;
52  inline dim_t getNumReducedNodes() const;
53  inline dim_t getNumDegreesOfFreedom() const;
54  inline dim_t getNumReducedDegreesOfFreedom() const;
55 
56  inline const std::vector<index_t>& borrowReducedNodesTarget() const;
57  inline const std::vector<index_t>& borrowDegreesOfFreedomTarget() const;
58  inline const std::vector<index_t>& borrowNodesTarget() const;
59  inline const std::vector<index_t>& borrowReducedDegreesOfFreedomTarget() const;
60 
61  inline const index_t* borrowTargetReducedNodes() const;
62  inline const index_t* borrowTargetDegreesOfFreedom() const;
63  inline const index_t* borrowTargetNodes() const;
64  inline const index_t* borrowTargetReducedDegreesOfFreedom() const;
65 
66  void createNodeMappings(const std::vector<index_t>& indexReducedNodes,
67  const std::vector<index_t>& dofDistribution,
68  const std::vector<index_t>& nodeDistribution);
70  dim_t createDenseNodeLabeling(std::vector<index_t>& nodeDistribution,
71  const std::vector<index_t>& dofDistribution);
72  dim_t createDenseReducedLabeling(const std::vector<short>& reducedMask,
73  bool useNodes);
74  void assignMPIRankToDOFs(std::vector<int>& mpiRankOfDOF, const std::vector<index_t>& distribution);
75 
76  void copyTable(index_t offset, index_t idOffset, index_t dofOffset,
77  const NodeFile* in);
78  void gather(const index_t* index, const NodeFile* in);
79  void gather_global(const index_t* index, const NodeFile* in);
80  void scatter(const index_t* index, const NodeFile* in);
81 
82  void setCoordinates(const escript::Data& newX);
83  void setTags(const int newTag, const escript::Data& mask);
84  inline void updateTagList();
85 
86  std::pair<index_t,index_t> getDOFRange() const;
87 
88 private:
89  std::pair<index_t,index_t> getGlobalIdRange() const;
90  std::pair<index_t,index_t> getGlobalDOFRange() const;
91  std::pair<index_t,index_t> getGlobalNodeIDIndexRange() const;
92  dim_t prepareLabeling(const std::vector<short>& mask,
93  std::vector<index_t>& buffer,
94  std::vector<index_t>& distribution, bool useNodes);
95  void createDOFMappingAndCoupling(bool reduced);
96 
98 
99 public:
101  // these should be private as well.
102 
106 
112  int numDim;
116  int *Tag;
118  std::vector<int> tagsInUse;
124  double *Coordinates;
133 
138 
141 
146 
149  int status;
150 };
151 
152 //
153 // implementation of inline methods
154 //
155 
157 {
158  return nodesDistribution->getFirstComponent();
159 }
160 
162 {
163  return nodesDistribution->getLastComponent();
164 }
165 
167 {
168  return nodesDistribution->getGlobalNumComponents();
169 }
170 
172 {
173  return globalNodesIndex;
174 }
175 
177 {
178  return reducedNodesDistribution->getFirstComponent();
179 }
180 
182 {
183  return reducedNodesDistribution->getLastComponent();
184 }
185 
187 {
188  return reducedNodesDistribution->getGlobalNumComponents();
189 }
190 
192 {
194 }
195 
197 {
198  return numNodes;
199 }
200 
202 {
204 }
205 
207 {
208  return degreesOfFreedomDistribution->getMyNumComponents();
209 }
210 
212 {
213  return reducedDegreesOfFreedomDistribution->getMyNumComponents();
214 }
215 
216 inline const std::vector<index_t>& NodeFile::borrowNodesTarget() const
217 {
218  return nodesMapping.map;
219 }
220 
221 inline const std::vector<index_t>& NodeFile::borrowReducedNodesTarget() const
222 {
223  return reducedNodesMapping.map;
224 }
225 
226 inline const std::vector<index_t>& NodeFile::borrowDegreesOfFreedomTarget() const
227 {
229 }
230 
231 inline const std::vector<index_t>& NodeFile::borrowReducedDegreesOfFreedomTarget() const
232 {
234 }
235 
237 {
238  return &nodesMapping.target[0];
239 }
240 
242 {
243  return &reducedNodesMapping.target[0];
244 }
245 
247 {
248  return &degreesOfFreedomMapping.target[0];
249 }
250 
252 {
254 }
255 
257 {
259 }
260 
261 
262 } // namespace finley
263 
264 #endif // __FINLEY_NODEFILE_H__
265 
void assignMPIRankToDOFs(std::vector< int > &mpiRankOfDOF, const std::vector< index_t > &distribution)
Definition: finley/src/NodeFile.cpp:459
const std::vector< index_t > & borrowReducedDegreesOfFreedomTarget() const
Definition: finley/src/NodeFile.h:231
paso::Connector_ptr degreesOfFreedomConnector
Definition: finley/src/NodeFile.h:139
paso::Distribution_ptr reducedDegreesOfFreedomDistribution
Definition: finley/src/NodeFile.h:137
index_t * degreesOfFreedomId
Definition: finley/src/NodeFile.h:144
index_t * borrowGlobalReducedNodesIndex() const
Definition: finley/src/NodeFile.h:191
index_t * Id
Id[i] is the id number of node i. It needs to be unique.
Definition: finley/src/NodeFile.h:114
std::pair< index_t, index_t > getGlobalNodeIDIndexRange() const
Definition: finley/src/NodeFile.cpp:292
void gather(const index_t *index, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:347
NodeMapping nodesMapping
Definition: finley/src/NodeFile.h:97
std::vector< int > tagsInUse
vector of tags which are actually used
Definition: finley/src/NodeFile.h:118
void copyTable(index_t offset, index_t idOffset, index_t dofOffset, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:310
int numDim
number of spatial dimensions
Definition: finley/src/NodeFile.h:112
int status
Definition: finley/src/NodeFile.h:149
const std::vector< index_t > & borrowNodesTarget() const
Definition: finley/src/NodeFile.h:216
const std::vector< index_t > & borrowReducedNodesTarget() const
Definition: finley/src/NodeFile.h:221
void createDOFMappingAndCoupling(bool reduced)
Definition: finley/src/NodeFile.cpp:791
dim_t getNumReducedDegreesOfFreedom() const
Definition: finley/src/NodeFile.h:211
const index_t * borrowTargetReducedDegreesOfFreedom() const
Definition: finley/src/NodeFile.h:251
dim_t getNumDegreesOfFreedom() const
Definition: finley/src/NodeFile.h:206
paso::Distribution_ptr degreesOfFreedomDistribution
Definition: finley/src/NodeFile.h:136
NodeMapping degreesOfFreedomMapping
Definition: finley/src/NodeFile.h:104
void setValuesInUse(const int *values, const int numValues, std::vector< int > &valuesInUse, esysUtils::JMPI &mpiinfo)
Definition: finley/src/Util.cpp:350
index_t * globalReducedNodesIndex
Definition: finley/src/NodeFile.h:130
dim_t getNumNodes() const
returns the number of FEM nodes
Definition: finley/src/NodeFile.h:196
dim_t createDenseReducedLabeling(const std::vector< short > &reducedMask, bool useNodes)
Definition: finley/src/NodeFile.cpp:721
void scatter(const index_t *index, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:337
boost::shared_ptr< Distribution > Distribution_ptr
Definition: Distribution.h:36
index_t * globalDegreesOfFreedom
Definition: finley/src/NodeFile.h:122
void freeTable()
frees the node table within this node file
Definition: finley/src/NodeFile.cpp:150
index_t getFirstReducedNode() const
Definition: finley/src/NodeFile.h:176
void createNodeMappings(const std::vector< index_t > &indexReducedNodes, const std::vector< index_t > &dofDistribution, const std::vector< index_t > &nodeDistribution)
Definition: finley/src/NodeFile.cpp:1007
dim_t getNumReducedNodes() const
Definition: finley/src/NodeFile.h:201
Definition: finley/src/Assemble.h:32
index_t * reducedNodesId
these are the packed versions of Id
Definition: finley/src/NodeFile.h:143
index_t getFirstNode() const
Definition: finley/src/NodeFile.h:156
dim_t prepareLabeling(const std::vector< short > &mask, std::vector< index_t > &buffer, std::vector< index_t > &distribution, bool useNodes)
Definition: finley/src/NodeFile.cpp:483
void gather_global(const index_t *index, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:355
void allocTable(dim_t numNodes)
allocates the node table within this node file to hold NN nodes.
Definition: finley/src/NodeFile.cpp:114
index_t * globalReducedDOFIndex
Definition: finley/src/NodeFile.h:127
paso::Distribution_ptr nodesDistribution
Definition: finley/src/NodeFile.h:134
dim_t getNumTargets() const
returns the number of target nodes (number of items in the map array)
Definition: finley/src/NodeMapping.h:75
Definition: finley/src/NodeMapping.h:29
index_t getLastReducedNode() const
Definition: finley/src/NodeFile.h:181
std::pair< index_t, index_t > getGlobalDOFRange() const
Definition: finley/src/NodeFile.cpp:273
NodeFile(int nDim, esysUtils::JMPI &mpiInfo)
Definition: finley/src/NodeFile.cpp:89
Data represents a collection of datapoints.
Definition: Data.h:68
void updateTagList()
Definition: finley/src/NodeFile.h:256
Definition: finley/src/NodeFile.h:30
std::vector< index_t > target
target[i] defines the target of FEM node i=0,...,numNodes-1
Definition: finley/src/NodeMapping.h:78
dim_t createDenseDOFLabeling()
Definition: finley/src/NodeFile.cpp:544
index_t * reducedDegreesOfFreedomId
Definition: finley/src/NodeFile.h:145
void print() const
Definition: finley/src/NodeFile.cpp:177
void setTags(const int newTag, const escript::Data &mask)
sets tags to newTag where mask>0
Definition: finley/src/NodeFile.cpp:223
std::vector< index_t > map
maps the target nodes back to the FEM nodes: target[map[i]]=i
Definition: finley/src/NodeMapping.h:80
esysUtils::JMPI MPIInfo
MPI information.
Definition: finley/src/NodeFile.h:108
int index_t
Definition: types.h:24
const index_t * borrowTargetNodes() const
Definition: finley/src/NodeFile.h:236
std::pair< index_t, index_t > getGlobalIdRange() const
Definition: finley/src/NodeFile.cpp:255
index_t getGlobalNumReducedNodes() const
Definition: finley/src/NodeFile.h:186
void setCoordinates(const escript::Data &newX)
copies the array newX into this->coordinates
Definition: finley/src/NodeFile.cpp:197
const index_t * borrowTargetReducedNodes() const
Definition: finley/src/NodeFile.h:241
dim_t createDenseNodeLabeling(std::vector< index_t > &nodeDistribution, const std::vector< index_t > &dofDistribution)
Definition: finley/src/NodeFile.cpp:607
boost::shared_ptr< Connector > Connector_ptr
Definition: Coupler.h:35
paso::Distribution_ptr reducedNodesDistribution
Definition: finley/src/NodeFile.h:135
const std::vector< index_t > & borrowDegreesOfFreedomTarget() const
Definition: finley/src/NodeFile.h:226
index_t dim_t
Definition: types.h:27
NodeMapping reducedNodesMapping
Definition: finley/src/NodeFile.h:103
index_t getGlobalNumNodes() const
Definition: finley/src/NodeFile.h:166
index_t * borrowGlobalNodesIndex() const
Definition: finley/src/NodeFile.h:171
NodeMapping reducedDegreesOfFreedomMapping
Definition: finley/src/NodeFile.h:105
dim_t numNodes
number of nodes
Definition: finley/src/NodeFile.h:110
double * Coordinates
Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i.
Definition: finley/src/NodeFile.h:124
const index_t * borrowTargetDegreesOfFreedom() const
Definition: finley/src/NodeFile.h:246
boost::shared_ptr< JMPI_ > JMPI
Definition: Esys_MPI.h:79
std::pair< index_t, index_t > getDOFRange() const
Definition: finley/src/NodeFile.cpp:244
index_t getLastNode() const
Definition: finley/src/NodeFile.h:161
int * Tag
Tag[i] is the tag of node i.
Definition: finley/src/NodeFile.h:116
paso::Connector_ptr reducedDegreesOfFreedomConnector
Definition: finley/src/NodeFile.h:140
index_t * globalNodesIndex
assigns each local reduced node a global unique Id in a dense labeling
Definition: finley/src/NodeFile.h:132
~NodeFile()
destructor
Definition: finley/src/NodeFile.cpp:108