XdmfGrid.hpp 7.09 KB
Newer Older
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
1 2 3 4 5 6
#ifndef XDMFGRID_HPP_
#define XDMFGRID_HPP_

// Forward Declarations
class XdmfAttribute;
class XdmfGeometry;
7
class XdmfSet;
8
class XdmfTime;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
9 10 11
class XdmfTopology;

// Includes
12
#include "XdmfItem.hpp"
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
13

14 15 16 17 18
/**
 * @brief A mesh that consists of elements, points, and values attached to the mesh.
 *
 * XdmfGrid represents a mesh.  It is required to contain two other Xdmf data structures, an XdmfGeometry
 * that stores point locations and an XdmfTopology that store connectivity information.  XdmfAttributes can be inserted
19 20
 * into the XdmfGrid to specify values attached at various parts of the mesh.  XdmfSets can be inserted in the XdmfGrid
 * to specify collections of mesh elements.
21
 */
22
class XdmfGrid : public virtual XdmfItem {
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
23 24 25

public:

26 27 28 29 30
	/**
	 * Create a new XdmfGrid.
	 *
	 * @return constructed XdmfGrid.
	 */
31
	static boost::shared_ptr<XdmfGrid> New();
32

33 34
	virtual ~XdmfGrid();

35
	LOKI_DEFINE_VISITABLE(XdmfGrid, XdmfItem)
36
	static const std::string ItemTag;
37

38
	/**
39
	 * Get an attribute attached to this grid by index.
40
	 *
41 42
	 * @param index of the attribute to retrieve.
	 * @return requested attribute.  If not found a NULL pointer is returned.
43
	 */
44
	boost::shared_ptr<XdmfAttribute> getAttribute(const unsigned int index);
45 46

	/**
47
	 * Get an attribute attached to this grid by index (const version).
48
	 *
49 50
	 * @param index of the attribute to retrieve.
	 * @return requested attribute.  If not found a NULL pointer is returned.
51
	 */
52
	boost::shared_ptr<const XdmfAttribute> getAttribute(const unsigned int index) const;
53

54
	/**
55
	 * Get an attribute attached to this grid by name.
56
	 *
57 58
	 * @param name of the attribute to retrieve.
	 * @return requested attribute.  If not found a NULL pointer is returned.
59
	 */
60
	boost::shared_ptr<XdmfAttribute> getAttribute(const std::string & name);
61 62

	/**
63
	 * Get an attribute attached to this grid by name (const version).
64
	 *
65 66
	 * @param name the name of the attribute to retrieve.
	 * @return requested attribute.  If not found a NULL pointer is returned.
67
	 */
68
	boost::shared_ptr<const XdmfAttribute> getAttribute(const std::string & name) const;
69

70
	/**
71
	 * Get the geometry associated with this grid.
72
	 *
73
	 * @return the geometry associated with this grid.
74
	 */
75
	boost::shared_ptr<XdmfGeometry> getGeometry();
76 77

	/**
78
	 * Get the geometry associated with this grid (const version).
79
	 *
80
	 * @return the geometry associated with this grid.
81
	 */
82
	boost::shared_ptr<const XdmfGeometry> getGeometry() const;
83

84 85
	std::map<std::string, std::string> getItemProperties() const;

86
	virtual std::string getItemTag() const;
87

88
	/**
89
	 * Get the name of the grid.
90
	 *
91
	 * @return the name of the grid.
92
	 */
93
	std::string getName() const;
94 95

	/**
96
	 * Get the number of attributes attached to this grid.
97
	 *
98
	 * @return the number of attributes attached to this grid.
99
	 */
100
	unsigned int getNumberAttributes() const;
101

102
	/**
103
	 * Get the number of sets attached to this grid.
104
	 *
105
	 * @return the number of sets attached to this grid.
106
	 */
107
	unsigned int getNumberSets() const;
108 109

	/**
110
	 * Get a set attached to this grid by index.
111
	 *
112 113
	 * @param index of the set to retrieve.
	 * @return requested set.  If not found a NULL pointer is returned.
114
	 */
115
	boost::shared_ptr<XdmfSet> getSet(const unsigned int index);
116 117

	/**
118
	 * Get a set attached to this grid by index (const version).
119
	 *
120 121
	 * @param index of the set to retrieve.
	 * @return requested set.  If not found a NULL pointer is returned.
122
	 */
123
	boost::shared_ptr<const XdmfSet> getSet(const unsigned int index) const;
124

125
	/**
126
	 * Get a set attached to this grid by name.
127
	 *
128 129
	 * @param name of the set to retrieve.
	 * @return requested set.  If not found a NULL pointer is returned.
130 131 132 133
	 */
	boost::shared_ptr<XdmfSet> getSet(const std::string & name);

	/**
134
	 * Get a set attached to this grid by name (const version).
135
	 *
136 137
	 * @param name of the set to retrieve.
	 * @return requested set.  If not found a NULL pointer is returned.
138 139 140 141
	 */
	boost::shared_ptr<const XdmfSet> getSet(const std::string & name) const;

	/**
142
	 * Get the time associated with this grid.
143
	 *
144
	 * @return pointer to the XdmfTime attached to this grid.  If no XdmfTime is attached, return a NULL pointer.
145 146 147 148
	 */
	boost::shared_ptr<XdmfTime> getTime();

	/**
149
	 * Get the time associated with this grid (const version).
150
	 *
151
	 * @return pointer to the XdmfTime attached to this grid.  If no XdmfTime is attached, return a NULL pointer.
152 153 154
	 */
	boost::shared_ptr<const XdmfTime> getTime() const;

155
	/**
156
	 * Get the topology associated with this grid.
157
	 *
158
	 * @return the topology associated with this grid.
159
	 */
160
	boost::shared_ptr<XdmfTopology> getTopology();
161 162

	/**
163
	 * Get the topology associated with this grid (const version).
164
	 *
165
	 * @return the topology associated with this grid.
166
	 */
167
	boost::shared_ptr<const XdmfTopology> getTopology() const;
168

169
	/**
170
	 * Insert an attribute into the grid.
171
	 *
172
	 * @param attribute an XdmfAttribute to attach to this grid.
173
	 */
174
	void insert(const boost::shared_ptr<XdmfAttribute> attribute);
175

176
	/**
177
	 * Insert a set into the grid.
178 179 180
	 *
	 * @param set an XdmfSet to attach to this grid.
	 */
181
	void insert(const boost::shared_ptr<XdmfSet> set);
182

183
	/**
184
	 * Remove an attribute from the grid by index.  If no attribute is at that index, no attributes are removed.
185
	 *
186
	 * @param index of the attribute to remove.
187 188 189
	 */
	void removeAttribute(const unsigned int index);

190
	/**
191
	 * Remove an attribute from the grid by name.  If no attribute having the name is found, no attributes are removed.
192
	 *
193
	 * @param name of the attribute to remove.
194 195 196
	 */
	void removeAttribute(const std::string & name);

197
	/**
198
	 * Remove an set from the grid by index.  If no set is at that index, no sets are removed.
199
	 *
200
	 * @param index of the set to remove.
201 202 203
	 */
	void removeSet(const unsigned int index);

204
	/**
205
	 * Remove an set from the grid by name.  If no set having the name is found, no sets are removed.
206
	 *
207
	 * @param name of the set to remove.
208 209 210
	 */
	void removeSet(const std::string & name);

211
	/**
212
	 * Set the geometry associated with this grid.
213
	 *
214
	 * @param geometry an XdmfGeometry to associate with this grid.
215
	 */
216
	void setGeometry(const boost::shared_ptr<XdmfGeometry> geometry);
217

218
	/**
219
	 * Set the time associated with this grid.
220
	 *
221
	 * @param time an XdmfTime to associate with this grid.
222 223 224
	 */
	void setTime(const boost::shared_ptr<XdmfTime> time);

225
	/**
226
	 * Set the topology associated with this grid.
227
	 *
228
	 * @param topology an XdmfTopology to associate with this grid.
229
	 */
230
	void setTopology(const boost::shared_ptr<XdmfTopology> topology);
231 232

	/**
233 234
	 * Set the name of the grid.
	 *
235
	 * @param name of the grid to set.
236
	 */
237
	void setName(const std::string & name);
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
238

239
	virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
240

Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
241 242 243
protected:

	XdmfGrid();
244
	virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems);
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
245

246 247
	std::string mName;

Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
248 249
private:

250 251
	XdmfGrid(const XdmfGrid & grid);  // Not implemented.
	void operator=(const XdmfGrid & grid);  // Not implemented.
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
252

253
	std::vector<boost::shared_ptr<XdmfAttribute> > mAttributes;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
254
	boost::shared_ptr<XdmfGeometry> mGeometry;
255
	std::vector<boost::shared_ptr<XdmfSet> > mSets;
256
	boost::shared_ptr<XdmfTime> mTime;
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
257 258 259 260
	boost::shared_ptr<XdmfTopology> mTopology;
};

#endif /* XDMFGRID_HPP_ */