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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2886 - (show annotations)
Thu Jan 28 05:39:23 2010 UTC (9 years, 6 months ago) by caltinay
File MIME type: text/plain
File size: 6553 byte(s)
New version of saveVTK within dataexporter. Not pythonised yet since it needs
more testing and release 3.1 will not ship dataexporter.

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

  ViewVC Help
Powered by ViewVC 1.1.26