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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6079 - (show annotations)
Mon Mar 21 12:22:38 2016 UTC (2 years, 10 months ago) by caltinay
File MIME type: text/plain
File size: 6584 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_MESH_H__
18 #define __DUDLEY_MESH_H__
19
20 /****************************************************************************
21
22 Dudley: Mesh
23
24 A mesh is built from nodes and elements which are describing the
25 domain, the surface and point sources (the latter are needed to
26 establish links with other codes, in particular to particle
27 codes). The nodes are stored in a NodeFile and elements in an
28 ElementFile. A NodeFile and three ElementFiles containing the
29 elements describe the domain, surface and point sources,
30 respectively. Notice that the surface elements do not necessarily
31 cover the entire surface of the domain.
32
33 The element type is fixed by the reference element, see
34 ReferenceElement.h. The numbering of the nodes starts with 0.
35
36 Important: it is assumed that every node appears in at least
37 one element or surface element and that any node used in an
38 element, surface element or as a point is specified in the
39 NodeFile, see also Dudley_resolveNodeIds.
40
41 In some cases it is useful to refer to a mesh entirly built from
42 order 1 (=linear) elements. The linear version of the mesh can be
43 accessed by referning to the first few nodes of each element
44 (thanks to the way the nodes are ordered). As the numbering of
45 these nodes is not continuous a relabeling vector is introduced
46 in the NodeFile. This feature is not fully implemented yet.
47
48 All nodes and elements are tagged. The tag allows to group nodes and
49 elements. A typical application is to mark surface elements on a
50 certain portion of the domain with the same tag. All these surface
51 elements can then assigned the same value e.g. for the pressure.
52
53 The spatial dimensionality is determined by the type of elements
54 used and can be queried using the function Dudley_Mesh_getDim.
55 Notice that the element type also determines the type of surface
56 elements to be used.
57
58 *****************************************************************************/
59
60 #include "Dudley.h"
61 #include "ElementFile.h"
62 #include "NodeFile.h"
63 #include "TagMap.h"
64 #include "Util.h"
65
66 #include <paso/SystemMatrixPattern.h>
67
68 #ifdef USE_TRILINOS
69 #include <trilinoswrap/types.h>
70 #endif
71
72 namespace dudley {
73
74 typedef std::map<std::string, int> TagMap;
75
76 class Mesh
77 {
78 public:
79 Mesh(const std::string name, int numDim, escript::JMPI mpi_info);
80 ~Mesh();
81
82 static Mesh* read(escript::JMPI mpiInfo, const std::string& filename,
83 bool optimize);
84 static Mesh* readGmsh(escript::JMPI mpiInfo, const std::string& filename,
85 int numDim, bool optimize);
86
87 /// writes the mesh to the external file filename using the Dudley file
88 /// format
89 void write(const std::string& filename) const;
90
91 int getDim() const { return Nodes->numDim; }
92 int getStatus() const { return Nodes->status; }
93
94 void addPoints(int numPoints, const double *points_ptr, const int *tags_ptr);
95 void addTagMap(const std::string& name, int tag_key);
96 int getTag(const std::string& name) const;
97 bool isValidTagName(const std::string& name) const;
98
99 /// returns a reference to the paso matrix pattern
100 paso::SystemMatrixPattern_ptr getPasoPattern();
101
102 void printInfo(bool);
103 void print();
104
105 /// assigns new coordinates to the nodes
106 void setCoordinates(const escript::Data& newX);
107 void setElements(ElementFile* elements);
108 void setFaceElements(ElementFile* elements);
109 void setPoints(ElementFile* elements);
110
111 void prepare(bool optimize);
112
113 /// Initially the element nodes refer to the numbering defined by the
114 /// global id assigned to the nodes in the NodeFile. It is also not ensured
115 /// that all nodes referred by an element are actually available on the
116 /// process. At the output, a local node labeling is used and all nodes are
117 /// available. In particular the numbering of the element nodes is between
118 /// 0 and Nodes->numNodes.
119 /// The function does not create a distribution of the degrees of freedom.
120 void resolveNodeIds();
121
122 void createMappings(const std::vector<index_t>& dofDistribution,
123 const std::vector<index_t>& nodeDistribution);
124
125 /// assigns new node reference numbers to all element files.
126 /// If k is the old node, the new node is newNode[k-offset].
127 void relabelElementNodes(const index_t* newNode, index_t offset);
128
129 #ifdef USE_TRILINOS
130 /// creates and returns a Trilinos CRS graph suitable to build a sparse
131 /// matrix
132 esys_trilinos::const_TrilinosGraph_ptr createTrilinosGraph() const;
133 #endif
134
135 private:
136 paso::SystemMatrixPattern_ptr makePasoPattern() const;
137 void createColoring(const index_t* dofMap);
138 void distributeByRankOfDOF(const std::vector<index_t>& distribution);
139 void markNodes(std::vector<short>& mask, index_t offset) const;
140 void optimizeDOFDistribution(std::vector<index_t>& distribution);
141 void optimizeDOFLabeling(const std::vector<index_t>& distribution);
142 void optimizeElementOrdering();
143 void updateTagList();
144 void printElementInfo(const ElementFile* e, const std::string& title,
145 const std::string& defaultType, bool full) const;
146
147 void writeElementInfo(std::ostream& stream, const ElementFile* e,
148 const std::string& defaultType) const;
149
150 public:
151 /// the name of the mesh
152 std::string m_name;
153 int approximationOrder;
154 int integrationOrder;
155 int reducedIntegrationOrder;
156 // the table of the nodes
157 NodeFile* Nodes;
158 // the table of the elements
159 ElementFile* Elements;
160 // the table of the face elements
161 ElementFile* FaceElements;
162 // the table of points (treated as elements of dimension 0)
163 ElementFile* Points;
164 // the tag map mapping names to tag keys
165 TagMap tagMap;
166
167 // pointer to the sparse matrix pattern
168 paso::SystemMatrixPattern_ptr pasoPattern;
169 escript::JMPI MPIInfo;
170 };
171
172 } // namespace dudley
173
174 #endif // __DUDLEY_MESH_H__
175

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26