escript  Revision_
finley/src/NodeFile.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2018 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 
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 
86 
87  inline const IndexVector& borrowReducedNodesTarget() const;
88  inline const IndexVector& borrowDegreesOfFreedomTarget() const;
89  inline const IndexVector& borrowNodesTarget() 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 
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 
150  dim_t numNodes;
151 
152 public:
154  // these should be private as well.
155 
157 
161  int numDim;
163  index_t* Id;
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 
236 {
237  return reducedNodesDistribution->getFirstComponent();
238 }
239 
241 {
242  return reducedNodesDistribution->getLastComponent();
243 }
244 
246 {
247  return reducedNodesDistribution->getGlobalNumComponents();
248 }
249 
251 {
253 }
254 
255 inline dim_t NodeFile::getNumNodes() const
256 {
257  return numNodes;
258 }
259 
260 inline dim_t NodeFile::getNumReducedNodes() const
261 {
263 }
264 
266 {
267  return degreesOfFreedomDistribution->getMyNumComponents();
268 }
269 
271 {
272  return reducedDegreesOfFreedomDistribution->getMyNumComponents();
273 }
274 
276 {
278 }
279 
281 {
283 }
284 
285 inline const IndexVector& NodeFile::borrowNodesTarget() const
286 {
287  return nodesMapping.map;
288 }
289 
291 {
292  return reducedNodesMapping.map;
293 }
294 
296 {
298 }
299 
301 {
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 
316 {
317  return &degreesOfFreedomMapping.target[0];
318 }
319 
321 {
323 }
324 
325 inline void NodeFile::updateTagList()
326 {
328 }
329 
330 
331 } // namespace finley
332 
333 #endif // __FINLEY_NODEFILE_H__
334 
finley::NodeFile::updateTagList
void updateTagList()
Definition: finley/src/NodeFile.h:324
finley::NodeFile::NodeFile
NodeFile(int nDim, escript::JMPI MPIInfo)
Definition: finley/src/NodeFile.cpp:114
finley::NodeFile::globalReducedNodesIndex
index_t * globalReducedNodesIndex
Definition: finley/src/NodeFile.h:179
finley::NodeMapping
Definition: finley/src/NodeMapping.h:40
finley::NodeFile::createDenseDOFLabeling
dim_t createDenseDOFLabeling()
Definition: finley/src/NodeFile.cpp:535
finley::NodeFile::borrowReducedNodesTarget
const IndexVector & borrowReducedNodesTarget() const
Definition: finley/src/NodeFile.h:289
finley::NodeFile::borrowTargetReducedNodes
const index_t * borrowTargetReducedNodes() const
Definition: finley/src/NodeFile.h:309
finley::NodeFile::getGlobalIdRange
std::pair< index_t, index_t > getGlobalIdRange() const
Definition: finley/src/NodeFile.cpp:236
finley::NodeFile::globalDegreesOfFreedom
index_t * globalDegreesOfFreedom
Definition: finley/src/NodeFile.h:171
escript::Distribution_ptr
boost::shared_ptr< Distribution > Distribution_ptr
Definition: Distribution.h:35
finley::NodeFile::borrowGlobalReducedNodesIndex
const index_t * borrowGlobalReducedNodesIndex() const
Definition: finley/src/NodeFile.h:249
finley::NodeFile::getGlobalDOFRange
std::pair< index_t, index_t > getGlobalDOFRange() const
Definition: finley/src/NodeFile.cpp:241
finley::NodeFile::getNumReducedNodes
dim_t getNumReducedNodes() const
returns the number of reduced order FEM nodes (on this rank)
Definition: finley/src/NodeFile.h:259
finley::NodeFile::assignMPIRankToDOFs
void assignMPIRankToDOFs(std::vector< int > &mpiRankOfDOF, const IndexVector &distribution)
Definition: finley/src/NodeFile.cpp:448
finley::NodeFile::Tag
int * Tag
Tag[i] is the tag of node i.
Definition: finley/src/NodeFile.h:164
finley::NodeFile::getFirstNode
index_t getFirstNode() const
Definition: finley/src/NodeFile.h:214
finley::NodeFile::nodesDistribution
escript::Distribution_ptr nodesDistribution
MPI distribution of nodes.
Definition: finley/src/NodeFile.h:184
finley::NodeFile::reducedNodesId
index_t * reducedNodesId
Definition: finley/src/NodeFile.h:201
finley::NodeFile::globalReducedDOFIndex
index_t * globalReducedDOFIndex
Definition: finley/src/NodeFile.h:176
finley::NodeFile::getNumDegreesOfFreedomTargets
dim_t getNumDegreesOfFreedomTargets() const
returns the number of degrees of freedom targets (own and shared)
Definition: finley/src/NodeFile.h:274
finley::NodeFile::numNodes
dim_t numNodes
number of nodes
Definition: finley/src/NodeFile.h:149
finley::NodeFile::reducedNodesMapping
NodeMapping reducedNodesMapping
Definition: finley/src/NodeFile.h:155
finley::NodeFile::gather
void gather(const index_t *index, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:331
finley::NodeFile::createDOFMappingAndCoupling
void createDOFMappingAndCoupling(bool reduced)
Definition: finley/src/NodeFile.cpp:782
finley::NodeFile::getGlobalNodeIDIndexRange
std::pair< index_t, index_t > getGlobalNodeIDIndexRange() const
Definition: finley/src/NodeFile.cpp:246
finley::NodeFile::borrowReducedDegreesOfFreedomTarget
const IndexVector & borrowReducedDegreesOfFreedomTarget() const
Definition: finley/src/NodeFile.h:299
finley::NodeFile::getNumReducedDegreesOfFreedom
dim_t getNumReducedDegreesOfFreedom() const
returns the number of reduced order degrees of freedom (on this rank)
Definition: finley/src/NodeFile.h:269
finley::NodeMapping::target
std::vector< index_t > target
target[i] defines the target of FEM node i=0,...,numNodes-1
Definition: finley/src/NodeMapping.h:104
finley::NodeFile::reducedDegreesOfFreedomMapping
NodeMapping reducedDegreesOfFreedomMapping
Definition: finley/src/NodeFile.h:146
finley::util::setValuesInUse
void setValuesInUse(const int *values, dim_t numValues, std::vector< int > &valuesInUse, escript::JMPI mpiinfo)
Definition: finley/src/Util.cpp:365
finley::NodeFile::getNumNodes
dim_t getNumNodes() const
returns the number of FEM nodes (on this rank)
Definition: finley/src/NodeFile.h:254
finley::NodeFile::createNodeMappings
void createNodeMappings(const IndexVector &indexReducedNodes, const IndexVector &dofDistribution, const IndexVector &nodeDistribution)
Definition: finley/src/NodeFile.cpp:1014
finley::NodeFile::Coordinates
double * Coordinates
Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i.
Definition: finley/src/NodeFile.h:173
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:62
finley::NodeFile::getLastNode
index_t getLastNode() const
Definition: finley/src/NodeFile.h:219
finley::NodeFile::getGlobalNumReducedNodes
index_t getGlobalNumReducedNodes() const
Definition: finley/src/NodeFile.h:244
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:87
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:70
NodeMapping.h
finley::NodeFile::borrowGlobalNodesIndex
const index_t * borrowGlobalNodesIndex() const
Definition: finley/src/NodeFile.h:229
finley::NodeFile::createDenseReducedLabeling
dim_t createDenseReducedLabeling(const std::vector< short > &reducedMask, bool useNodes)
Definition: finley/src/NodeFile.cpp:712
finley::NodeFile::~NodeFile
~NodeFile()
destructor
Definition: finley/src/NodeFile.cpp:132
finley::NodeFile::MPIInfo
escript::JMPI MPIInfo
MPI information.
Definition: finley/src/NodeFile.h:158
finley::NodeFile::prepareLabeling
dim_t prepareLabeling(const std::vector< short > &mask, IndexVector &buffer, IndexVector &distribution, bool useNodes)
Definition: finley/src/NodeFile.cpp:474
finley::NodeFile::freeTable
void freeTable()
empties the node table and frees all memory
Definition: finley/src/NodeFile.cpp:172
finley::NodeFile::borrowNodesTarget
const IndexVector & borrowNodesTarget() const
Definition: finley/src/NodeFile.h:284
finley::NodeMapping::map
std::vector< index_t > map
maps the target nodes back to the FEM nodes: target[map[i]]=i
Definition: finley/src/NodeMapping.h:106
finley::NodeFile::getFirstReducedNode
index_t getFirstReducedNode() const
Definition: finley/src/NodeFile.h:234
finley::NodeFile::Id
index_t * Id
Id[i] is the unique ID number of FEM node i.
Definition: finley/src/NodeFile.h:162
finley::NodeFile::createDenseNodeLabeling
dim_t createDenseNodeLabeling(IndexVector &nodeDistribution, const IndexVector &dofDistribution)
Definition: finley/src/NodeFile.cpp:598
finley::NodeFile::nodesMapping
NodeMapping nodesMapping
Definition: finley/src/NodeFile.h:144
finley::NodeFile::status
int status
Definition: finley/src/NodeFile.h:207
finley::NodeFile::setCoordinates
void setCoordinates(const escript::Data &newX)
copies the array newX into this->coordinates
Definition: finley/src/NodeFile.cpp:252
finley::NodeFile::print
void print() const
Definition: finley/src/NodeFile.cpp:206
finley::NodeFile::reducedDegreesOfFreedomDistribution
escript::Distribution_ptr reducedDegreesOfFreedomDistribution
Definition: finley/src/NodeFile.h:187
finley::NodeFile::degreesOfFreedomDistribution
escript::Distribution_ptr degreesOfFreedomDistribution
Definition: finley/src/NodeFile.h:186
finley::NodeFile::getDOFRange
std::pair< index_t, index_t > getDOFRange() const
Definition: finley/src/NodeFile.cpp:225
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:82
finley::NodeFile::getGlobalNumNodes
dim_t getGlobalNumNodes() const
Definition: finley/src/NodeFile.h:224
finley::NodeFile
Definition: finley/src/NodeFile.h:39
escript
Definition: AbstractContinuousDomain.cpp:22
finley::NodeFile::reducedDegreesOfFreedomId
index_t * reducedDegreesOfFreedomId
Definition: finley/src/NodeFile.h:203
finley::NodeFile::degreesOfFreedomMapping
NodeMapping degreesOfFreedomMapping
Definition: finley/src/NodeFile.h:145
finley::NodeFile::globalNodesIndex
index_t * globalNodesIndex
assigns each local node a global unique ID in a dense labeling
Definition: finley/src/NodeFile.h:181
finley::NodeFile::borrowTargetNodes
const index_t * borrowTargetNodes() const
returns the mapping from local nodes to a target
Definition: finley/src/NodeFile.h:304
Finley.h
finley::NodeFile::reducedNodesDistribution
escript::Distribution_ptr reducedNodesDistribution
Definition: finley/src/NodeFile.h:185
paso::Connector_ptr
boost::shared_ptr< Connector > Connector_ptr
Definition: Coupler.h:48
finley::NodeFile::borrowTargetDegreesOfFreedom
const index_t * borrowTargetDegreesOfFreedom() const
Definition: finley/src/NodeFile.h:314
finley::NodeFile::getNumDegreesOfFreedom
dim_t getNumDegreesOfFreedom() const
returns the number of degrees of freedom (on this rank)
Definition: finley/src/NodeFile.h:264
finley::NodeFile::getLastReducedNode
index_t getLastReducedNode() const
Definition: finley/src/NodeFile.h:239
finley::NodeFile::getNumReducedDegreesOfFreedomTargets
dim_t getNumReducedDegreesOfFreedomTargets() const
returns the number of reduced degrees of freedom targets (own and shared)
Definition: finley/src/NodeFile.h:279
finley::NodeFile::borrowTargetReducedDegreesOfFreedom
const index_t * borrowTargetReducedDegreesOfFreedom() const
Definition: finley/src/NodeFile.h:319
finley::NodeFile::degreesOfFreedomId
index_t * degreesOfFreedomId
Definition: finley/src/NodeFile.h:202
finley::NodeFile::scatter
void scatter(const index_t *index, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:320
finley::NodeFile::gather_global
void gather_global(const index_t *index, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:339
finley::NodeFile::tagsInUse
std::vector< int > tagsInUse
vector of tags which are actually used
Definition: finley/src/NodeFile.h:166
finley
A suite of factory methods for creating various finley domains.
Definition: finley/src/Assemble.h:31
finley::NodeFile::setTags
void setTags(int newTag, const escript::Data &mask)
set tags to newTag where mask > 0
Definition: finley/src/NodeFile.cpp:277
finley::NodeFile::numDim
int numDim
number of spatial dimensions
Definition: finley/src/NodeFile.h:160
finley::NodeFile::allocTable
void allocTable(dim_t numNodes)
allocates the node table within this node file to hold numNodes nodes.
Definition: finley/src/NodeFile.cpp:137
finley::NodeFile::borrowDegreesOfFreedomTarget
const IndexVector & borrowDegreesOfFreedomTarget() const
Definition: finley/src/NodeFile.h:294
finley::NodeFile::copyTable
void copyTable(index_t offset, index_t idOffset, index_t dofOffset, const NodeFile *in)
Definition: finley/src/NodeFile.cpp:295
escript::DataTypes::IndexVector
std::vector< index_t > IndexVector
Definition: DataTypes.h:85
finley::NodeMapping::getNumTargets
dim_t getNumTargets() const
returns the number of target nodes (number of items in the map array)
Definition: finley/src/NodeMapping.h:101