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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2880 - (show annotations)
Thu Jan 28 01:21:30 2010 UTC (9 years, 2 months ago) by caltinay
File MIME type: text/plain
File size: 6386 byte(s)
Better resolution for Hex27 & Rec9 data in dataexporter (mantis #486).
Saved Silo data resolution is now equal to finley.SaveVTK generated data in
all cases.

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

  ViewVC Help
Powered by ViewVC 1.1.26