XdmfRegularGrid.hpp 5.45 KB
Newer Older
1 2
#ifndef XDMFREGULARGRID_HPP_
#define XDMFREGULARGRID_HPP_
3

4 5 6
// Forward Declarations
class XdmfArray;

7
// Includes
8
#include "Xdmf.hpp"
9 10 11
#include "XdmfGrid.hpp"

/**
12
 * @brief A regular grid consisting of congruent points arranged regularly in space.
13
 *
14
 * XdmfRegularGrid represents a regular mesh of congruent points arranged in space.
15 16 17 18 19 20
 * In order to define a regular grid, three sets of terms need to be supplied:
 *
 * Brick Size (Dx, Dy, (Dz)) - Size of an individual brick.
 * Dimensions (X, Y, (Z)) - Number of points in X, Y, and Z directions
 * Origin Location (X, Y, (Z)) - Location of the origin of the mesh in space.
 */
21
class XDMF_EXPORT XdmfRegularGrid : public XdmfGrid {
22 23 24 25 26 27

public:

	/**
	 * Create a new structured grid (Two dimensional).
	 *
28 29 30 31 32 33
	 * @param xBrickSize the size of the brick in the x direction.
	 * @param yBrickSize the size of the brick in the y direction.
	 * @param xNumPoints the number of points in the x direction.
	 * @param yNumPoints the number of points in the y direction.
	 * @param xOrigin the x coordinate of the origin.
	 * @param yOrigin the y coordinate of the origin.
34 35 36
	 *
	 * @return constructed structured grid.
	 */
37
	static boost::shared_ptr<XdmfRegularGrid> New(const double xBrickSize, const double yBrickSize, const unsigned int xNumPoints,
38
		const unsigned int yNumPoints, const double xOrigin, const double yOrigin);
39 40 41 42

	/**
	 * Create a new structured grid (Three dimensional).
	 *
43 44 45 46 47 48 49 50 51
	 * @param xBrickSize the size of the brick in the x direction.
	 * @param yBrickSize the size of the brick in the y direction.
	 * @param zBrickSize the size of the brick in the z direction.
	 * @param xNumPoints the number of points in the x direction.
	 * @param yNumPoints the number of points in the y direction.
	 * @param zNumPoints the number of points in the z direction.
	 * @param xOrigin the x coordinate of the origin.
	 * @param yOrigin the y coordinate of the origin.
	 * @param zOrigin the z coordinate of the origin.
52 53 54
	 *
	 * @return constructed structured grid.
	 */
55
	static boost::shared_ptr<XdmfRegularGrid> New(const double xBrickSize, const double yBrickSize, const double zBrickSize,
56 57
		const unsigned int xNumPoints, const unsigned int yNumPoints, const unsigned int zNumPoints,
		const double xOrigin, const double yOrigin, const double zOrigin);
58

59 60 61 62 63 64 65 66 67
	/**
	 * Create a new structured grid (N dimensional).
	 *
	 * @param brickSize the size of the brick in each direction.
	 * @param numPoints the number of points in each direction.
	 * @param origin the coordinates of the origin.
	 *
	 * @return constructed structured grid.
	 */
68
	static boost::shared_ptr<XdmfRegularGrid> New(const boost::shared_ptr<XdmfArray> brickSize, const boost::shared_ptr<XdmfArray> numPoints,
69 70
		const boost::shared_ptr<XdmfArray> origin);

71
	virtual ~XdmfRegularGrid();
72

73
	LOKI_DEFINE_VISITABLE(XdmfRegularGrid, XdmfGrid)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
	static const std::string ItemTag;

	/**
	 * Get the size of the points composing the grid.
	 *
	 * @return XdmfArray containing brick sizes for this grid.
	 */
	boost::shared_ptr<XdmfArray> getBrickSize();

	/**
	 * Get the size of the points composing the grid (const version).
	 *
	 * @return XdmfArray containing brick sizes for this grid.
	 */
	boost::shared_ptr<const XdmfArray> getBrickSize() const;

	/**
	 * Get the dimensions of the grid, the number of points in each direction.
	 *
	 * @return XdmfArray containing dimensions of this grid.
	 */
	boost::shared_ptr<XdmfArray> getDimensions();

	/**
98
	 * Get the dimensions of the grid, the number of points in each direction (const version).
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
	 *
	 * @return XdmfArray containing the dimensions of this grid.
	 */
	boost::shared_ptr<const XdmfArray> getDimensions() const;

	/**
	 * Get the location of the origin of the grid.
	 *
	 * @return XdmfArray containing the location of the origin of the grid.
	 */
	boost::shared_ptr<XdmfArray> getOrigin();

	/**
	 * Get the location of the origin of the grid.
	 *
114
	 * @return XdmfArray containing the location of the origin of the grid (const version).
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
	 */
	boost::shared_ptr<const XdmfArray> getOrigin() const;

	/**
	 * Set the size of the points composing the grid.
	 *
	 * @param brickSize the sizes of the points composing the mesh.  This should
	 * have the same number of terms as the dimensionality of the mesh.
	 */
	void setBrickSize(const boost::shared_ptr<XdmfArray> brickSize);

	/**
	 * Set the dimensions of the grid, the number of points in each direction.
	 *
	 * @param dimensions the dimension of the grid.
	 */
	void setDimensions(const boost::shared_ptr<XdmfArray> dimensions);

	/**
	 * Set the origin of the grid.
	 *
	 * @param origin location of the origin of the grid.  This should have
	 * the same number of terms as the dimensionality of the mesh.
	 */
	void setOrigin(const boost::shared_ptr<XdmfArray> origin);

protected:

143
	XdmfRegularGrid(const boost::shared_ptr<XdmfArray> brickSize, const boost::shared_ptr<XdmfArray> numPoints,
144 145
		const boost::shared_ptr<XdmfArray> origin);

146
	void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader);
147 148 149 150 151 152

private:

	/**
	 * PIMPL
	 */
153
	class XdmfRegularGridImpl;
154

155 156
	XdmfRegularGrid(const XdmfRegularGrid & grid);  // Not implemented.
	void operator=(const XdmfRegularGrid & grid);  // Not implemented.
157

158
	XdmfRegularGridImpl * mImpl;
159 160 161

};

162 163 164 165 166
#ifdef _WIN32
    XDMF_TEMPLATE template class XDMF_EXPORT boost::shared_ptr<XdmfArray>;
    XDMF_TEMPLATE template class XDMF_EXPORT boost::shared_ptr<const XdmfArray>;
#endif

167
#endif /* XDMFREGULARGRID_HPP_ */