/[escript]/trunk/weipa/src/FinleyElements.h
ViewVC logotype

Annotation of /trunk/weipa/src/FinleyElements.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (hide annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years ago) by jfenwick
File MIME type: text/plain
File size: 6095 byte(s)
Merging dudley and scons updates from branches

1 caltinay 2183
2     /*******************************************************
3     *
4 jfenwick 2881 * Copyright (c) 2003-2010 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 caltinay 3143 #ifndef __WEIPA_FINLEYELEMENTS_H__
15     #define __WEIPA_FINLEYELEMENTS_H__
16 caltinay 2183
17 caltinay 3143 #include <weipa/ElementData.h>
18     #include <weipa/FinleyNodes.h>
19 caltinay 2896
20     extern "C" {
21 jfenwick 3259 #include <dudley/ElementType.h> // for Dudley_ElementTypeId
22     #include <finley/ReferenceElements.h> // for Finley_ElementTypeId
23 caltinay 2896 }
24    
25 caltinay 2187 class DBfile;
26     class NcFile;
27    
28 jfenwick 3259 struct Dudley_ElementFile;
29 caltinay 2810 struct Finley_ElementFile;
30    
31 caltinay 3037 namespace weipa {
32 caltinay 3143
33 caltinay 2810 /// \brief Holds information that is used to convert from finley element types
34     /// to elements supported by Silo and VTK.
35 caltinay 2183 struct FinleyElementInfo
36     {
37 caltinay 2187 ZoneType elementType, reducedElementType;
38 caltinay 2183 int elementFactor;
39     int elementSize, reducedElementSize;
40     const size_t* multiCellIndices;
41 caltinay 2880 bool useQuadNodes;
42     int quadDim;
43 caltinay 2183 };
44    
45 caltinay 3143 class FinleyElements;
46     typedef boost::shared_ptr<FinleyElements> FinleyElements_ptr;
47 caltinay 2880
48 caltinay 2810 /// \brief Stores and manipulates one type of finley mesh elements (cells,
49     /// faces or contacts).
50 caltinay 2206 ///
51 caltinay 2810 /// This class provides functionality to manipulate a finley element file.
52     /// It is able to load element data from NetCDF files or retrieve it from
53     /// a Finley_ElementFile instance.
54     ///
55     /// \note The corresponding mesh nodes are not part of this class but are
56     /// stored in a NodeData instance.
57 caltinay 3143 class FinleyElements : public ElementData
58 caltinay 2183 {
59     public:
60 caltinay 2196
61 caltinay 2810 /// \brief Constructor with name and accompanying NodeData object.
62 caltinay 3143 FinleyElements(const std::string& elementName, FinleyNodes_ptr nodes);
63 caltinay 2183
64 caltinay 2206 /// \brief Copy constructor
65 caltinay 3143 FinleyElements(const FinleyElements& e);
66 caltinay 2196
67 caltinay 3143 /// \brief Destructor
68     virtual ~FinleyElements() {}
69    
70 jfenwick 3259 /// \brief Initialises with data from a Dudley_ElementFile instance.
71     bool initFromDudley(const Dudley_ElementFile* dudleyFile);
72    
73 caltinay 2810 /// \brief Initialises with data from a Finley_ElementFile instance.
74     bool initFromFinley(const Finley_ElementFile* finleyFile);
75    
76     /// \brief Reads element data from escript/finley NetCDF file.
77 caltinay 2183 bool readFromNc(NcFile* ncfile);
78 caltinay 2206
79 caltinay 2810 /// \brief Moves "ghost" elements (whose owner does not match ownIndex)
80     /// and the corresponding data to the end of the arrays.
81     void reorderGhostZones(int ownIndex);
82 caltinay 2206
83     /// \brief Removes "ghost" elements.
84 caltinay 2810 void removeGhostZones(int ownIndex);
85 caltinay 2206
86 caltinay 2886 /// \brief Writes connectivity data to a stream in VTK text format.
87 caltinay 3143 virtual void writeConnectivityVTK(std::ostream& os);
88 caltinay 2886
89 caltinay 2206 /// \brief Writes element data into given directory in given Silo file.
90     ///
91     /// Since the mesh depends on element information this method also writes
92 caltinay 2810 /// the node mesh itself. If Silo was not available at compile time or if
93     /// a Silo function fails this method returns false.
94 caltinay 3128 bool writeToSilo(DBfile* dbfile, const std::string& siloPath,
95     const StringVec& labels, const StringVec& units);
96 caltinay 2183
97 caltinay 2206 /// \brief Returns the names of the meshes associated with the elements.
98 caltinay 3143 virtual StringVec getMeshNames() const;
99 caltinay 2206
100     /// \brief Returns a vector with the mesh variable names.
101 caltinay 3143 virtual StringVec getVarNames() const;
102 caltinay 2206
103     /// \brief Returns the number of elements.
104 caltinay 3143 virtual int getNumElements() const { return numElements; }
105 caltinay 2206
106     /// \brief Returns the number of nodes per element.
107 caltinay 3143 virtual int getNodesPerElement() const { return nodesPerElement; }
108 caltinay 2206
109     /// \brief Returns the number of "ghost" elements.
110 caltinay 3143 virtual int getGhostCount() const { return numGhostElements; }
111 caltinay 2206
112     /// \brief Returns the type of the elements.
113 caltinay 3143 virtual ZoneType getType() const { return type; }
114 caltinay 2206
115 caltinay 2880 /// \brief Returns the original type id of the Finley reference elements.
116 jfenwick 3259 Finley_ElementTypeId getFinleyTypeId() const { return finleyTypeId; }
117 caltinay 2880
118 caltinay 2206 /// \brief Returns a vector of the node IDs used by the elements.
119 caltinay 3143 virtual const IntVec& getNodeList() const { return nodes; }
120 caltinay 2206
121     /// \brief Returns a vector of element IDs.
122 caltinay 3143 virtual const IntVec& getIDs() const { return ID; }
123 caltinay 2183
124 caltinay 2810 /// \brief Returns an array of data values for the name provided.
125     ///
126     /// The name must be one of the names returned from getVarNames().
127 caltinay 3143 virtual const IntVec& getVarDataByName(const std::string varName) const;
128 caltinay 2810
129     /// \brief Returns the node mesh instance used by the elements.
130 caltinay 3143 virtual NodeData_ptr getNodes() const { return nodeMesh; }
131 caltinay 2810
132 caltinay 2834 /// \brief Returns the reduced elements.
133 caltinay 3143 virtual ElementData_ptr getReducedElements() const { return reducedElements; }
134 caltinay 2810
135 caltinay 2880 /// \brief Returns a QuadMaskInfo structure for given functionspace code.
136 caltinay 3143 virtual const QuadMaskInfo& getQuadMask(int functionSpace) const;
137 caltinay 2880
138     /// \brief If the original element type is not supported they are
139     /// subdivided into N smaller elements (e.g. one Rec9 -> four Rec4)
140     /// and this method returns the multiplication factor N.
141 caltinay 3143 virtual int getElementFactor() const { return elementFactor; }
142 caltinay 2880
143 caltinay 2183 private:
144 caltinay 3143 FinleyElements() {}
145 jfenwick 3259 FinleyElementInfo getDudleyTypeInfo(Dudley_ElementTypeId typeId);
146     FinleyElementInfo getFinleyTypeInfo(Finley_ElementTypeId typeId);
147 caltinay 2183 void buildMeshes();
148     void buildReducedElements(const FinleyElementInfo& f);
149 caltinay 2834 IntVec prepareGhostIndices(int ownIndex);
150 caltinay 2183 void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
151 caltinay 2880 QuadMaskInfo buildQuadMask(const CoordArray& quadNodes, int numQNodes);
152 caltinay 2183
153 caltinay 3143 FinleyElements_ptr reducedElements;
154     FinleyNodes_ptr nodeMesh;
155     FinleyNodes_ptr originalMesh;
156 caltinay 2183 std::string name;
157 caltinay 2834 int numElements;
158     int numGhostElements;
159     int nodesPerElement;
160     ZoneType type;
161 jfenwick 3259 Finley_ElementTypeId finleyTypeId;
162 caltinay 2834 IntVec nodes;
163 caltinay 2183 IntVec color, ID, tag;
164 caltinay 2834 IntVec owner;
165 caltinay 2880 QuadMaskInfo quadMask, reducedQuadMask;
166     int elementFactor;
167 caltinay 2183 };
168    
169 caltinay 3037 } // namespace weipa
170 caltinay 2183
171 caltinay 3143 #endif // __WEIPA_FINLEYELEMENTS_H__
172 caltinay 2183

  ViewVC Help
Powered by ViewVC 1.1.26