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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4496 - (show annotations)
Mon Jul 15 06:53:44 2013 UTC (6 years ago) by caltinay
File MIME type: text/plain
File size: 8017 byte(s)
finley (WIP):
-moved all of finley into its namespace
-introduced some shared pointers
-Mesh is now a class
-other bits and pieces...

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16 #ifndef __FINLEY_NODEFILE_H__
17 #define __FINLEY_NODEFILE_H__
18
19 #define MAX_numDim 3
20
21 #include "Finley.h"
22 #include "NodeMapping.h"
23 #include "Util.h"
24 #include <paso/Distribution.h>
25
26 struct Esys_MPIInfo;
27 struct Paso_Connector;
28
29 namespace finley {
30
31 class NodeFile
32 {
33 public:
34 NodeFile(int nDim, Esys_MPIInfo *mpiInfo);
35 ~NodeFile();
36
37 void allocTable(int numNodes);
38 void freeTable();
39
40 void print() const;
41 inline int getFirstNode() const;
42 inline int getLastNode() const;
43 inline int getGlobalNumNodes() const;
44 inline int* borrowGlobalNodesIndex() const;
45
46 inline int getFirstReducedNode() const;
47 inline int getLastReducedNode() const;
48 inline int getGlobalNumReducedNodes() const;
49 inline int* borrowGlobalReducedNodesIndex() const;
50
51 /// returns the number of FEM nodes
52 inline int getNumNodes() const;
53 inline int getNumReducedNodes() const;
54 inline int getNumDegreesOfFreedom() const;
55 inline int getNumReducedDegreesOfFreedom() const;
56
57 inline const std::vector<int>& borrowReducedNodesTarget() const;
58 inline const std::vector<int>& borrowDegreesOfFreedomTarget() const;
59 inline const std::vector<int>& borrowNodesTarget() const;
60 inline const std::vector<int>& borrowReducedDegreesOfFreedomTarget() const;
61
62 inline const int* borrowTargetReducedNodes() const;
63 inline const int* borrowTargetDegreesOfFreedom() const;
64 inline const int* borrowTargetNodes() const;
65 inline const int* borrowTargetReducedDegreesOfFreedom() const;
66
67 void createNodeMappings(const std::vector<int>& indexReducedNodes,
68 const std::vector<int>& dofDistribution,
69 const std::vector<int>& nodeDistribution);
70 int createDenseDOFLabeling();
71 int createDenseNodeLabeling(std::vector<int>& nodeDistribution,
72 const std::vector<int>& dofDistribution);
73 int createDenseReducedLabeling(const std::vector<short>& reducedMask,
74 bool useNodes);
75 void assignMPIRankToDOFs(std::vector<int>& mpiRankOfDOF, const std::vector<int>& distribution);
76
77 void copyTable(int offset, int idOffset, int dofOffset, const NodeFile* in);
78 void gather(int* index, const NodeFile* in);
79 void gather_global(const std::vector<int>& index, const NodeFile* in);
80 void scatter(int* index, const NodeFile* in);
81
82 void setCoordinates(const escript::Data& newX);
83 void setTags(const int newTag, const escript::Data& mask);
84 inline void updateTagList();
85
86 std::pair<int,int> getDOFRange() const;
87
88 private:
89 std::pair<int,int> getGlobalIdRange() const;
90 std::pair<int,int> getGlobalDOFRange() const;
91 std::pair<int,int> getGlobalNodeIDIndexRange() const;
92 int prepareLabeling(const std::vector<short>& mask,
93 std::vector<int>& buffer,
94 std::vector<int>& distribution, bool useNodes);
95 void createDOFMappingAndCoupling(bool reduced);
96
97 NodeMapping nodesMapping;
98
99 public:
100 ///////////////////////////////////////
101 // these should be private as well.
102
103 NodeMapping reducedNodesMapping;
104 NodeMapping degreesOfFreedomMapping;
105 NodeMapping reducedDegreesOfFreedomMapping;
106
107 /// MPI information
108 Esys_MPIInfo *MPIInfo;
109 /// number of nodes
110 int numNodes;
111 /// number of spatial dimensions
112 int numDim;
113 /// Id[i] is the id number of node i. It needs to be unique.
114 int *Id;
115 /// Tag[i] is the tag of node i.
116 int *Tag;
117 /// vector of tags which are actually used
118 std::vector<int> tagsInUse;
119 /// globalDegreesOfFreedom[i] is the global degree of freedom assigned
120 /// to node i. This index is used to consider periodic boundary conditions
121 /// by assigning the same degreesOfFreedom to the same node.
122 int* globalDegreesOfFreedom;
123 /// Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i
124 double *Coordinates;
125 /// assigns each local node a global unique Id in a dense labeling of
126 /// reduced DOF. Value <0 indicates that the DOF is not used.
127 int *globalReducedDOFIndex;
128 /// assigns each local node a global unique Id in a dense labeling.
129 /// Value <0 indicates that the DOF is not used
130 int *globalReducedNodesIndex;
131 /// assigns each local reduced node a global unique Id in a dense labeling
132 int *globalNodesIndex;
133
134 Paso_Distribution *nodesDistribution;
135 Paso_Distribution *reducedNodesDistribution;
136 Paso_Distribution *degreesOfFreedomDistribution;
137 Paso_Distribution *reducedDegreesOfFreedomDistribution;
138
139 Paso_Connector* degreesOfFreedomConnector;
140 Paso_Connector *reducedDegreesOfFreedomConnector;
141
142 /// these are the packed versions of Id
143 int *reducedNodesId;
144 int *degreesOfFreedomId;
145 int *reducedDegreesOfFreedomId;
146
147 /// the status counts the updates done on the node coordinates.
148 /// The value is increased by 1 when the node coordinates are updated.
149 int status;
150 };
151
152 //
153 // implementation of inline methods
154 //
155
156 inline int NodeFile::getFirstNode() const
157 {
158 return Paso_Distribution_getFirstComponent(nodesDistribution);
159 }
160
161 inline int NodeFile::getLastNode() const
162 {
163 return Paso_Distribution_getLastComponent(nodesDistribution);
164 }
165
166 inline int NodeFile::getGlobalNumNodes() const
167 {
168 return Paso_Distribution_getGlobalNumComponents(nodesDistribution);
169 }
170
171 inline int* NodeFile::borrowGlobalNodesIndex() const
172 {
173 return globalNodesIndex;
174 }
175
176 inline int NodeFile::getFirstReducedNode() const
177 {
178 return Paso_Distribution_getFirstComponent(reducedNodesDistribution);
179 }
180
181 inline int NodeFile::getLastReducedNode() const
182 {
183 return Paso_Distribution_getLastComponent(reducedNodesDistribution);
184 }
185
186 inline int NodeFile::getGlobalNumReducedNodes() const
187 {
188 return Paso_Distribution_getGlobalNumComponents(reducedNodesDistribution);
189 }
190
191 inline int* NodeFile::borrowGlobalReducedNodesIndex() const
192 {
193 return globalReducedNodesIndex;
194 }
195
196 inline int NodeFile::getNumNodes() const
197 {
198 return numNodes;
199 }
200
201 inline int NodeFile::getNumReducedNodes() const
202 {
203 return reducedNodesMapping.getNumTargets();
204 }
205
206 inline int NodeFile::getNumDegreesOfFreedom() const
207 {
208 return Paso_Distribution_getMyNumComponents(degreesOfFreedomDistribution);
209 }
210
211 inline int NodeFile::getNumReducedDegreesOfFreedom() const
212 {
213 return Paso_Distribution_getMyNumComponents(reducedDegreesOfFreedomDistribution);
214 }
215
216 inline const std::vector<int>& NodeFile::borrowNodesTarget() const
217 {
218 return nodesMapping.map;
219 }
220
221 inline const std::vector<int>& NodeFile::borrowReducedNodesTarget() const
222 {
223 return reducedNodesMapping.map;
224 }
225
226 inline const std::vector<int>& NodeFile::borrowDegreesOfFreedomTarget() const
227 {
228 return degreesOfFreedomMapping.map;
229 }
230
231 inline const std::vector<int>& NodeFile::borrowReducedDegreesOfFreedomTarget() const
232 {
233 return reducedDegreesOfFreedomMapping.map;
234 }
235
236 inline const int* NodeFile::borrowTargetNodes() const
237 {
238 return &nodesMapping.target[0];
239 }
240
241 inline const int* NodeFile::borrowTargetReducedNodes() const
242 {
243 return &reducedNodesMapping.target[0];
244 }
245
246 inline const int* NodeFile::borrowTargetDegreesOfFreedom() const
247 {
248 return &degreesOfFreedomMapping.target[0];
249 }
250
251 inline const int* NodeFile::borrowTargetReducedDegreesOfFreedom() const
252 {
253 return &reducedDegreesOfFreedomMapping.target[0];
254 }
255
256 inline void NodeFile::updateTagList()
257 {
258 util::setValuesInUse(Tag, numNodes, tagsInUse, MPIInfo);
259 }
260
261
262 } // namespace finley
263
264 #endif // __FINLEY_NODEFILE_H__
265

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26