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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4492 - (show annotations)
Tue Jul 2 01:44:11 2013 UTC (5 years, 9 months ago) by caltinay
File MIME type: text/plain
File size: 6264 byte(s)
Finley changes that were held back while in release mode - moved more stuff
into finley namespace.

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

  ViewVC Help
Powered by ViewVC 1.1.26