escript Revision_
finley/src/NodeFile.h
Go to the documentation of this file.
1
2/*****************************************************************************
3*
4* Copyright (c) 2003-2020 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-2017 by Centre for Geoscience Computing (GeoComp)
14* Development from 2019 by School of Earth and Environmental Sciences
15**
16*****************************************************************************/
17
18#ifndef __FINLEY_NODEFILE_H__
19#define __FINLEY_NODEFILE_H__
20
21#define MAX_numDim 3
22
23#include "Finley.h"
24#include "NodeMapping.h"
25
26#include <escript/Distribution.h>
27
28#ifdef ESYS_HAVE_PASO
29#include <paso/Coupler.h>
30#endif
31#ifdef ESYS_HAVE_TRILINOS
32#include <trilinoswrap/types.h>
33#endif
34
35namespace escript {
36 struct IndexList;
37}
38
39namespace finley {
40
42{
43public:
44
48
50 ~NodeFile();
51
53 void allocTable(dim_t numNodes);
54
56 void freeTable();
57
58 void print() const;
59
60 inline index_t getFirstNode() const;
61 inline index_t getLastNode() const;
62 inline dim_t getGlobalNumNodes() const;
63 inline const index_t* borrowGlobalNodesIndex() const;
64
65 inline index_t getFirstReducedNode() const;
66 inline index_t getLastReducedNode() const;
67 inline index_t getGlobalNumReducedNodes() const;
68 inline const index_t* borrowGlobalReducedNodesIndex() const;
69
71 inline dim_t getNumNodes() const;
72
74 inline dim_t getNumReducedNodes() const;
75
77 inline dim_t getNumDegreesOfFreedom() const;
78
80 inline dim_t getNumReducedDegreesOfFreedom() const;
81
83 inline dim_t getNumDegreesOfFreedomTargets() const;
84
86 inline dim_t getNumReducedDegreesOfFreedomTargets() const;
87
88 inline const IndexVector& borrowReducedNodesTarget() const;
89 inline const IndexVector& borrowDegreesOfFreedomTarget() const;
90 inline const IndexVector& borrowNodesTarget() const;
91 inline const IndexVector& borrowReducedDegreesOfFreedomTarget() const;
92
93 inline const index_t* borrowTargetReducedNodes() const;
94 inline const index_t* borrowTargetDegreesOfFreedom() const;
95
97 inline const index_t* borrowTargetNodes() const;
98 inline const index_t* borrowTargetReducedDegreesOfFreedom() const;
99
100 inline void updateTagList();
101
105
106 dim_t createDenseNodeLabeling(IndexVector& nodeDistribution,
107 const IndexVector& dofDistribution);
108
109 dim_t createDenseReducedLabeling(const std::vector<short>& reducedMask,
110 bool useNodes);
111
112 void createNodeMappings(const IndexVector& indexReducedNodes,
113 const IndexVector& dofDistribution,
114 const IndexVector& nodeDistribution);
115
116
117 void assignMPIRankToDOFs(std::vector<int>& mpiRankOfDOF,
118 const IndexVector& distribution);
119
120 void copyTable(index_t offset, index_t idOffset, index_t dofOffset,
121 const NodeFile* in);
122
126 void gather(const index_t* index, const NodeFile* in);
127
128 void gather_global(const index_t* index, const NodeFile* in);
129 void scatter(const index_t* index, const NodeFile* in);
130
131 void setCoordinates(const escript::Data& newX);
132
134 void setTags(int newTag, const escript::Data& mask);
135
136 std::pair<index_t,index_t> getDOFRange() const;
137
138private:
139 std::pair<index_t,index_t> getGlobalIdRange() const;
140 std::pair<index_t,index_t> getGlobalDOFRange() const;
141 std::pair<index_t,index_t> getGlobalNodeIDIndexRange() const;
142 dim_t prepareLabeling(const std::vector<short>& mask, IndexVector& buffer,
143 IndexVector& distribution, bool useNodes);
144 void createDOFMappingAndCoupling(bool reduced);
145
149
151 dim_t numNodes;
152
153public:
155 // these should be private as well.
156
158
164 index_t* Id;
166 int* Tag;
168 std::vector<int> tagsInUse;
169
175 double* Coordinates;
184
190
191#ifdef ESYS_HAVE_PASO
192 paso::Connector_ptr degreesOfFreedomConnector;
193 paso::Connector_ptr reducedDegreesOfFreedomConnector;
194#endif
195#ifdef ESYS_HAVE_TRILINOS
196 esys_trilinos::const_TrilinosMap_ptr trilinosRowMap;
197 esys_trilinos::const_TrilinosMap_ptr trilinosReducedRowMap;
198 esys_trilinos::const_TrilinosMap_ptr trilinosColMap;
199 esys_trilinos::const_TrilinosMap_ptr trilinosReducedColMap;
200#endif
201
202 // these are the packed versions of Id
203 index_t* reducedNodesId;
206
210};
211
212//
213// implementation of inline methods
214//
215
216inline index_t NodeFile::getFirstNode() const
217{
218 return nodesDistribution->getFirstComponent();
219}
220
221inline index_t NodeFile::getLastNode() const
222{
223 return nodesDistribution->getLastComponent();
224}
225
226inline dim_t NodeFile::getGlobalNumNodes() const
227{
228 return nodesDistribution->getGlobalNumComponents();
229}
230
231inline const index_t* NodeFile::borrowGlobalNodesIndex() const
232{
233 return globalNodesIndex;
234}
235
236inline index_t NodeFile::getFirstReducedNode() const
237{
238 return reducedNodesDistribution->getFirstComponent();
239}
240
241inline index_t NodeFile::getLastReducedNode() const
242{
243 return reducedNodesDistribution->getLastComponent();
244}
245
247{
248 return reducedNodesDistribution->getGlobalNumComponents();
249}
250
251inline const index_t* NodeFile::borrowGlobalReducedNodesIndex() const
252{
254}
255
256inline dim_t NodeFile::getNumNodes() const
257{
258 return numNodes;
259}
260
262{
264}
265
267{
268 return degreesOfFreedomDistribution->getMyNumComponents();
269}
270
272{
273 return reducedDegreesOfFreedomDistribution->getMyNumComponents();
274}
275
280
285
286inline const IndexVector& NodeFile::borrowNodesTarget() const
287{
288 return nodesMapping.map;
289}
290
291inline const IndexVector& NodeFile::borrowReducedNodesTarget() const
292{
294}
295
296inline const IndexVector& NodeFile::borrowDegreesOfFreedomTarget() const
297{
299}
300
301inline const IndexVector& NodeFile::borrowReducedDegreesOfFreedomTarget() const
302{
304}
305
306inline const index_t* NodeFile::borrowTargetNodes() const
307{
308 return &nodesMapping.target[0];
309}
310
311inline const index_t* NodeFile::borrowTargetReducedNodes() const
312{
313 return &reducedNodesMapping.target[0];
314}
315
316inline const index_t* NodeFile::borrowTargetDegreesOfFreedom() const
317{
319}
320
322{
324}
325
330
331
332} // namespace finley
333
334#endif // __FINLEY_NODEFILE_H__
335
Data represents a collection of datapoints.
Definition Data.h:64
Definition finley/src/NodeFile.h:42
std::pair< index_t, index_t > getGlobalDOFRange() const
Definition finley/src/NodeFile.cpp:231
dim_t getNumReducedNodes() const
returns the number of reduced order FEM nodes (on this rank)
Definition finley/src/NodeFile.h:261
double * Coordinates
Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i.
Definition finley/src/NodeFile.h:175
~NodeFile()
destructor
Definition finley/src/NodeFile.cpp:122
void updateTagList()
Definition finley/src/NodeFile.h:326
NodeMapping reducedNodesMapping
Definition finley/src/NodeFile.h:157
index_t getLastReducedNode() const
Definition finley/src/NodeFile.h:241
void copyTable(index_t offset, index_t idOffset, index_t dofOffset, const NodeFile *in)
Definition finley/src/NodeFile.cpp:285
const index_t * borrowTargetReducedDegreesOfFreedom() const
Definition finley/src/NodeFile.h:321
void createDOFMappingAndCoupling(bool reduced)
Definition finley/src/NodeFile.cpp:772
dim_t getNumDegreesOfFreedomTargets() const
returns the number of degrees of freedom targets (own and shared)
Definition finley/src/NodeFile.h:276
index_t * globalNodesIndex
assigns each local node a global unique ID in a dense labeling
Definition finley/src/NodeFile.h:183
index_t getGlobalNumReducedNodes() const
Definition finley/src/NodeFile.h:246
void freeTable()
empties the node table and frees all memory
Definition finley/src/NodeFile.cpp:162
index_t * globalReducedNodesIndex
Definition finley/src/NodeFile.h:181
escript::Distribution_ptr degreesOfFreedomDistribution
Definition finley/src/NodeFile.h:188
void gather(const index_t *index, const NodeFile *in)
Definition finley/src/NodeFile.cpp:321
dim_t createDenseDOFLabeling()
Definition finley/src/NodeFile.cpp:525
index_t * globalDegreesOfFreedom
Definition finley/src/NodeFile.h:173
escript::JMPI MPIInfo
MPI information.
Definition finley/src/NodeFile.h:160
const index_t * borrowGlobalReducedNodesIndex() const
Definition finley/src/NodeFile.h:251
void allocTable(dim_t numNodes)
allocates the node table within this node file to hold numNodes nodes.
Definition finley/src/NodeFile.cpp:127
int status
Definition finley/src/NodeFile.h:209
index_t * globalReducedDOFIndex
Definition finley/src/NodeFile.h:178
escript::Distribution_ptr reducedNodesDistribution
Definition finley/src/NodeFile.h:187
std::pair< index_t, index_t > getGlobalIdRange() const
Definition finley/src/NodeFile.cpp:226
index_t getFirstNode() const
Definition finley/src/NodeFile.h:216
dim_t createDenseNodeLabeling(IndexVector &nodeDistribution, const IndexVector &dofDistribution)
Definition finley/src/NodeFile.cpp:588
void print() const
Definition finley/src/NodeFile.cpp:196
std::pair< index_t, index_t > getGlobalNodeIDIndexRange() const
Definition finley/src/NodeFile.cpp:236
dim_t getGlobalNumNodes() const
Definition finley/src/NodeFile.h:226
escript::Distribution_ptr reducedDegreesOfFreedomDistribution
Definition finley/src/NodeFile.h:189
index_t getFirstReducedNode() const
Definition finley/src/NodeFile.h:236
NodeMapping degreesOfFreedomMapping
Definition finley/src/NodeFile.h:147
index_t getLastNode() const
Definition finley/src/NodeFile.h:221
const IndexVector & borrowDegreesOfFreedomTarget() const
Definition finley/src/NodeFile.h:296
const IndexVector & borrowNodesTarget() const
Definition finley/src/NodeFile.h:286
void scatter(const index_t *index, const NodeFile *in)
Definition finley/src/NodeFile.cpp:310
dim_t getNumReducedDegreesOfFreedom() const
returns the number of reduced order degrees of freedom (on this rank)
Definition finley/src/NodeFile.h:271
dim_t getNumDegreesOfFreedom() const
returns the number of degrees of freedom (on this rank)
Definition finley/src/NodeFile.h:266
index_t * degreesOfFreedomId
Definition finley/src/NodeFile.h:204
void setCoordinates(const escript::Data &newX)
copies the array newX into this->coordinates
Definition finley/src/NodeFile.cpp:242
void createNodeMappings(const IndexVector &indexReducedNodes, const IndexVector &dofDistribution, const IndexVector &nodeDistribution)
Definition finley/src/NodeFile.cpp:1004
NodeMapping reducedDegreesOfFreedomMapping
Definition finley/src/NodeFile.h:148
dim_t createDenseReducedLabeling(const std::vector< short > &reducedMask, bool useNodes)
Definition finley/src/NodeFile.cpp:702
NodeMapping nodesMapping
Definition finley/src/NodeFile.h:146
int * Tag
Tag[i] is the tag of node i.
Definition finley/src/NodeFile.h:166
const IndexVector & borrowReducedDegreesOfFreedomTarget() const
Definition finley/src/NodeFile.h:301
const index_t * borrowTargetReducedNodes() const
Definition finley/src/NodeFile.h:311
index_t * reducedDegreesOfFreedomId
Definition finley/src/NodeFile.h:205
dim_t getNumReducedDegreesOfFreedomTargets() const
returns the number of reduced degrees of freedom targets (own and shared)
Definition finley/src/NodeFile.h:281
index_t * reducedNodesId
Definition finley/src/NodeFile.h:203
dim_t numNodes
number of nodes
Definition finley/src/NodeFile.h:151
void assignMPIRankToDOFs(std::vector< int > &mpiRankOfDOF, const IndexVector &distribution)
Definition finley/src/NodeFile.cpp:438
const index_t * borrowTargetNodes() const
returns the mapping from local nodes to a target
Definition finley/src/NodeFile.h:306
const index_t * borrowTargetDegreesOfFreedom() const
Definition finley/src/NodeFile.h:316
const IndexVector & borrowReducedNodesTarget() const
Definition finley/src/NodeFile.h:291
const index_t * borrowGlobalNodesIndex() const
Definition finley/src/NodeFile.h:231
dim_t prepareLabeling(const std::vector< short > &mask, IndexVector &buffer, IndexVector &distribution, bool useNodes)
Definition finley/src/NodeFile.cpp:464
index_t * Id
Id[i] is the unique ID number of FEM node i.
Definition finley/src/NodeFile.h:164
void setTags(int newTag, const escript::Data &mask)
set tags to newTag where mask > 0
Definition finley/src/NodeFile.cpp:267
void gather_global(const index_t *index, const NodeFile *in)
Definition finley/src/NodeFile.cpp:329
std::pair< index_t, index_t > getDOFRange() const
Definition finley/src/NodeFile.cpp:215
dim_t getNumNodes() const
returns the number of FEM nodes (on this rank)
Definition finley/src/NodeFile.h:256
int numDim
number of spatial dimensions
Definition finley/src/NodeFile.h:162
std::vector< int > tagsInUse
vector of tags which are actually used
Definition finley/src/NodeFile.h:168
escript::Distribution_ptr nodesDistribution
MPI distribution of nodes.
Definition finley/src/NodeFile.h:186
Definition AbstractContinuousDomain.cpp:23
boost::shared_ptr< Distribution > Distribution_ptr
Definition Distribution.h:26
boost::shared_ptr< JMPI_ > JMPI
Definition EsysMPI.h:76
void setValuesInUse(const int *values, dim_t numValues, std::vector< int > &valuesInUse, escript::JMPI mpiinfo)
Definition finley/src/Util.cpp:343
A suite of factory methods for creating various finley domains.
Definition finley/src/Assemble.h:32
boost::shared_ptr< Connector > Connector_ptr
Definition Coupler.h:39
Definition finley/src/NodeMapping.h:30
std::vector< index_t > target
target[i] defines the target of FEM node i=0,...,numNodes-1
Definition finley/src/NodeMapping.h:82
std::vector< index_t > map
maps the target nodes back to the FEM nodes: target[map[i]]=i
Definition finley/src/NodeMapping.h:84
dim_t getNumTargets() const
returns the number of target nodes (number of items in the map array)
Definition finley/src/NodeMapping.h:79