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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (show annotations)
Wed Feb 7 02:12:08 2018 UTC (20 months, 1 week ago) by jfenwick
File MIME type: text/plain
File size: 10015 byte(s)
Make everyone sad by touching all the files

Copyright dates update

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
44 /// constructor - creates empty node file.
45 /// Use allocTable() to allocate the node table (Id,Coordinates).
46 NodeFile(int nDim, escript::JMPI MPIInfo);
47
48 /// destructor
49 ~NodeFile();
50
51 /// allocates the node table within this node file to hold numNodes nodes.
52 void allocTable(dim_t numNodes);
53
54 /// empties the node table and frees all memory
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
69 /// returns the number of FEM nodes (on this rank)
70 inline dim_t getNumNodes() const;
71
72 /// returns the number of reduced order FEM nodes (on this rank)
73 inline dim_t getNumReducedNodes() const;
74
75 /// returns the number of degrees of freedom (on this rank)
76 inline dim_t getNumDegreesOfFreedom() const;
77
78 /// returns the number of reduced order degrees of freedom (on this rank)
79 inline dim_t getNumReducedDegreesOfFreedom() const;
80
81 /// returns the number of degrees of freedom targets (own and shared)
82 inline dim_t getNumDegreesOfFreedomTargets() const;
83
84 /// returns the number of reduced degrees of freedom targets (own and shared)
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
95 /// returns the mapping from local nodes to a target
96 inline const index_t* borrowTargetNodes() const;
97 inline const index_t* borrowTargetReducedDegreesOfFreedom() const;
98
99 inline void updateTagList();
100
101 /// creates a dense labeling of the global degrees of freedom and returns
102 /// the new number of global degrees of freedom
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
122 /// gathers nodes from the NodeFile `in` using the entries in
123 /// index[0:numNodes-1] which are between min_index and max_index
124 /// (exclusive)
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
132 /// set tags to newTag where mask > 0
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
145 NodeMapping nodesMapping;
146 NodeMapping degreesOfFreedomMapping;
147 NodeMapping reducedDegreesOfFreedomMapping;
148
149 /// number of nodes
150 dim_t numNodes;
151
152 public:
153 ///////////////////////////////////////
154 // these should be private as well.
155
156 NodeMapping reducedNodesMapping;
157
158 /// MPI information
159 escript::JMPI MPIInfo;
160 /// number of spatial dimensions
161 int numDim;
162 /// Id[i] is the unique ID number of FEM node i
163 index_t* Id;
164 /// Tag[i] is the tag of node i
165 int* Tag;
166 /// vector of tags which are actually used
167 std::vector<int> tagsInUse;
168
169 /// globalDegreesOfFreedom[i] is the global degree of freedom assigned
170 /// to node i. This index is used to consider periodic boundary conditions
171 /// by assigning the same degree of freedom to different nodes.
172 index_t* globalDegreesOfFreedom;
173 /// Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i
174 double* Coordinates;
175 /// assigns each local node a global unique ID in a dense labeling of
176 /// reduced DOF. Value <0 indicates that the DOF is not used.
177 index_t* globalReducedDOFIndex;
178 /// assigns each local reduced node a global unique ID in a dense labeling
179 /// Value <0 indicates that the DOF is not used
180 index_t* globalReducedNodesIndex;
181 /// assigns each local node a global unique ID in a dense labeling
182 index_t* globalNodesIndex;
183
184 /// MPI distribution of nodes
185 escript::Distribution_ptr nodesDistribution;
186 escript::Distribution_ptr reducedNodesDistribution;
187 escript::Distribution_ptr degreesOfFreedomDistribution;
188 escript::Distribution_ptr reducedDegreesOfFreedomDistribution;
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
202 index_t* reducedNodesId;
203 index_t* degreesOfFreedomId;
204 index_t* reducedDegreesOfFreedomId;
205
206 /// the status counts the updates done on the node coordinates.
207 /// The value is increased by 1 when the node coordinates are updated.
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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26