XdmfGridCollection.hpp 2.59 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
#ifndef XDMFGRIDCOLLECTION_HPP_
#define XDMFGRIDCOLLECTION_HPP_

// Includes
#include "XdmfGrid.hpp"
#include "XdmfGridCollectionType.hpp"

/**
 * @brief A spatial or temporal collection of XdmfGrids.
 *
 * A temporal collection is timestep data.  Each child grid represents the state at a single timestep.
 * A spatial collection consists of XdmfGrids that are arranged together in space.  E.g. a partitioned mesh.
 *
 * It is valid to nest collections.  A spatial collection within a temporal collection is commonly used.
 */
class XdmfGridCollection : public XdmfGrid {

public:

	XdmfNewMacro(XdmfGridCollection);
	LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfGrid)
	static std::string ItemTag;

	/**
	 * Get a grid from this collection.
	 *
	 * @param index of grid to retrieve.
	 * @return the requested XdmfGrid.
	 */
	boost::shared_ptr<XdmfGrid> getGrid(unsigned int index);

	/**
	 * Get a grid from this collection (const version).
	 *
	 * @param index of the grid to retrieve.
	 * @return the requested XdmfGrid.
	 */
	boost::shared_ptr<const XdmfGrid> getGrid(unsigned int index) const;

	/**
	 * Get the XdmfGridCollectionType associated with this grid collection.
	 *
	 * @return XdmfGridCollectionType of this collection.
	 */
	XdmfGridCollectionType getGridCollectionType() const;

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

	/**
	 * Get the number of grids in this collection.
	 *
	 * @return unsigned int containing the number of XdmfGrids in this collection.
	 */
	unsigned int getNumberOfGrids() const;

	/**
	 * Insert a grid into this collection.
	 *
	 * @param grid an XdmfGrid to insert into this collection.
	 */
	void insert(boost::shared_ptr<XdmfGrid> grid);

	/**
	 * Remove a grid from this collection.
	 *
	 * @param index of the XdmfGrid to remove.
	 */
	void removeGrid(const unsigned int index);

	/**
	 * Set the XdmfGridCollectionType associated with this grid collection.
	 *
	 * @param collectionType the XdmfGridCollectionType to set.
	 */
	void setGridCollectionType(const XdmfGridCollectionType & collectionType);

	virtual void traverse(boost::shared_ptr<Loki::BaseVisitor> visitor);

protected:

	XdmfGridCollection();
	virtual ~XdmfGridCollection();
	virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems);

private:

	XdmfGridCollection(const XdmfGridCollection & collection);  // Not implemented.
	void operator=(const XdmfGridCollection & collection);  // Not implemented.

	XdmfGridCollectionType mCollectionType;
	std::vector<boost::shared_ptr<XdmfGrid> > mGrids;
};

#endif /* XDMFGRID_HPP_ */