/[escript]/branches/trilinos_from_5897/dudley/src/NodeFile.h
ViewVC logotype

Contents of /branches/trilinos_from_5897/dudley/src/NodeFile.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6079 - (show annotations)
Mon Mar 21 12:22:38 2016 UTC (2 years, 11 months ago) by caltinay
File MIME type: text/plain
File size: 6570 byte(s)
Big commit - making dudley much more like finley to make it more
managable. Fixed quite a few issues that had been fixed in finley.
Disposed of all ReducedNode/ReducedDOF entities that dudley never supported.
Compiles and passes tests.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The 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 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17 #ifndef __DUDLEY_NODEFILE_H__
18 #define __DUDLEY_NODEFILE_H__
19
20 #include "Dudley.h"
21 #include "NodeMapping.h"
22
23 #include <paso/Distribution.h>
24 #include <paso/Coupler.h>
25
26 namespace dudley {
27
28 class NodeFile
29 {
30 public:
31
32 /// constructor - creates empty node file.
33 /// Use allocTable() to allocate the node table (Id,Coordinates).
34 NodeFile(int nDim, escript::JMPI MPIInfo);
35
36 /// destructor
37 ~NodeFile();
38
39 /// allocates the node table within this node file to hold numNodes nodes.
40 void allocTable(dim_t numNodes);
41
42 /// empties the node table and frees all memory
43 void freeTable();
44
45 void print() const;
46
47 inline index_t getFirstNode() const;
48 inline index_t getLastNode() const;
49 inline dim_t getGlobalNumNodes() const;
50 inline const index_t* borrowGlobalNodesIndex() const;
51
52 /// returns the number of FEM nodes (on this rank)
53 inline dim_t getNumNodes() const;
54
55 /// returns the number of degrees of freedom (on this rank)
56 inline dim_t getNumDegreesOfFreedom() const;
57
58 /// returns the number of degrees of freedom targets (own and shared)
59 inline dim_t getNumDegreesOfFreedomTargets() const;
60
61 /// returns the mapping from target to the local nodes
62 inline const index_t* borrowNodesTarget() const;
63
64 /// returns the mapping from target to the local degrees of freedom
65 inline const index_t* borrowDegreesOfFreedomTarget() const;
66
67 /// returns the mapping from local degrees of freedom to a target
68 inline const index_t* borrowTargetDegreesOfFreedom() const;
69
70 /// returns the mapping from local nodes to a target
71 inline const index_t* borrowTargetNodes() const;
72
73 inline void updateTagList();
74
75 /// creates a dense labeling of the global degrees of freedom and returns
76 /// the new number of global degrees of freedom
77 dim_t createDenseDOFLabeling();
78
79 dim_t createDenseNodeLabeling(std::vector<index_t>& nodeDistribution,
80 const std::vector<index_t>& dofDistribution);
81
82 void createNodeMappings(const std::vector<index_t>& dofDistribution,
83 const std::vector<index_t>& nodeDistribution);
84
85 void assignMPIRankToDOFs(int* mpiRankOfDOF,
86 const std::vector<index_t>& distribution);
87
88 void copyTable(index_t offset, index_t idOffset, index_t dofOffset,
89 const NodeFile* in);
90
91 /// gathers nodes from the NodeFile `in` using the entries in
92 /// index[0:numNodes-1] which are between min_index and max_index
93 /// (exclusive)
94 void gather(const index_t* index, const NodeFile* in);
95
96 void gather_global(const index_t* index, const NodeFile* in);
97
98 void setCoordinates(const escript::Data& newX);
99
100 /// set tags to newTag where mask > 0
101 void setTags(int newTag, const escript::Data& mask);
102
103 std::pair<index_t,index_t> getDOFRange() const;
104
105 private:
106 std::pair<index_t,index_t> getGlobalIdRange() const;
107 std::pair<index_t,index_t> getGlobalDOFRange() const;
108 std::pair<index_t,index_t> getGlobalNodeIDIndexRange() const;
109 dim_t prepareLabeling(const std::vector<short>& mask,
110 std::vector<index_t>& buffer,
111 std::vector<index_t>& distribution, bool useNodes);
112 void createDOFMappingAndCoupling();
113
114 NodeMapping nodesMapping;
115 NodeMapping degreesOfFreedomMapping;
116
117 /// number of nodes
118 dim_t numNodes;
119
120 public:
121 /// MPI information
122 escript::JMPI MPIInfo;
123 /// number of spatial dimensions
124 int numDim;
125 /// Id[i] is the unique ID number of FEM node i
126 index_t* Id;
127 /// Tag[i] is the tag of node i
128 int* Tag;
129 /// vector of tags which are actually used
130 std::vector<int> tagsInUse;
131
132 /// globalDegreesOfFreedom[i] is the global degree of freedom assigned
133 /// to node i. This index is used to consider periodic boundary conditions
134 /// by assigning the same degree of freedom to different nodes.
135 index_t* globalDegreesOfFreedom;
136 /// Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i
137 double* Coordinates;
138 /// assigns each local node a global unique ID in a dense labeling
139 index_t* globalNodesIndex;
140
141 /// MPI distribution of nodes
142 paso::Distribution_ptr nodesDistribution;
143
144 /// MPI distribution of degrees of freedom
145 paso::Distribution_ptr dofDistribution;
146
147 paso::Connector_ptr degreesOfFreedomConnector;
148
149 // these are the packed versions of Id
150 index_t* degreesOfFreedomId;
151
152 /// the status counts the updates done on the node coordinates.
153 /// The value is increased by 1 when the node coordinates are updated.
154 int status;
155 };
156
157 //
158 // implementation of inline methods
159 //
160
161 inline index_t NodeFile::getFirstNode() const
162 {
163 return nodesDistribution->getFirstComponent();
164 }
165
166 inline index_t NodeFile::getLastNode() const
167 {
168 return nodesDistribution->getLastComponent();
169 }
170
171 inline dim_t NodeFile::getGlobalNumNodes() const
172 {
173 return nodesDistribution->getGlobalNumComponents();
174 }
175
176 inline const index_t* NodeFile::borrowGlobalNodesIndex() const
177 {
178 return globalNodesIndex;
179 }
180
181 inline dim_t NodeFile::getNumNodes() const
182 {
183 return numNodes;
184 }
185
186 inline dim_t NodeFile::getNumDegreesOfFreedom() const
187 {
188 return dofDistribution->getMyNumComponents();
189 }
190
191 inline dim_t NodeFile::getNumDegreesOfFreedomTargets() const
192 {
193 return degreesOfFreedomMapping.numTargets;
194 }
195
196 inline const index_t* NodeFile::borrowNodesTarget() const
197 {
198 return nodesMapping.map;
199 }
200
201 inline const index_t* NodeFile::borrowDegreesOfFreedomTarget() const
202 {
203 return degreesOfFreedomMapping.map;
204 }
205
206 inline const index_t* NodeFile::borrowTargetNodes() const
207 {
208 return nodesMapping.target;
209 }
210
211 inline const index_t* NodeFile::borrowTargetDegreesOfFreedom() const
212 {
213 return degreesOfFreedomMapping.target;
214 }
215
216 inline void NodeFile::updateTagList()
217 {
218 util::setValuesInUse(Tag, numNodes, tagsInUse, MPIInfo);
219 }
220
221
222 } // namespace dudley
223
224 #endif // __DUDLEY_NODEFILE_H__
225

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26