/[escript]/branches/diaplayground/weipa/src/SpeckleyElements.h
ViewVC logotype

Contents of /branches/diaplayground/weipa/src/SpeckleyElements.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5147 - (show annotations)
Fri Sep 12 00:33:02 2014 UTC (4 years, 8 months ago) by caltinay
File MIME type: text/plain
File size: 5059 byte(s)
merge to latest trunk.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 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 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17 #ifndef __WEIPA_SPECKLEYELEMENTS_H__
18 #define __WEIPA_SPECKLEYELEMENTS_H__
19
20 #include <weipa/ElementData.h>
21 #include <weipa/SpeckleyNodes.h>
22
23 class DBfile;
24
25 namespace speckley {
26 class SpeckleyDomain;
27 }
28
29
30 namespace weipa {
31
32 class SpeckleyElements;
33 typedef boost::shared_ptr<SpeckleyElements> SpeckleyElements_ptr;
34
35 /// \brief Stores and manipulates one type of speckley mesh elements (cells,
36 /// faces).
37 ///
38 /// This class provides functionality to manipulate a speckley domain.
39 /// It is able to load element data from NetCDF files or retrieve it from
40 /// a SpeckleyDomain instance.
41 ///
42 /// \note The corresponding mesh nodes are not part of this class but are
43 /// stored in a NodeData instance.
44 class SpeckleyElements : public ElementData
45 {
46 public:
47
48 /// \brief Constructor with name and accompanying NodeData object.
49 SpeckleyElements(const std::string& elementName, SpeckleyNodes_ptr nodes);
50
51 /// \brief Copy constructor
52 SpeckleyElements(const SpeckleyElements& e);
53
54 /// \brief Destructor
55 virtual ~SpeckleyElements() {}
56
57 /// \brief Initialises with data from a SpeckleyDomain instance.
58 bool initFromSpeckley(const speckley::SpeckleyDomain* speckleyDomain, int fsType);
59
60 /// \brief Moves "ghost" elements (whose owner does not match ownIndex)
61 /// and the corresponding data to the end of the arrays.
62 void reorderGhostZones(int ownIndex);
63
64 /// \brief Removes "ghost" elements.
65 void removeGhostZones(int ownIndex);
66
67 /// \brief Writes connectivity data to a stream in VTK text format.
68 virtual void writeConnectivityVTK(std::ostream& os);
69
70 /// \brief Writes element data into given directory in given Silo file.
71 ///
72 /// Since the mesh depends on element information this method also writes
73 /// the node mesh itself. If Silo was not available at compile time or if
74 /// a Silo function fails this method returns false.
75 bool writeToSilo(DBfile* dbfile, const std::string& siloPath,
76 const StringVec& labels, const StringVec& units,
77 bool writeMeshData);
78
79 /// \brief Returns the names of the meshes associated with the elements.
80 virtual StringVec getMeshNames() const;
81
82 /// \brief Returns a vector with the mesh variable names.
83 virtual StringVec getVarNames() const;
84
85 /// \brief Returns the number of elements.
86 virtual int getNumElements() const { return numElements; }
87
88 /// \brief Returns the number of nodes per element.
89 virtual int getNodesPerElement() const { return nodesPerElement; }
90
91 /// \brief Returns the number of "ghost" elements.
92 virtual int getGhostCount() const { return numGhostElements; }
93
94 /// \brief Returns the type of the elements.
95 virtual ZoneType getType() const { return type; }
96
97 /// \brief Returns a vector of the node IDs used by the elements.
98 virtual const IntVec& getNodeList() const { return nodes; }
99
100 /// \brief Returns a vector of element IDs.
101 virtual const IntVec& getIDs() const { return ID; }
102
103 /// \brief Returns an array of data values for the name provided.
104 ///
105 /// The name must be one of the names returned from getVarNames().
106 virtual const IntVec& getVarDataByName(const std::string varName) const;
107
108 /// \brief Returns the node mesh instance used by the elements.
109 virtual NodeData_ptr getNodes() const { return nodeMesh; }
110
111 /// \brief Returns the reduced elements.
112 virtual ElementData_ptr getReducedElements() const { return ElementData_ptr(); }
113
114 /// \brief Returns a QuadMaskInfo structure for given functionspace code.
115 virtual const QuadMaskInfo& getQuadMask(int functionSpace) const { return quadMask; }
116
117 /// \brief If the original element type is not supported they are
118 /// subdivided into N smaller elements (e.g. one Rec9 -> four Rec4)
119 /// and this method returns the multiplication factor N.
120 virtual int getElementFactor() const { return 1; }
121
122 private:
123 SpeckleyElements() {}
124 void buildMeshes();
125 IntVec prepareGhostIndices(int ownIndex);
126 void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
127
128 SpeckleyNodes_ptr nodeMesh;
129 SpeckleyNodes_ptr originalMesh;
130 std::string name;
131 int numElements;
132 int numGhostElements;
133 int nodesPerElement;
134 ZoneType type;
135 IntVec nodes;
136 IntVec ID, tag, owner;
137 QuadMaskInfo quadMask; // dummy
138 };
139
140 } // namespace weipa
141
142 #endif // __WEIPA_SPECKLEYELEMENTS_H__
143

  ViewVC Help
Powered by ViewVC 1.1.26