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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show 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
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 <dudley/ElementType.h> // for Dudley_ElementTypeId
22 #include <finley/ReferenceElements.h> // for Finley_ElementTypeId
23 }
24
25 class DBfile;
26 class NcFile;
27
28 struct Dudley_ElementFile;
29 struct Finley_ElementFile;
30
31 namespace weipa {
32
33 /// \brief Holds information that is used to convert from finley element types
34 /// to elements supported by Silo and VTK.
35 struct FinleyElementInfo
36 {
37 ZoneType elementType, reducedElementType;
38 int elementFactor;
39 int elementSize, reducedElementSize;
40 const size_t* multiCellIndices;
41 bool useQuadNodes;
42 int quadDim;
43 };
44
45 class FinleyElements;
46 typedef boost::shared_ptr<FinleyElements> FinleyElements_ptr;
47
48 /// \brief Stores and manipulates one type of finley mesh elements (cells,
49 /// faces or contacts).
50 ///
51 /// 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 class FinleyElements : public ElementData
58 {
59 public:
60
61 /// \brief Constructor with name and accompanying NodeData object.
62 FinleyElements(const std::string& elementName, FinleyNodes_ptr nodes);
63
64 /// \brief Copy constructor
65 FinleyElements(const FinleyElements& e);
66
67 /// \brief Destructor
68 virtual ~FinleyElements() {}
69
70 /// \brief Initialises with data from a Dudley_ElementFile instance.
71 bool initFromDudley(const Dudley_ElementFile* dudleyFile);
72
73 /// \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 bool readFromNc(NcFile* ncfile);
78
79 /// \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
83 /// \brief Removes "ghost" elements.
84 void removeGhostZones(int ownIndex);
85
86 /// \brief Writes connectivity data to a stream in VTK text format.
87 virtual void writeConnectivityVTK(std::ostream& os);
88
89 /// \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 /// the node mesh itself. If Silo was not available at compile time or if
93 /// a Silo function fails this method returns false.
94 bool writeToSilo(DBfile* dbfile, const std::string& siloPath,
95 const StringVec& labels, const StringVec& units);
96
97 /// \brief Returns the names of the meshes associated with the elements.
98 virtual StringVec getMeshNames() const;
99
100 /// \brief Returns a vector with the mesh variable names.
101 virtual StringVec getVarNames() const;
102
103 /// \brief Returns the number of elements.
104 virtual int getNumElements() const { return numElements; }
105
106 /// \brief Returns the number of nodes per element.
107 virtual int getNodesPerElement() const { return nodesPerElement; }
108
109 /// \brief Returns the number of "ghost" elements.
110 virtual int getGhostCount() const { return numGhostElements; }
111
112 /// \brief Returns the type of the elements.
113 virtual ZoneType getType() const { return type; }
114
115 /// \brief Returns the original type id of the Finley reference elements.
116 Finley_ElementTypeId getFinleyTypeId() const { return finleyTypeId; }
117
118 /// \brief Returns a vector of the node IDs used by the elements.
119 virtual const IntVec& getNodeList() const { return nodes; }
120
121 /// \brief Returns a vector of element IDs.
122 virtual const IntVec& getIDs() const { return ID; }
123
124 /// \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 virtual const IntVec& getVarDataByName(const std::string varName) const;
128
129 /// \brief Returns the node mesh instance used by the elements.
130 virtual NodeData_ptr getNodes() const { return nodeMesh; }
131
132 /// \brief Returns the reduced elements.
133 virtual ElementData_ptr getReducedElements() const { return reducedElements; }
134
135 /// \brief Returns a QuadMaskInfo structure for given functionspace code.
136 virtual const QuadMaskInfo& getQuadMask(int functionSpace) const;
137
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 virtual int getElementFactor() const { return elementFactor; }
142
143 private:
144 FinleyElements() {}
145 FinleyElementInfo getDudleyTypeInfo(Dudley_ElementTypeId typeId);
146 FinleyElementInfo getFinleyTypeInfo(Finley_ElementTypeId typeId);
147 void buildMeshes();
148 void buildReducedElements(const FinleyElementInfo& f);
149 IntVec prepareGhostIndices(int ownIndex);
150 void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
151 QuadMaskInfo buildQuadMask(const CoordArray& quadNodes, int numQNodes);
152
153 FinleyElements_ptr reducedElements;
154 FinleyNodes_ptr nodeMesh;
155 FinleyNodes_ptr originalMesh;
156 std::string name;
157 int numElements;
158 int numGhostElements;
159 int nodesPerElement;
160 ZoneType type;
161 Finley_ElementTypeId finleyTypeId;
162 IntVec nodes;
163 IntVec color, ID, tag;
164 IntVec owner;
165 QuadMaskInfo quadMask, reducedQuadMask;
166 int elementFactor;
167 };
168
169 } // namespace weipa
170
171 #endif // __WEIPA_FINLEYELEMENTS_H__
172

  ViewVC Help
Powered by ViewVC 1.1.26