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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2854 - (hide annotations)
Mon Jan 18 01:54:04 2010 UTC (10 years, 10 months ago) by caltinay
File MIME type: text/plain
File size: 5645 byte(s)
Fixed a compile error and removed unneeded member.

1 caltinay 2183
2     /*******************************************************
3     *
4 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
5 caltinay 2183 * 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 caltinay 2810 #include <escriptexport/escriptexport.h>
18 caltinay 2183 #include <finley/ReferenceElements.h> // for ElementTypeId
19 caltinay 2834 #include <finley/vtkCellType.h>
20 caltinay 2183
21 caltinay 2187 class DBfile;
22     class NcFile;
23    
24 caltinay 2810 struct Finley_ElementFile;
25    
26     namespace escriptexport {
27 caltinay 2187
28 caltinay 2810 class NodeData;
29    
30 caltinay 2187 typedef enum {
31 caltinay 2848 ZONETYPE_UNKNOWN=0,
32 caltinay 2834 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 caltinay 2187 } ZoneType;
39    
40 caltinay 2810 /// \brief Holds information that is used to convert from finley element types
41     /// to elements supported by Silo and VTK.
42 caltinay 2183 struct FinleyElementInfo
43     {
44 caltinay 2187 ZoneType elementType, reducedElementType;
45 caltinay 2183 int elementFactor;
46     int elementSize, reducedElementSize;
47     const size_t* multiCellIndices;
48     };
49    
50 caltinay 2810 /// \brief Stores and manipulates one type of finley mesh elements (cells,
51     /// faces or contacts).
52 caltinay 2206 ///
53 caltinay 2810 /// This class provides functionality to manipulate a finley element file.
54     /// It is able to load element data from NetCDF files or retrieve it from
55     /// a Finley_ElementFile instance.
56     ///
57     /// \note The corresponding mesh nodes are not part of this class but are
58     /// stored in a NodeData instance.
59 caltinay 2183 class ElementData
60     {
61     public:
62 caltinay 2196
63 caltinay 2810 /// \brief Constructor with name and accompanying NodeData object.
64     ESCRIPTEXPORT_DLL_API
65     ElementData(const std::string& elementName, NodeData_ptr nodes);
66 caltinay 2183
67 caltinay 2206 /// \brief Copy constructor
68 caltinay 2810 ESCRIPTEXPORT_DLL_API
69 caltinay 2183 ElementData(const ElementData& e);
70 caltinay 2196
71 caltinay 2810 /// \brief Initialises with data from a Finley_ElementFile instance.
72     ESCRIPTEXPORT_DLL_API
73     bool initFromFinley(const Finley_ElementFile* finleyFile);
74    
75 caltinay 2206 /// \brief Destructor
76 caltinay 2810 ESCRIPTEXPORT_DLL_API
77 caltinay 2206 ~ElementData();
78 caltinay 2196
79 caltinay 2810 /// \brief Reads element data from escript/finley NetCDF file.
80     ESCRIPTEXPORT_DLL_API
81 caltinay 2183 bool readFromNc(NcFile* ncfile);
82 caltinay 2206
83 caltinay 2810 /// \brief Moves "ghost" elements (whose owner does not match ownIndex)
84     /// and the corresponding data to the end of the arrays.
85     ESCRIPTEXPORT_DLL_API
86     void reorderGhostZones(int ownIndex);
87 caltinay 2206
88     /// \brief Removes "ghost" elements.
89 caltinay 2810 ESCRIPTEXPORT_DLL_API
90     void removeGhostZones(int ownIndex);
91 caltinay 2206
92     /// \brief Writes element data into given directory in given Silo file.
93     ///
94     /// Since the mesh depends on element information this method also writes
95 caltinay 2810 /// the node mesh itself. If Silo was not available at compile time or if
96     /// a Silo function fails this method returns false.
97     ESCRIPTEXPORT_DLL_API
98 caltinay 2183 bool writeToSilo(DBfile* dbfile, const std::string& siloPath);
99    
100 caltinay 2206 /// \brief Returns the names of the meshes associated with the elements.
101 caltinay 2810 ESCRIPTEXPORT_DLL_API
102 caltinay 2183 StringVec getMeshNames() const;
103 caltinay 2206
104     /// \brief Returns a vector with the mesh variable names.
105 caltinay 2810 ESCRIPTEXPORT_DLL_API
106 caltinay 2183 StringVec getVarNames() const;
107 caltinay 2206
108     /// \brief Returns the number of elements.
109 caltinay 2810 ESCRIPTEXPORT_DLL_API
110     int getNumElements() const { return numElements; }
111 caltinay 2206
112     /// \brief Returns the number of nodes per element.
113 caltinay 2810 ESCRIPTEXPORT_DLL_API
114 caltinay 2183 int getNodesPerElement() const { return nodesPerElement; }
115 caltinay 2206
116     /// \brief Returns the number of "ghost" elements.
117 caltinay 2810 ESCRIPTEXPORT_DLL_API
118 caltinay 2183 int getGhostCount() const { return numGhostElements; }
119 caltinay 2206
120     /// \brief Returns the type of the elements.
121 caltinay 2810 ESCRIPTEXPORT_DLL_API
122 caltinay 2187 ZoneType getType() const { return type; }
123 caltinay 2206
124     /// \brief Returns a vector of the node IDs used by the elements.
125 caltinay 2810 ESCRIPTEXPORT_DLL_API
126 caltinay 2183 const IntVec& getNodeList() const { return nodes; }
127 caltinay 2206
128     /// \brief Returns a vector of element IDs.
129 caltinay 2810 ESCRIPTEXPORT_DLL_API
130 caltinay 2183 const IntVec& getIDs() const { return ID; }
131    
132 caltinay 2810 /// \brief Returns a mapping of element IDs to array index.
133     ESCRIPTEXPORT_DLL_API
134     IndexMap getIndexMap() const;
135    
136     /// \brief Returns an array of data values for the name provided.
137     ///
138     /// The name must be one of the names returned from getVarNames().
139     ESCRIPTEXPORT_DLL_API
140     const IntVec& getVarDataByName(const std::string varName) const;
141    
142     /// \brief Returns the node mesh instance used by the elements.
143     ESCRIPTEXPORT_DLL_API
144 caltinay 2834 NodeData_ptr getNodeMesh() const { return nodeMesh; }
145 caltinay 2810
146 caltinay 2834 /// \brief Returns the reduced elements.
147 caltinay 2810 ESCRIPTEXPORT_DLL_API
148 caltinay 2834 ElementData_ptr getReducedElements() const { return reducedElements; }
149 caltinay 2810
150 caltinay 2183 private:
151     ElementData() {}
152     FinleyElementInfo getFinleyTypeInfo(ElementTypeId typeId);
153     void buildMeshes();
154     void buildReducedElements(const FinleyElementInfo& f);
155 caltinay 2834 IntVec prepareGhostIndices(int ownIndex);
156 caltinay 2183 void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
157    
158 caltinay 2834 ElementData_ptr reducedElements;
159     NodeData_ptr nodeMesh;
160     NodeData_ptr originalMesh;
161 caltinay 2183 std::string name;
162 caltinay 2834 int numElements;
163     int numGhostElements;
164     int nodesPerElement;
165     ZoneType type;
166     IntVec nodes;
167 caltinay 2183 IntVec color, ID, tag;
168 caltinay 2834 IntVec owner;
169 caltinay 2183 };
170    
171 caltinay 2810
172     inline IndexMap ElementData::getIndexMap() const
173 caltinay 2183 {
174 caltinay 2810 IndexMap ID2idx;
175 caltinay 2183 size_t idx = 0;
176     IntVec::const_iterator idIt;
177     for (idIt = ID.begin(); idIt != ID.end(); idIt++, idx++)
178     ID2idx[*idIt] = idx;
179 caltinay 2810 return ID2idx;
180 caltinay 2183 }
181    
182 caltinay 2810 } // namespace escriptexport
183 caltinay 2183
184     #endif // __ELEMENTDATA_H__
185    

  ViewVC Help
Powered by ViewVC 1.1.26