/[escript]/trunk/finley/src/NodeFile.h
ViewVC logotype

Contents of /trunk/finley/src/NodeFile.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (show annotations)
Mon Jan 20 03:37:18 2020 UTC (4 months, 1 week ago) by uqaeller
File MIME type: text/plain
File size: 10091 byte(s)
Updated the copyright header.


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
35 namespace escript {
36 struct IndexList;
37 }
38
39 namespace finley {
40
41 class NodeFile
42 {
43 public:
44
45 /// constructor - creates empty node file.
46 /// Use allocTable() to allocate the node table (Id,Coordinates).
47 NodeFile(int nDim, escript::JMPI MPIInfo);
48
49 /// destructor
50 ~NodeFile();
51
52 /// allocates the node table within this node file to hold numNodes nodes.
53 void allocTable(dim_t numNodes);
54
55 /// empties the node table and frees all memory
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
70 /// returns the number of FEM nodes (on this rank)
71 inline dim_t getNumNodes() const;
72
73 /// returns the number of reduced order FEM nodes (on this rank)
74 inline dim_t getNumReducedNodes() const;
75
76 /// returns the number of degrees of freedom (on this rank)
77 inline dim_t getNumDegreesOfFreedom() const;
78
79 /// returns the number of reduced order degrees of freedom (on this rank)
80 inline dim_t getNumReducedDegreesOfFreedom() const;
81
82 /// returns the number of degrees of freedom targets (own and shared)
83 inline dim_t getNumDegreesOfFreedomTargets() const;
84
85 /// returns the number of reduced degrees of freedom targets (own and shared)
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
96 /// returns the mapping from local nodes to a target
97 inline const index_t* borrowTargetNodes() const;
98 inline const index_t* borrowTargetReducedDegreesOfFreedom() const;
99
100 inline void updateTagList();
101
102 /// creates a dense labeling of the global degrees of freedom and returns
103 /// the new number of global degrees of freedom
104 dim_t createDenseDOFLabeling();
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
123 /// gathers nodes from the NodeFile `in` using the entries in
124 /// index[0:numNodes-1] which are between min_index and max_index
125 /// (exclusive)
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
133 /// set tags to newTag where mask > 0
134 void setTags(int newTag, const escript::Data& mask);
135
136 std::pair<index_t,index_t> getDOFRange() const;
137
138 private:
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
146 NodeMapping nodesMapping;
147 NodeMapping degreesOfFreedomMapping;
148 NodeMapping reducedDegreesOfFreedomMapping;
149
150 /// number of nodes
151 dim_t numNodes;
152
153 public:
154 ///////////////////////////////////////
155 // these should be private as well.
156
157 NodeMapping reducedNodesMapping;
158
159 /// MPI information
160 escript::JMPI MPIInfo;
161 /// number of spatial dimensions
162 int numDim;
163 /// Id[i] is the unique ID number of FEM node i
164 index_t* Id;
165 /// Tag[i] is the tag of node i
166 int* Tag;
167 /// vector of tags which are actually used
168 std::vector<int> tagsInUse;
169
170 /// globalDegreesOfFreedom[i] is the global degree of freedom assigned
171 /// to node i. This index is used to consider periodic boundary conditions
172 /// by assigning the same degree of freedom to different nodes.
173 index_t* globalDegreesOfFreedom;
174 /// Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i
175 double* Coordinates;
176 /// assigns each local node a global unique ID in a dense labeling of
177 /// reduced DOF. Value <0 indicates that the DOF is not used.
178 index_t* globalReducedDOFIndex;
179 /// assigns each local reduced node a global unique ID in a dense labeling
180 /// Value <0 indicates that the DOF is not used
181 index_t* globalReducedNodesIndex;
182 /// assigns each local node a global unique ID in a dense labeling
183 index_t* globalNodesIndex;
184
185 /// MPI distribution of nodes
186 escript::Distribution_ptr nodesDistribution;
187 escript::Distribution_ptr reducedNodesDistribution;
188 escript::Distribution_ptr degreesOfFreedomDistribution;
189 escript::Distribution_ptr reducedDegreesOfFreedomDistribution;
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;
204 index_t* degreesOfFreedomId;
205 index_t* reducedDegreesOfFreedomId;
206
207 /// the status counts the updates done on the node coordinates.
208 /// The value is increased by 1 when the node coordinates are updated.
209 int status;
210 };
211
212 //
213 // implementation of inline methods
214 //
215
216 inline index_t NodeFile::getFirstNode() const
217 {
218 return nodesDistribution->getFirstComponent();
219 }
220
221 inline index_t NodeFile::getLastNode() const
222 {
223 return nodesDistribution->getLastComponent();
224 }
225
226 inline dim_t NodeFile::getGlobalNumNodes() const
227 {
228 return nodesDistribution->getGlobalNumComponents();
229 }
230
231 inline const index_t* NodeFile::borrowGlobalNodesIndex() const
232 {
233 return globalNodesIndex;
234 }
235
236 inline index_t NodeFile::getFirstReducedNode() const
237 {
238 return reducedNodesDistribution->getFirstComponent();
239 }
240
241 inline index_t NodeFile::getLastReducedNode() const
242 {
243 return reducedNodesDistribution->getLastComponent();
244 }
245
246 inline dim_t NodeFile::getGlobalNumReducedNodes() const
247 {
248 return reducedNodesDistribution->getGlobalNumComponents();
249 }
250
251 inline const index_t* NodeFile::borrowGlobalReducedNodesIndex() const
252 {
253 return globalReducedNodesIndex;
254 }
255
256 inline dim_t NodeFile::getNumNodes() const
257 {
258 return numNodes;
259 }
260
261 inline dim_t NodeFile::getNumReducedNodes() const
262 {
263 return reducedNodesMapping.getNumTargets();
264 }
265
266 inline dim_t NodeFile::getNumDegreesOfFreedom() const
267 {
268 return degreesOfFreedomDistribution->getMyNumComponents();
269 }
270
271 inline dim_t NodeFile::getNumReducedDegreesOfFreedom() const
272 {
273 return reducedDegreesOfFreedomDistribution->getMyNumComponents();
274 }
275
276 inline dim_t NodeFile::getNumDegreesOfFreedomTargets() const
277 {
278 return degreesOfFreedomMapping.getNumTargets();
279 }
280
281 inline dim_t NodeFile::getNumReducedDegreesOfFreedomTargets() const
282 {
283 return reducedDegreesOfFreedomMapping.getNumTargets();
284 }
285
286 inline const IndexVector& NodeFile::borrowNodesTarget() const
287 {
288 return nodesMapping.map;
289 }
290
291 inline const IndexVector& NodeFile::borrowReducedNodesTarget() const
292 {
293 return reducedNodesMapping.map;
294 }
295
296 inline const IndexVector& NodeFile::borrowDegreesOfFreedomTarget() const
297 {
298 return degreesOfFreedomMapping.map;
299 }
300
301 inline const IndexVector& NodeFile::borrowReducedDegreesOfFreedomTarget() const
302 {
303 return reducedDegreesOfFreedomMapping.map;
304 }
305
306 inline const index_t* NodeFile::borrowTargetNodes() const
307 {
308 return &nodesMapping.target[0];
309 }
310
311 inline const index_t* NodeFile::borrowTargetReducedNodes() const
312 {
313 return &reducedNodesMapping.target[0];
314 }
315
316 inline const index_t* NodeFile::borrowTargetDegreesOfFreedom() const
317 {
318 return &degreesOfFreedomMapping.target[0];
319 }
320
321 inline const index_t* NodeFile::borrowTargetReducedDegreesOfFreedom() const
322 {
323 return &reducedDegreesOfFreedomMapping.target[0];
324 }
325
326 inline void NodeFile::updateTagList()
327 {
328 util::setValuesInUse(Tag, numNodes, tagsInUse, MPIInfo);
329 }
330
331
332 } // namespace finley
333
334 #endif // __FINLEY_NODEFILE_H__
335

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26