XdmfRegularGrid.hpp 7.75 KB
Newer Older
Kenneth Leiter's avatar
Kenneth Leiter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*****************************************************************************/
/*                                    XDMF                                   */
/*                       eXtensible Data Model and Format                    */
/*                                                                           */
/*  Id : XdmfRegularGrid.hpp                                                 */
/*                                                                           */
/*  Author:                                                                  */
/*     Kenneth Leiter                                                        */
/*     kenneth.leiter@arl.army.mil                                           */
/*     US Army Research Laboratory                                           */
/*     Aberdeen Proving Ground, MD                                           */
/*                                                                           */
/*     Copyright @ 2011 US Army Research Laboratory                          */
/*     All Rights Reserved                                                   */
/*     See Copyright.txt for details                                         */
/*                                                                           */
/*     This software is distributed WITHOUT ANY WARRANTY; without            */
/*     even the implied warranty of MERCHANTABILITY or FITNESS               */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice             */
/*     for more information.                                                 */
/*                                                                           */
/*****************************************************************************/

24 25
#ifndef XDMFREGULARGRID_HPP_
#define XDMFREGULARGRID_HPP_
26

27 28 29
// Forward Declarations
class XdmfArray;

30
// Includes
31
#include "Xdmf.hpp"
32 33 34
#include "XdmfGrid.hpp"

/**
35 36
 * @brief A regular grid consists of congruent points arranged
 * regularly in space.
37
 *
38 39 40
 * XdmfRegularGrid represents a regular mesh of congruent points
 * arranged in space. In order to define a regular grid, three sets of
 * terms need to be supplied:
41 42 43 44 45
 *
 * 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.
 */
46
class XDMF_EXPORT XdmfRegularGrid : public XdmfGrid {
47

48
public:
49 50 51 52 53 54 55 56 57 58 59 60 61

  /**
   * Create a new structured grid (Two dimensional).
   *
   * @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.
   *
   * @return constructed structured grid.
   */
62 63 64 65 66 67
  static shared_ptr<XdmfRegularGrid> New(const double xBrickSize,
                                         const double yBrickSize,
                                         const unsigned int xNumPoints,
                                         const unsigned int yNumPoints,
                                         const double xOrigin,
                                         const double yOrigin);
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

  /**
   * Create a new structured grid (Three dimensional).
   *
   * @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.
   *
   * @return constructed structured grid.
   */
84 85 86 87 88 89 90 91 92
  static shared_ptr<XdmfRegularGrid> New(const double xBrickSize,
                                         const double yBrickSize,
                                         const double zBrickSize,
                                         const unsigned int xNumPoints,
                                         const unsigned int yNumPoints,
                                         const unsigned int zNumPoints,
                                         const double xOrigin,
                                         const double yOrigin,
                                         const double zOrigin);
93 94 95 96 97 98 99 100 101 102

  /**
   * 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.
   */
103 104 105 106
  static shared_ptr<XdmfRegularGrid>
  New(const shared_ptr<XdmfArray> brickSize,
      const shared_ptr<XdmfArray> numPoints,
      const shared_ptr<XdmfArray> origin);
107 108 109 110 111 112 113

  virtual ~XdmfRegularGrid();

  LOKI_DEFINE_VISITABLE(XdmfRegularGrid, XdmfGrid);
  static const std::string ItemTag;

  /**
114
   * Get the size of the bricks composing the grid.
115 116 117
   *
   * @return XdmfArray containing brick sizes for this grid.
   */
118
  shared_ptr<XdmfArray> getBrickSize();
119 120

  /**
121
   * Get the size of the bricks composing the grid (const version).
122 123 124
   *
   * @return XdmfArray containing brick sizes for this grid.
   */
125
  shared_ptr<const XdmfArray> getBrickSize() const;
126 127

  /**
128 129
   * Get the dimensions of the grid, the number of points in each
   * direction.
130 131 132
   *
   * @return XdmfArray containing dimensions of this grid.
   */
133
  shared_ptr<XdmfArray> getDimensions();
134 135

  /**
136 137
   * Get the dimensions of the grid, the number of points in each
   * direction (const version).
138 139 140
   *
   * @return XdmfArray containing the dimensions of this grid.
   */
141
  shared_ptr<const XdmfArray> getDimensions() const;
142 143 144 145

  /**
   * Get the location of the origin of the grid.
   *
146 147
   * @return XdmfArray containing the location of the origin of the
   * grid.
148
   */
149
  shared_ptr<XdmfArray> getOrigin();
150 151 152 153

  /**
   * Get the location of the origin of the grid.
   *
154 155
   * @return XdmfArray containing the location of the origin of the
   * grid (const version).
156
   */
157
  shared_ptr<const XdmfArray> getOrigin() const;
158 159 160 161

  /**
   * Set the size of the points composing the grid.
   *
162 163 164
   * @param brickSize the sizes of the points composing the mesh. This
   * should have the same number of terms as the dimensionality of the
   * mesh.
165
   */
166
  void setBrickSize(const shared_ptr<XdmfArray> brickSize);
167 168

  /**
169 170
   * Set the dimensions of the grid, the number of points in each
   * direction.
171 172 173
   *
   * @param dimensions the dimension of the grid.
   */
174
  void setDimensions(const shared_ptr<XdmfArray> dimensions);
175 176 177 178

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

184
protected:
185

186 187 188
  XdmfRegularGrid(const shared_ptr<XdmfArray> brickSize,
                  const shared_ptr<XdmfArray> numPoints,
                  const shared_ptr<XdmfArray> origin);
189 190

  void populateItem(const std::map<std::string, std::string> & itemProperties,
191
                    std::vector<shared_ptr<XdmfItem> > & childItems,
192 193
                    const XdmfCoreReader * const reader);

194
private:
195 196 197 198 199 200 201 202 203 204

  /**
   * PIMPL
   */
  class XdmfRegularGridImpl;

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

  XdmfRegularGridImpl * mImpl;
205 206 207

};

208
#ifdef _WIN32
209
XDMF_TEMPLATE template class XDMF_EXPORT
210
shared_ptr<XdmfArray>;
211
XDMF_TEMPLATE template class XDMF_EXPORT
212
shared_ptr<const XdmfArray>;
213 214
#endif

215
#endif /* XDMFREGULARGRID_HPP_ */