/[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 2196 - (show annotations)
Wed Jan 7 06:14:59 2009 UTC (12 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 3700 byte(s)
As harsh as it sounds: removed obsolete friendship between DataVar and Mesh.
Updated and added documentation to some more methods.

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 //
38 // Holds information that is used to convert from escript element types to
39 // Silo.
40 //
41 struct FinleyElementInfo
42 {
43 ZoneType elementType, reducedElementType;
44 int elementFactor;
45 int elementSize, reducedElementSize;
46 const size_t* multiCellIndices;
47 };
48
49 //
50 // A class that stores and manipulates one type of escript mesh elements
51 // (elements, faces, contacts or points). The corresponding mesh nodes are
52 // not part of this class but stored in a Mesh object which has to be provided
53 // when constructing an ElementData object.
54 //
55 class ElementData
56 {
57 friend class DataVar;
58 friend class MeshWithElements;
59 public:
60
61 /// Constructor with name and accompanying Mesh object.
62 ElementData(const std::string& elementName, const Mesh* mainMesh);
63
64 /// Copy constructor
65 ElementData(const ElementData& e);
66
67 /// Virtual destructor
68 virtual ~ElementData();
69
70 bool readFromNc(NcFile* ncfile);
71 void handleGhostZones(int ownIndex);
72 void removeGhostZones();
73 bool writeToSilo(DBfile* dbfile, const std::string& siloPath);
74
75 StringVec getMeshNames() const;
76 StringVec getVarNames() const;
77 int getCount() const { return count; }
78 int getReducedCount() const { return reducedCount; }
79 int getNodesPerElement() const { return nodesPerElement; }
80 int getReducedNodesPerElement() const { return reducedNodesPerElement; }
81 int getGhostCount() const { return numGhostElements; }
82 int getReducedGhostCount() const { return numReducedGhostElements; }
83 ZoneType getType() const { return type; }
84 ZoneType getReducedType() const { return reducedType; }
85 const IntVec& getNodeList() const { return nodes; }
86 const IntVec& getReducedNodeList() const { return reducedNodes; }
87 const IntVec& getIDs() const { return ID; }
88
89 private:
90 ElementData() {}
91 FinleyElementInfo getFinleyTypeInfo(ElementTypeId typeId);
92 void buildIndexMap();
93 void buildMeshes();
94 void buildReducedElements(const FinleyElementInfo& f);
95 void prepareGhostIndices(int ownIndex);
96 void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
97
98 const IntVec& getVarDataByName(const std::string varName) const;
99
100 std::string name;
101 int count, reducedCount;
102 int numGhostElements, numReducedGhostElements;
103 IndexMap ID2idx;
104 IntVec indexArray, reducedIndexArray;
105 Mesh* fullMesh;
106 Mesh* reducedMesh;
107 const Mesh* originalMesh;
108 bool fullMeshIsOriginalMesh;
109
110 int numDims;
111 ZoneType type, reducedType;
112 int nodesPerElement, reducedNodesPerElement;
113 IntVec nodes, reducedNodes;
114 IntVec color, ID, tag;
115 IntVec owner, reducedOwner;
116 };
117
118 //
119 //
120 //
121 inline void ElementData::buildIndexMap()
122 {
123 ID2idx.clear();
124 size_t idx = 0;
125 IntVec::const_iterator idIt;
126 for (idIt = ID.begin(); idIt != ID.end(); idIt++, idx++)
127 ID2idx[*idIt] = idx;
128 }
129
130 } // namespace EscriptReader
131
132 #endif // __ELEMENTDATA_H__
133

  ViewVC Help
Powered by ViewVC 1.1.26