/[escript]/trunk/tools/libescriptreader/src/escriptreader/ElementData.h
ViewVC logotype

Annotation of /trunk/tools/libescriptreader/src/escriptreader/ElementData.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2206 - (hide annotations)
Fri Jan 9 03:50:29 2009 UTC (12 years, 6 months ago) by caltinay
File MIME type: text/plain
File size: 4997 byte(s)
Added some more doxygen docu to escriptreader classes.

1 caltinay 2183
2     /*******************************************************
3     *
4     * Copyright (c) 2003-2008 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     //
15     // ElementData.h
16     //
17     #ifndef __ELEMENTDATA_H__
18     #define __ELEMENTDATA_H__
19    
20     #include <finley/ReferenceElements.h> // for ElementTypeId
21     #include <escriptreader/Mesh.h>
22    
23 caltinay 2187 class DBfile;
24     class NcFile;
25    
26     namespace EscriptReader {
27    
28     typedef enum {
29     ZONETYPE_BEAM=1,
30     ZONETYPE_HEX,
31     ZONETYPE_POLYGON,
32     ZONETYPE_QUAD,
33     ZONETYPE_TET,
34     ZONETYPE_TRIANGLE
35     } ZoneType;
36    
37 caltinay 2206 /// \brief Holds information that is used to convert from escript element types
38     /// to Silo.
39 caltinay 2183 struct FinleyElementInfo
40     {
41 caltinay 2187 ZoneType elementType, reducedElementType;
42 caltinay 2183 int elementFactor;
43     int elementSize, reducedElementSize;
44     const size_t* multiCellIndices;
45     };
46    
47 caltinay 2206 /// \brief A class that stores and manipulates one type of escript mesh elements
48     /// (elements, faces, contacts or points).
49     ///
50     /// The corresponding mesh nodes are not part of this class but stored in a Mesh
51     /// object which has to be provided when constructing an ElementData object.
52 caltinay 2183 class ElementData
53     {
54     friend class DataVar;
55     friend class MeshWithElements;
56     public:
57 caltinay 2196
58 caltinay 2206 /// \brief Constructor with name and accompanying Mesh object.
59 caltinay 2183 ElementData(const std::string& elementName, const Mesh* mainMesh);
60    
61 caltinay 2206 /// \brief Copy constructor
62 caltinay 2183 ElementData(const ElementData& e);
63 caltinay 2196
64 caltinay 2206 /// \brief Destructor
65     ~ElementData();
66 caltinay 2196
67 caltinay 2206 /// \brief Reads element data from escript NetCDF file.
68 caltinay 2183 bool readFromNc(NcFile* ncfile);
69 caltinay 2206
70     /// \brief Moves "ghost" elements and corresponding data to the end of the
71     /// arrays.
72 caltinay 2183 void handleGhostZones(int ownIndex);
73 caltinay 2206
74     /// \brief Removes "ghost" elements.
75 caltinay 2183 void removeGhostZones();
76 caltinay 2206
77     /// \brief Writes element data into given directory in given Silo file.
78     ///
79     /// Since the mesh depends on element information this method also writes
80     /// the mesh itself. If Silo was not available at compile time or if a Silo
81     /// function fails this method returns false.
82 caltinay 2183 bool writeToSilo(DBfile* dbfile, const std::string& siloPath);
83    
84 caltinay 2206 /// \brief Returns the names of the meshes associated with the elements.
85 caltinay 2183 StringVec getMeshNames() const;
86 caltinay 2206
87     /// \brief Returns a vector with the mesh variable names.
88 caltinay 2183 StringVec getVarNames() const;
89 caltinay 2206
90     /// \brief Returns the number of elements.
91 caltinay 2183 int getCount() const { return count; }
92 caltinay 2206
93     /// \brief Returns the number of reduced elements.
94 caltinay 2183 int getReducedCount() const { return reducedCount; }
95 caltinay 2206
96     /// \brief Returns the number of nodes per element.
97 caltinay 2183 int getNodesPerElement() const { return nodesPerElement; }
98 caltinay 2206
99     /// \brief Returns the number of nodes per reduced element.
100 caltinay 2183 int getReducedNodesPerElement() const { return reducedNodesPerElement; }
101 caltinay 2206
102     /// \brief Returns the number of "ghost" elements.
103 caltinay 2183 int getGhostCount() const { return numGhostElements; }
104 caltinay 2206
105     /// \brief Returns the number of "ghost" reduced elements.
106 caltinay 2183 int getReducedGhostCount() const { return numReducedGhostElements; }
107 caltinay 2206
108     /// \brief Returns the type of the elements.
109 caltinay 2187 ZoneType getType() const { return type; }
110 caltinay 2206
111     /// \brief Returns the type of reduced elements.
112 caltinay 2187 ZoneType getReducedType() const { return reducedType; }
113 caltinay 2206
114     /// \brief Returns a vector of the node IDs used by the elements.
115 caltinay 2183 const IntVec& getNodeList() const { return nodes; }
116 caltinay 2206
117     /// \brief Returns a vector of the node IDs used by the reduced elements.
118 caltinay 2183 const IntVec& getReducedNodeList() const { return reducedNodes; }
119 caltinay 2206
120     /// \brief Returns a vector of element IDs.
121 caltinay 2183 const IntVec& getIDs() const { return ID; }
122    
123     private:
124     ElementData() {}
125     FinleyElementInfo getFinleyTypeInfo(ElementTypeId typeId);
126     void buildIndexMap();
127     void buildMeshes();
128     void buildReducedElements(const FinleyElementInfo& f);
129     void prepareGhostIndices(int ownIndex);
130     void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
131    
132     const IntVec& getVarDataByName(const std::string varName) const;
133    
134     std::string name;
135     int count, reducedCount;
136     int numGhostElements, numReducedGhostElements;
137     IndexMap ID2idx;
138     IntVec indexArray, reducedIndexArray;
139     Mesh* fullMesh;
140     Mesh* reducedMesh;
141     const Mesh* originalMesh;
142     bool fullMeshIsOriginalMesh;
143    
144     int numDims;
145 caltinay 2187 ZoneType type, reducedType;
146 caltinay 2183 int nodesPerElement, reducedNodesPerElement;
147     IntVec nodes, reducedNodes;
148     IntVec color, ID, tag;
149     IntVec owner, reducedOwner;
150     };
151    
152     //
153     //
154     //
155     inline void ElementData::buildIndexMap()
156     {
157     ID2idx.clear();
158     size_t idx = 0;
159     IntVec::const_iterator idIt;
160     for (idIt = ID.begin(); idIt != ID.end(); idIt++, idx++)
161     ID2idx[*idIt] = idx;
162     }
163    
164 caltinay 2187 } // namespace EscriptReader
165 caltinay 2183
166     #endif // __ELEMENTDATA_H__
167    

  ViewVC Help
Powered by ViewVC 1.1.26