/[escript]/trunk/dataexporter/src/ElementData.h
ViewVC logotype

Contents of /trunk/dataexporter/src/ElementData.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2896 - (show annotations)
Sun Jan 31 22:17:22 2010 UTC (10 years, 7 months ago) by caltinay
File MIME type: text/plain
File size: 6570 byte(s)
Added missing extern C for finley include.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14 #ifndef __ELEMENTDATA_H__
15 #define __ELEMENTDATA_H__
16
17 #include <escriptexport/escriptexport.h>
18
19 extern "C" {
20 #include <finley/ReferenceElements.h> // for ElementTypeId
21 }
22
23 #include <finley/vtkCellType.h>
24 #include <ostream>
25
26 class DBfile;
27 class NcFile;
28
29 struct Finley_ElementFile;
30
31 namespace escriptexport {
32
33 class NodeData;
34
35 typedef enum {
36 ZONETYPE_UNKNOWN=0,
37 ZONETYPE_BEAM=VTK_LINE,
38 ZONETYPE_HEX=VTK_HEXAHEDRON,
39 ZONETYPE_POLYGON=VTK_POLYGON,
40 ZONETYPE_QUAD=VTK_QUAD,
41 ZONETYPE_TET=VTK_TETRA,
42 ZONETYPE_TRIANGLE=VTK_TRIANGLE
43 } ZoneType;
44
45 /// \brief Holds information that is used to convert from finley element types
46 /// to elements supported by Silo and VTK.
47 struct FinleyElementInfo
48 {
49 ZoneType elementType, reducedElementType;
50 int elementFactor;
51 int elementSize, reducedElementSize;
52 const size_t* multiCellIndices;
53 bool useQuadNodes;
54 int quadDim;
55 };
56
57 /// \brief This struct holds a mask (0's and 1's) that indicates which quad
58 /// nodes contribute to a sub-element when full element order is used.
59 /// factor[i] contains the number of non-zeroes in mask[i].
60 struct QuadMaskInfo {
61 std::vector<IntVec> mask;
62 IntVec factor;
63 };
64
65 /// \brief Stores and manipulates one type of finley mesh elements (cells,
66 /// faces or contacts).
67 ///
68 /// This class provides functionality to manipulate a finley element file.
69 /// It is able to load element data from NetCDF files or retrieve it from
70 /// a Finley_ElementFile instance.
71 ///
72 /// \note The corresponding mesh nodes are not part of this class but are
73 /// stored in a NodeData instance.
74 class ElementData
75 {
76 public:
77
78 /// \brief Constructor with name and accompanying NodeData object.
79 ESCRIPTEXPORT_DLL_API
80 ElementData(const std::string& elementName, NodeData_ptr nodes);
81
82 /// \brief Copy constructor
83 ESCRIPTEXPORT_DLL_API
84 ElementData(const ElementData& e);
85
86 /// \brief Initialises with data from a Finley_ElementFile instance.
87 ESCRIPTEXPORT_DLL_API
88 bool initFromFinley(const Finley_ElementFile* finleyFile);
89
90 /// \brief Destructor
91 ESCRIPTEXPORT_DLL_API
92 ~ElementData() {}
93
94 /// \brief Reads element data from escript/finley NetCDF file.
95 ESCRIPTEXPORT_DLL_API
96 bool readFromNc(NcFile* ncfile);
97
98 /// \brief Moves "ghost" elements (whose owner does not match ownIndex)
99 /// and the corresponding data to the end of the arrays.
100 ESCRIPTEXPORT_DLL_API
101 void reorderGhostZones(int ownIndex);
102
103 /// \brief Removes "ghost" elements.
104 ESCRIPTEXPORT_DLL_API
105 void removeGhostZones(int ownIndex);
106
107 /// \brief Writes connectivity data to a stream in VTK text format.
108 ESCRIPTEXPORT_DLL_API
109 void writeConnectivityVTK(std::ostream& os);
110
111 /// \brief Writes element data into given directory in given Silo file.
112 ///
113 /// Since the mesh depends on element information this method also writes
114 /// the node mesh itself. If Silo was not available at compile time or if
115 /// a Silo function fails this method returns false.
116 ESCRIPTEXPORT_DLL_API
117 bool writeToSilo(DBfile* dbfile, const std::string& siloPath);
118
119 /// \brief Returns the names of the meshes associated with the elements.
120 ESCRIPTEXPORT_DLL_API
121 StringVec getMeshNames() const;
122
123 /// \brief Returns a vector with the mesh variable names.
124 ESCRIPTEXPORT_DLL_API
125 StringVec getVarNames() const;
126
127 /// \brief Returns the number of elements.
128 ESCRIPTEXPORT_DLL_API
129 int getNumElements() const { return numElements; }
130
131 /// \brief Returns the number of nodes per element.
132 ESCRIPTEXPORT_DLL_API
133 int getNodesPerElement() const { return nodesPerElement; }
134
135 /// \brief Returns the number of "ghost" elements.
136 ESCRIPTEXPORT_DLL_API
137 int getGhostCount() const { return numGhostElements; }
138
139 /// \brief Returns the type of the elements.
140 ESCRIPTEXPORT_DLL_API
141 ZoneType getType() const { return type; }
142
143 /// \brief Returns the original type id of the Finley reference elements.
144 ESCRIPTEXPORT_DLL_API
145 ElementTypeId getFinleyTypeId() const { return finleyTypeId; }
146
147 /// \brief Returns a vector of the node IDs used by the elements.
148 ESCRIPTEXPORT_DLL_API
149 const IntVec& getNodeList() const { return nodes; }
150
151 /// \brief Returns a vector of element IDs.
152 ESCRIPTEXPORT_DLL_API
153 const IntVec& getIDs() const { return ID; }
154
155 /// \brief Returns an array of data values for the name provided.
156 ///
157 /// The name must be one of the names returned from getVarNames().
158 ESCRIPTEXPORT_DLL_API
159 const IntVec& getVarDataByName(const std::string varName) const;
160
161 /// \brief Returns the node mesh instance used by the elements.
162 ESCRIPTEXPORT_DLL_API
163 NodeData_ptr getNodeMesh() const { return nodeMesh; }
164
165 /// \brief Returns the reduced elements.
166 ESCRIPTEXPORT_DLL_API
167 ElementData_ptr getReducedElements() const { return reducedElements; }
168
169 /// \brief Returns a QuadMaskInfo structure for given functionspace code.
170 const QuadMaskInfo& getQuadMask(int functionSpace) const;
171
172 /// \brief If the original element type is not supported they are
173 /// subdivided into N smaller elements (e.g. one Rec9 -> four Rec4)
174 /// and this method returns the multiplication factor N.
175 int getElementFactor() const { return elementFactor; }
176
177 private:
178 ElementData() {}
179 FinleyElementInfo getFinleyTypeInfo(ElementTypeId typeId);
180 void buildMeshes();
181 void buildReducedElements(const FinleyElementInfo& f);
182 IntVec prepareGhostIndices(int ownIndex);
183 void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
184 QuadMaskInfo buildQuadMask(const CoordArray& quadNodes, int numQNodes);
185
186 ElementData_ptr reducedElements;
187 NodeData_ptr nodeMesh;
188 NodeData_ptr originalMesh;
189 std::string name;
190 int numElements;
191 int numGhostElements;
192 int nodesPerElement;
193 ZoneType type;
194 ElementTypeId finleyTypeId;
195 IntVec nodes;
196 IntVec color, ID, tag;
197 IntVec owner;
198 QuadMaskInfo quadMask, reducedQuadMask;
199 int elementFactor;
200 };
201
202 } // namespace escriptexport
203
204 #endif // __ELEMENTDATA_H__
205

  ViewVC Help
Powered by ViewVC 1.1.26