XdmfRectilinearGrid.hpp 6.48 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 : XdmfRectilinearGrid.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 XDMFRECTILINEARGRID_HPP_
#define XDMFRECTILINEARGRID_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 rectilinear grid consists of cells and points arranged on
 * a regular lattice in space.
37
 *
38 39 40
 * XdmfRectilinearGrid represents a mesh of cells and points arranged
 * on a regular lattice in space. Points are arranged along coordinate
 * axes, but the spacing between points may vary.
41
 *
42 43
 * In order to define a rectilinear grid, the coordinates along each
 * axis direction must be specified.
44 45
 *
 */
46
class XDMF_EXPORT XdmfRectilinearGrid : public XdmfGrid {
47

48
public:
49 50 51 52 53 54 55 56 57

  /**
   * Create a new rectilinear grid (Two dimensional).
   *
   * @param xCoordinates the coordinates of points along the x axis
   * @param yCoordinates the coordinates of points along the y axis.
   *
   * @return constructed rectilinear grid.
   */
58 59 60
  static shared_ptr<XdmfRectilinearGrid>
  New(const shared_ptr<XdmfArray> xCoordinates,
      const shared_ptr<XdmfArray> yCoordinates);
61 62 63 64 65 66 67 68 69 70

  /**
   * Create a new rectilinear grid (Three dimensional).
   *
   * @param xCoordinates the coordinates of points along the x axis
   * @param yCoordinates the coordinates of points along the y axis.
   * @param zCoordinates the coordinates of points along the z axis.
   *
   * @return constructed rectilinear grid.
   */
71 72 73 74
  static shared_ptr<XdmfRectilinearGrid>
  New(const shared_ptr<XdmfArray> xCoordinates,
      const shared_ptr<XdmfArray> yCoordinates,
      const shared_ptr<XdmfArray> zCoordinates);
75 76 77 78 79 80 81 82

  /**
   * Create a new rectilinear grid (N dimensional).
   *
   * @param axesCoordinates the coordinates of points along each axis.
   *
   * @return constructed rectilinear grid.
   */
83 84
  static shared_ptr<XdmfRectilinearGrid>
  New(const std::vector<shared_ptr<XdmfArray> > & axesCoordinates);
85 86 87 88 89 90 91 92 93

  virtual ~XdmfRectilinearGrid();

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

  /**
   * Get the coordinates of the grid along a single axis.
   *
94 95
   * @param axisIndex the index of the axis to retrieve, (i.e. 0 for
   * x-axis). If no array exists at the index, return NULL.
96 97 98
   *
   * @return array of coordinates along
   */
99
  shared_ptr<XdmfArray> getCoordinates(const unsigned int axisIndex);
100 101

  /**
102 103
   * Get the coordinates of the grid along a single axis (const
   * version).
104
   *
105 106
   * @param axisIndex the index of the axis to retrieve (i.e. 0 for
   * x-axis). If no array exists at the index, return NULL.
107 108 109
   *
   * @return array of coordinates along
   */
110
  shared_ptr<const XdmfArray>
111 112 113 114 115
  getCoordinates(const unsigned int axisIndex) const;

  /**
   * Get the coordinates of the grid along all axes.
   *
116 117
   * @return vector containing an array of coordinates along each
   * direction.
118
   */
119
  std::vector<shared_ptr<XdmfArray> > getCoordinates();
120 121 122 123

  /**
   * Get the coordinates of the grid along all axes (const version).
   *
124 125
   * @return vector containing an array of coordinates along each
   * direction.
126
   */
127
  const std::vector<shared_ptr<XdmfArray> > getCoordinates() const;
128 129

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

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

  /**
   * Set the coordinates of the grid along a single axis.
   *
   * @param axisIndex the index of the axis to set (i.e. 0 for x-axis).
149 150
   * @param axisCoordinates the coordinates of points along a single axis to
   * set.
151 152
   */
  void setCoordinates(const unsigned int axisIndex,
153
                      const shared_ptr<XdmfArray> axisCoordinates);
154 155 156 157 158 159 160

  /**
   * Set the coordinates of the grid along all axes.
   *
   * @param axesCoordinates the coordinates of points along each axis.
   */
  void
161
  setCoordinates(const std::vector<shared_ptr<XdmfArray> > axesCoordinates);
162

163
protected:
164

165
  XdmfRectilinearGrid(const std::vector<shared_ptr<XdmfArray> > & axesCoordinates);
166 167

  void populateItem(const std::map<std::string, std::string> & itemProperties,
168
                    const std::vector<shared_ptr<XdmfItem> > & childItems,
169 170
                    const XdmfCoreReader * const reader);

171
private:
172 173 174 175 176 177 178 179 180 181

  /**
   * PIMPL
   */
  class XdmfRectilinearGridImpl;

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

  XdmfRectilinearGridImpl * mImpl;
182 183 184

};

185
#ifdef _WIN32
186
XDMF_TEMPLATE template class XDMF_EXPORT
187
shared_ptr<XdmfArray>;
188
XDMF_TEMPLATE template class XDMF_EXPORT
189
shared_ptr<const XdmfArray>;
190 191
#endif

192
#endif /* XDMFRECTILINEARGRID_HPP_ */