escript  Revision_
dudley/src/NodeFile.h
Go to the documentation of this file.
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 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 __DUDLEY_NODEFILE_H__
18 #define __DUDLEY_NODEFILE_H__
19 
20 #include "Dudley.h"
21 #include "NodeMapping.h"
22 
23 #include <escript/Distribution.h>
24 
25 #ifdef ESYS_HAVE_PASO
26 #include <paso/Coupler.h>
27 #endif
28 #ifdef ESYS_HAVE_TRILINOS
29 #include <trilinoswrap/types.h>
30 #endif
31 
32 namespace escript {
33  struct IndexList;
34 }
35 
36 namespace dudley {
37 
38 class NodeFile
39 {
40 public:
41 
44  NodeFile(int nDim, escript::JMPI MPIInfo);
45 
47  ~NodeFile();
48 
50  void allocTable(dim_t numNodes);
51 
53  void freeTable();
54 
55  void print() const;
56 
57  inline index_t getFirstNode() const;
58  inline index_t getLastNode() const;
59  inline dim_t getGlobalNumNodes() const;
60  inline const index_t* borrowGlobalNodesIndex() const;
61 
63  inline dim_t getNumNodes() const;
64 
66  inline dim_t getNumDegreesOfFreedom() const;
67 
69  inline dim_t getNumDegreesOfFreedomTargets() const;
70 
72  inline const index_t* borrowNodesTarget() const;
73 
75  inline const index_t* borrowDegreesOfFreedomTarget() const;
76 
78  inline const index_t* borrowTargetDegreesOfFreedom() const;
79 
81  inline const index_t* borrowTargetNodes() const;
82 
83  inline void updateTagList();
84 
87  dim_t createDenseDOFLabeling();
88 
89  dim_t createDenseNodeLabeling(IndexVector& nodeDistribution,
90  const IndexVector& dofDistribution);
91 
92  void createNodeMappings(const IndexVector& dofDistribution,
93  const IndexVector& nodeDistribution);
94 
95  void assignMPIRankToDOFs(int* mpiRankOfDOF,
96  const IndexVector& distribution);
97 
98  void copyTable(index_t offset, index_t idOffset, index_t dofOffset,
99  const NodeFile* in);
100 
104  void gather(const index_t* index, const NodeFile* in);
105 
106  void gather_global(const index_t* index, const NodeFile* in);
107 
108  void setCoordinates(const escript::Data& newX);
109 
111  void setTags(int newTag, const escript::Data& mask);
112 
113  std::pair<index_t,index_t> getDOFRange() const;
114 
115 #ifdef ESYS_HAVE_TRILINOS
116  void createTrilinosGraph(const escript::IndexList* indexList);
117  esys_trilinos::const_TrilinosGraph_ptr getTrilinosGraph() const {
118  return m_graph;
119  }
120 #endif
121 
122 private:
123  std::pair<index_t,index_t> getGlobalIdRange() const;
124  std::pair<index_t,index_t> getGlobalDOFRange() const;
125  std::pair<index_t,index_t> getGlobalNodeIDIndexRange() const;
126  dim_t prepareLabeling(const std::vector<short>& mask, IndexVector& buffer,
127  IndexVector& distribution, bool useNodes);
128  void createDOFMappingAndCoupling();
129 
132 
135 
136 #ifdef ESYS_HAVE_TRILINOS
137  esys_trilinos::const_TrilinosGraph_ptr m_graph;
139 #endif
140 
141 public:
145  int numDim;
149  int* Tag;
151  std::vector<int> tagsInUse;
152 
158  double* Coordinates;
161 
164 
167 
168 #ifdef ESYS_HAVE_PASO
169  paso::Connector_ptr degreesOfFreedomConnector;
170 #endif
171  // these are the packed versions of Id
173 
176  int status;
177 };
178 
179 //
180 // implementation of inline methods
181 //
182 
183 inline index_t NodeFile::getFirstNode() const
184 {
185  return nodesDistribution->getFirstComponent();
186 }
187 
188 inline index_t NodeFile::getLastNode() const
189 {
190  return nodesDistribution->getLastComponent();
191 }
192 
193 inline dim_t NodeFile::getGlobalNumNodes() const
194 {
195  return nodesDistribution->getGlobalNumComponents();
196 }
197 
198 inline const index_t* NodeFile::borrowGlobalNodesIndex() const
199 {
200  return globalNodesIndex;
201 }
202 
203 inline dim_t NodeFile::getNumNodes() const
204 {
205  return numNodes;
206 }
207 
208 inline dim_t NodeFile::getNumDegreesOfFreedom() const
209 {
210  return dofDistribution->getMyNumComponents();
211 }
212 
213 inline dim_t NodeFile::getNumDegreesOfFreedomTargets() const
214 {
215  return degreesOfFreedomMapping.numTargets;
216 }
217 
218 inline const index_t* NodeFile::borrowNodesTarget() const
219 {
220  return nodesMapping.map;
221 }
222 
223 inline const index_t* NodeFile::borrowDegreesOfFreedomTarget() const
224 {
225  return degreesOfFreedomMapping.map;
226 }
227 
228 inline const index_t* NodeFile::borrowTargetNodes() const
229 {
230  return nodesMapping.target;
231 }
232 
233 inline const index_t* NodeFile::borrowTargetDegreesOfFreedom() const
234 {
235  return degreesOfFreedomMapping.target;
236 }
237 
238 inline void NodeFile::updateTagList()
239 {
240  util::setValuesInUse(Tag, numNodes, tagsInUse, MPIInfo);
241 }
242 
243 
244 } // namespace dudley
245 
246 #endif // __DUDLEY_NODEFILE_H__
247 
std::vector< int > tagsInUse
vector of tags which are actually used
Definition: dudley/src/NodeFile.h:151
Definition: AbstractContinuousDomain.cpp:22
boost::shared_ptr< Distribution > Distribution_ptr
Definition: Distribution.h:24
std::vector< index_t > IndexVector
Definition: DataTypes.h:62
escript::Distribution_ptr dofDistribution
MPI distribution of degrees of freedom.
Definition: dudley/src/NodeFile.h:166
int * Tag
Tag[i] is the tag of node i.
Definition: dudley/src/NodeFile.h:149
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:71
index_t * globalNodesIndex
assigns each local node a global unique ID in a dense labeling
Definition: dudley/src/NodeFile.h:160
void setValuesInUse(const int *values, dim_t numValues, std::vector< int > &valuesInUse, escript::JMPI mpiinfo)
Definition: dudley/src/Util.cpp:215
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:59
index_t * globalDegreesOfFreedom
Definition: dudley/src/NodeFile.h:156
double * Coordinates
Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i.
Definition: dudley/src/NodeFile.h:158
Data represents a collection of datapoints.
Definition: Data.h:63
escript::Distribution_ptr nodesDistribution
MPI distribution of nodes.
Definition: dudley/src/NodeFile.h:163
NodeMapping degreesOfFreedomMapping
Definition: dudley/src/NodeFile.h:131
A suite of factory methods for creating 2D and 3D dudley domains.
Definition: dudley/src/Assemble.h:31
dim_t numNodes
number of nodes
Definition: dudley/src/NodeFile.h:134
index_t * degreesOfFreedomId
Definition: dudley/src/NodeFile.h:172
void gather(int len, const index_t *index, int numData, const double *in, double *out)
Definition: dudley/src/Util.cpp:43
Definition: dudley/src/NodeMapping.h:26
boost::shared_ptr< Connector > Connector_ptr
Definition: Coupler.h:37
int status
Definition: dudley/src/NodeFile.h:176
Definition: escriptcore/src/IndexList.h:28
escript::JMPI MPIInfo
MPI information.
Definition: dudley/src/NodeFile.h:143
Definition: dudley/src/NodeFile.h:38
NodeMapping nodesMapping
Definition: dudley/src/NodeFile.h:130
int numDim
number of spatial dimensions
Definition: dudley/src/NodeFile.h:145
index_t dim_t
Definition: DataTypes.h:64
index_t * Id
Id[i] is the unique ID number of FEM node i.
Definition: dudley/src/NodeFile.h:147