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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1
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 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 /// \brief Holds information that is used to convert from escript element types
38 /// to Silo.
39 struct FinleyElementInfo
40 {
41 ZoneType elementType, reducedElementType;
42 int elementFactor;
43 int elementSize, reducedElementSize;
44 const size_t* multiCellIndices;
45 };
46
47 /// \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 class ElementData
53 {
54 friend class DataVar;
55 friend class MeshWithElements;
56 public:
57
58 /// \brief Constructor with name and accompanying Mesh object.
59 ElementData(const std::string& elementName, const Mesh* mainMesh);
60
61 /// \brief Copy constructor
62 ElementData(const ElementData& e);
63
64 /// \brief Destructor
65 ~ElementData();
66
67 /// \brief Reads element data from escript NetCDF file.
68 bool readFromNc(NcFile* ncfile);
69
70 /// \brief Moves "ghost" elements and corresponding data to the end of the
71 /// arrays.
72 void handleGhostZones(int ownIndex);
73
74 /// \brief Removes "ghost" elements.
75 void removeGhostZones();
76
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 bool writeToSilo(DBfile* dbfile, const std::string& siloPath);
83
84 /// \brief Returns the names of the meshes associated with the elements.
85 StringVec getMeshNames() const;
86
87 /// \brief Returns a vector with the mesh variable names.
88 StringVec getVarNames() const;
89
90 /// \brief Returns the number of elements.
91 int getCount() const { return count; }
92
93 /// \brief Returns the number of reduced elements.
94 int getReducedCount() const { return reducedCount; }
95
96 /// \brief Returns the number of nodes per element.
97 int getNodesPerElement() const { return nodesPerElement; }
98
99 /// \brief Returns the number of nodes per reduced element.
100 int getReducedNodesPerElement() const { return reducedNodesPerElement; }
101
102 /// \brief Returns the number of "ghost" elements.
103 int getGhostCount() const { return numGhostElements; }
104
105 /// \brief Returns the number of "ghost" reduced elements.
106 int getReducedGhostCount() const { return numReducedGhostElements; }
107
108 /// \brief Returns the type of the elements.
109 ZoneType getType() const { return type; }
110
111 /// \brief Returns the type of reduced elements.
112 ZoneType getReducedType() const { return reducedType; }
113
114 /// \brief Returns a vector of the node IDs used by the elements.
115 const IntVec& getNodeList() const { return nodes; }
116
117 /// \brief Returns a vector of the node IDs used by the reduced elements.
118 const IntVec& getReducedNodeList() const { return reducedNodes; }
119
120 /// \brief Returns a vector of element IDs.
121 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 ZoneType type, reducedType;
146 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 } // namespace EscriptReader
165
166 #endif // __ELEMENTDATA_H__
167

  ViewVC Help
Powered by ViewVC 1.1.26