/[escript]/branches/domexper/weipa/src/FinleyElements.h
ViewVC logotype

Contents of /branches/domexper/weipa/src/FinleyElements.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3247 - (show annotations)
Wed Oct 6 05:53:06 2010 UTC (8 years, 6 months ago) by caltinay
File MIME type: text/plain
File size: 5801 byte(s)
Fixed name clashes between dudley and finley so both can be used
simultaneously.

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

  ViewVC Help
Powered by ViewVC 1.1.26