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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (hide 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 jgs 82
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 jfenwick 6651 * Copyright (c) 2003-2018 by The University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
7     * Primary Business: Queensland, Australia
8 jfenwick 6112 * Licensed under the Apache License, version 2.0
9     * http://www.apache.org/licenses/LICENSE-2.0
10 ksteube 1811 *
11 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13     * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 *
15     *****************************************************************************/
16 ksteube 1312
17 caltinay 4431 #ifndef __FINLEY_NODEFILE_H__
18     #define __FINLEY_NODEFILE_H__
19 ksteube 1811
20 jgs 82 #define MAX_numDim 3
21    
22 jgs 150 #include "Finley.h"
23 ksteube 1312 #include "NodeMapping.h"
24 caltinay 6001
25 caltinay 6197 #include <escript/Distribution.h>
26    
27     #ifdef ESYS_HAVE_PASO
28 caltinay 4817 #include <paso/Coupler.h>
29 caltinay 6197 #endif
30 caltinay 6215 #ifdef ESYS_HAVE_TRILINOS
31     #include <trilinoswrap/types.h>
32     #endif
33 jgs 82
34 caltinay 6215 namespace escript {
35     struct IndexList;
36     }
37 caltinay 4492
38 caltinay 4428 namespace finley {
39 gross 776
40 caltinay 4428 class NodeFile
41     {
42     public:
43 caltinay 6197
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 caltinay 4428 ~NodeFile();
50 ksteube 1312
51 caltinay 6197 /// allocates the node table within this node file to hold numNodes nodes.
52 caltinay 5692 void allocTable(dim_t numNodes);
53 caltinay 6197
54     /// empties the node table and frees all memory
55 caltinay 4428 void freeTable();
56    
57 caltinay 4492 void print() const;
58 caltinay 6197
59 caltinay 5692 inline index_t getFirstNode() const;
60     inline index_t getLastNode() const;
61 caltinay 6197 inline dim_t getGlobalNumNodes() const;
62     inline const index_t* borrowGlobalNodesIndex() const;
63 caltinay 4428
64 caltinay 5692 inline index_t getFirstReducedNode() const;
65     inline index_t getLastReducedNode() const;
66     inline index_t getGlobalNumReducedNodes() const;
67 caltinay 6197 inline const index_t* borrowGlobalReducedNodesIndex() const;
68 caltinay 4428
69 caltinay 6197 /// returns the number of FEM nodes (on this rank)
70 caltinay 5692 inline dim_t getNumNodes() const;
71 caltinay 6197
72     /// returns the number of reduced order FEM nodes (on this rank)
73 caltinay 5692 inline dim_t getNumReducedNodes() const;
74 caltinay 6197
75     /// returns the number of degrees of freedom (on this rank)
76 caltinay 5692 inline dim_t getNumDegreesOfFreedom() const;
77 caltinay 6197
78     /// returns the number of reduced order degrees of freedom (on this rank)
79 caltinay 5692 inline dim_t getNumReducedDegreesOfFreedom() const;
80 caltinay 4428
81 caltinay 6215 /// returns the number of degrees of freedom targets (own and shared)
82     inline dim_t getNumDegreesOfFreedomTargets() const;
83    
84 caltinay 6216 /// returns the number of reduced degrees of freedom targets (own and shared)
85     inline dim_t getNumReducedDegreesOfFreedomTargets() const;
86    
87 caltinay 6197 inline const IndexVector& borrowReducedNodesTarget() const;
88     inline const IndexVector& borrowDegreesOfFreedomTarget() const;
89     inline const IndexVector& borrowNodesTarget() const;
90     inline const IndexVector& borrowReducedDegreesOfFreedomTarget() const;
91 caltinay 4428
92 caltinay 5692 inline const index_t* borrowTargetReducedNodes() const;
93     inline const index_t* borrowTargetDegreesOfFreedom() const;
94 caltinay 6197
95     /// returns the mapping from local nodes to a target
96 caltinay 5692 inline const index_t* borrowTargetNodes() const;
97     inline const index_t* borrowTargetReducedDegreesOfFreedom() const;
98 caltinay 4428
99 caltinay 6215 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 caltinay 5787 dim_t createDenseDOFLabeling();
104 caltinay 6215
105 caltinay 6197 dim_t createDenseNodeLabeling(IndexVector& nodeDistribution,
106     const IndexVector& dofDistribution);
107 caltinay 6215
108 caltinay 5787 dim_t createDenseReducedLabeling(const std::vector<short>& reducedMask,
109     bool useNodes);
110 caltinay 4428
111 caltinay 6215 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 caltinay 5787 void copyTable(index_t offset, index_t idOffset, index_t dofOffset,
120     const NodeFile* in);
121 caltinay 6197
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 caltinay 5708 void gather(const index_t* index, const NodeFile* in);
126 caltinay 6197
127 caltinay 5708 void gather_global(const index_t* index, const NodeFile* in);
128     void scatter(const index_t* index, const NodeFile* in);
129 caltinay 4428
130     void setCoordinates(const escript::Data& newX);
131 caltinay 6197
132     /// set tags to newTag where mask > 0
133     void setTags(int newTag, const escript::Data& mask);
134 caltinay 4428
135 caltinay 5692 std::pair<index_t,index_t> getDOFRange() const;
136 caltinay 4428
137     private:
138 caltinay 5692 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 caltinay 6197 dim_t prepareLabeling(const std::vector<short>& mask, IndexVector& buffer,
142     IndexVector& distribution, bool useNodes);
143 caltinay 4492 void createDOFMappingAndCoupling(bool reduced);
144 caltinay 4428
145 caltinay 4492 NodeMapping nodesMapping;
146 caltinay 6215 NodeMapping degreesOfFreedomMapping;
147 caltinay 6216 NodeMapping reducedDegreesOfFreedomMapping;
148 caltinay 6197
149     /// number of nodes
150     dim_t numNodes;
151    
152 caltinay 4428 public:
153     ///////////////////////////////////////
154 caltinay 4492 // these should be private as well.
155 caltinay 4428
156 caltinay 4492 NodeMapping reducedNodesMapping;
157    
158 caltinay 4428 /// MPI information
159 caltinay 5997 escript::JMPI MPIInfo;
160 caltinay 4428 /// number of spatial dimensions
161     int numDim;
162 caltinay 6197 /// 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 caltinay 4428 /// vector of tags which are actually used
167     std::vector<int> tagsInUse;
168 caltinay 6197
169 caltinay 4428 /// globalDegreesOfFreedom[i] is the global degree of freedom assigned
170     /// to node i. This index is used to consider periodic boundary conditions
171 caltinay 6197 /// by assigning the same degree of freedom to different nodes.
172 caltinay 5692 index_t* globalDegreesOfFreedom;
173 caltinay 4428 /// Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i
174 caltinay 6197 double* Coordinates;
175     /// assigns each local node a global unique ID in a dense labeling of
176 caltinay 4428 /// reduced DOF. Value <0 indicates that the DOF is not used.
177 caltinay 6197 index_t* globalReducedDOFIndex;
178     /// assigns each local reduced node a global unique ID in a dense labeling
179 caltinay 4428 /// Value <0 indicates that the DOF is not used
180 caltinay 6197 index_t* globalReducedNodesIndex;
181     /// assigns each local node a global unique ID in a dense labeling
182     index_t* globalNodesIndex;
183 caltinay 4428
184 caltinay 6215 /// MPI distribution of nodes
185 caltinay 6197 escript::Distribution_ptr nodesDistribution;
186     escript::Distribution_ptr reducedNodesDistribution;
187     escript::Distribution_ptr degreesOfFreedomDistribution;
188     escript::Distribution_ptr reducedDegreesOfFreedomDistribution;
189 ksteube 1312
190 caltinay 6197 #ifdef ESYS_HAVE_PASO
191 caltinay 4817 paso::Connector_ptr degreesOfFreedomConnector;
192     paso::Connector_ptr reducedDegreesOfFreedomConnector;
193 caltinay 6197 #endif
194 caltinay 6216 #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 ksteube 1312
201 caltinay 6215 // these are the packed versions of Id
202 caltinay 6197 index_t* reducedNodesId;
203     index_t* degreesOfFreedomId;
204     index_t* reducedDegreesOfFreedomId;
205 ksteube 1312
206 caltinay 4428 /// 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 jgs 82 };
210    
211 caltinay 4428 //
212     // implementation of inline methods
213     //
214 bcumming 730
215 caltinay 5692 inline index_t NodeFile::getFirstNode() const
216 caltinay 4428 {
217 caltinay 4814 return nodesDistribution->getFirstComponent();
218 caltinay 4428 }
219 bcumming 730
220 caltinay 5692 inline index_t NodeFile::getLastNode() const
221 caltinay 4428 {
222 caltinay 4814 return nodesDistribution->getLastComponent();
223 caltinay 4428 }
224 jgs 82
225 caltinay 6197 inline dim_t NodeFile::getGlobalNumNodes() const
226 caltinay 4428 {
227 caltinay 4814 return nodesDistribution->getGlobalNumComponents();
228 caltinay 4428 }
229 ksteube 1312
230 caltinay 6197 inline const index_t* NodeFile::borrowGlobalNodesIndex() const
231 caltinay 4428 {
232 caltinay 4492 return globalNodesIndex;
233 caltinay 4428 }
234 ksteube 1312
235 caltinay 5692 inline index_t NodeFile::getFirstReducedNode() const
236 caltinay 4428 {
237 caltinay 4814 return reducedNodesDistribution->getFirstComponent();
238 caltinay 4428 }
239 ksteube 1312
240 caltinay 5692 inline index_t NodeFile::getLastReducedNode() const
241 caltinay 4428 {
242 caltinay 4814 return reducedNodesDistribution->getLastComponent();
243 caltinay 4428 }
244 ksteube 1312
245 caltinay 5692 inline dim_t NodeFile::getGlobalNumReducedNodes() const
246 caltinay 4428 {
247 caltinay 4814 return reducedNodesDistribution->getGlobalNumComponents();
248 caltinay 4428 }
249 bcumming 730
250 caltinay 6197 inline const index_t* NodeFile::borrowGlobalReducedNodesIndex() const
251 caltinay 4428 {
252 caltinay 4492 return globalReducedNodesIndex;
253 caltinay 4428 }
254 gross 1749
255 caltinay 5692 inline dim_t NodeFile::getNumNodes() const
256 caltinay 4428 {
257 caltinay 4492 return numNodes;
258 caltinay 4428 }
259 ksteube 1312
260 caltinay 5692 inline dim_t NodeFile::getNumReducedNodes() const
261 caltinay 4428 {
262 caltinay 4492 return reducedNodesMapping.getNumTargets();
263 caltinay 4428 }
264 ksteube 1312
265 caltinay 5692 inline dim_t NodeFile::getNumDegreesOfFreedom() const
266 caltinay 4428 {
267 caltinay 4814 return degreesOfFreedomDistribution->getMyNumComponents();
268 caltinay 4428 }
269 jgs 82
270 caltinay 5692 inline dim_t NodeFile::getNumReducedDegreesOfFreedom() const
271 caltinay 4428 {
272 caltinay 4814 return reducedDegreesOfFreedomDistribution->getMyNumComponents();
273 caltinay 4428 }
274    
275 caltinay 6215 inline dim_t NodeFile::getNumDegreesOfFreedomTargets() const
276     {
277     return degreesOfFreedomMapping.getNumTargets();
278     }
279    
280 caltinay 6216 inline dim_t NodeFile::getNumReducedDegreesOfFreedomTargets() const
281     {
282     return reducedDegreesOfFreedomMapping.getNumTargets();
283     }
284    
285 caltinay 6197 inline const IndexVector& NodeFile::borrowNodesTarget() const
286 caltinay 4428 {
287 caltinay 4492 return nodesMapping.map;
288 caltinay 4428 }
289    
290 caltinay 6197 inline const IndexVector& NodeFile::borrowReducedNodesTarget() const
291 caltinay 4428 {
292 caltinay 4492 return reducedNodesMapping.map;
293 caltinay 4428 }
294    
295 caltinay 6197 inline const IndexVector& NodeFile::borrowDegreesOfFreedomTarget() const
296 caltinay 4428 {
297 caltinay 4492 return degreesOfFreedomMapping.map;
298 caltinay 4428 }
299    
300 caltinay 6197 inline const IndexVector& NodeFile::borrowReducedDegreesOfFreedomTarget() const
301 caltinay 4428 {
302 caltinay 4492 return reducedDegreesOfFreedomMapping.map;
303 caltinay 4428 }
304    
305 caltinay 5692 inline const index_t* NodeFile::borrowTargetNodes() const
306 caltinay 4428 {
307 caltinay 4492 return &nodesMapping.target[0];
308 caltinay 4428 }
309    
310 caltinay 5692 inline const index_t* NodeFile::borrowTargetReducedNodes() const
311 caltinay 4428 {
312 caltinay 4492 return &reducedNodesMapping.target[0];
313 caltinay 4428 }
314    
315 caltinay 5692 inline const index_t* NodeFile::borrowTargetDegreesOfFreedom() const
316 caltinay 4428 {
317 caltinay 4492 return &degreesOfFreedomMapping.target[0];
318 caltinay 4428 }
319    
320 caltinay 5692 inline const index_t* NodeFile::borrowTargetReducedDegreesOfFreedom() const
321 caltinay 4428 {
322 caltinay 4492 return &reducedDegreesOfFreedomMapping.target[0];
323 caltinay 4428 }
324    
325 caltinay 4441 inline void NodeFile::updateTagList()
326     {
327     util::setValuesInUse(Tag, numNodes, tagsInUse, MPIInfo);
328     }
329 caltinay 4428
330 caltinay 4441
331 caltinay 4431 } // namespace finley
332 caltinay 4428
333 caltinay 4431 #endif // __FINLEY_NODEFILE_H__
334 jgs 82

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26