XdmfRectilinearGrid.hpp 12 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

  /**
   * Create a new rectilinear grid (Two dimensional).
   *
53 54 55 56
   * Example of use:
   *
   * C++
   *
57
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
58 59 60 61
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initialization2
   * @until //#initialization2
62 63 64
   *
   * Python
   *
65
   * @dontinclude XdmfExampleRectilinearGrid.py
66 67 68 69
   * @skipline #//initvalues
   * @until #//initvalues
   * @skipline #//initialization2
   * @until #//initialization2
70
   *
71 72
   * @param     xCoordinates    The coordinates of points along the x axis
   * @param     yCoordinates    The coordinates of points along the y axis.
73
   *
74
   * @return                    Constructed rectilinear grid.
75
   */
76 77 78
  static shared_ptr<XdmfRectilinearGrid>
  New(const shared_ptr<XdmfArray> xCoordinates,
      const shared_ptr<XdmfArray> yCoordinates);
79 80 81 82

  /**
   * Create a new rectilinear grid (Three dimensional).
   *
83 84 85 86
   * Example of use:
   *
   * C++
   *
87
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
88 89 90 91
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initialization3
   * @until //#initialization3
92 93 94
   *
   * Python
   *
95
   * @dontinclude XdmfExampleRectilinearGrid.py
96 97 98 99
   * @skipline #//initvalues
   * @until #//initvalues
   * @skipline #//initialization3
   * @until #//initialization3
100
   *
101 102 103
   * @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.
104
   *
105
   * @return                    Constructed rectilinear grid.
106
   */
107 108 109 110
  static shared_ptr<XdmfRectilinearGrid>
  New(const shared_ptr<XdmfArray> xCoordinates,
      const shared_ptr<XdmfArray> yCoordinates,
      const shared_ptr<XdmfArray> zCoordinates);
111 112 113 114

  /**
   * Create a new rectilinear grid (N dimensional).
   *
115 116 117 118
   * Example of use:
   *
   * C++
   *
119
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
120 121 122 123
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initializationvector
   * @until //#initializationvector
124 125 126
   *
   * Python
   *
127
   * @dontinclude XdmfExampleRectilinearGrid.py
128 129 130 131
   * @skipline #//initvalues
   * @until #//initvalues
   * @skipline #//initializationvector
   * @until #//initializationvector
132
   *
133
   * @param     axesCoordinates         The coordinates of points along each axis.
134
   *
135
   * @return                            Constructed rectilinear grid.
136
   */
137 138
  static shared_ptr<XdmfRectilinearGrid>
  New(const std::vector<shared_ptr<XdmfArray> > & axesCoordinates);
139 140 141

  virtual ~XdmfRectilinearGrid();

142
  LOKI_DEFINE_VISITABLE(XdmfRectilinearGrid, XdmfGrid)
143 144 145 146 147
  static const std::string ItemTag;

  /**
   * Get the coordinates of the grid along a single axis.
   *
148 149 150 151
   * Example of use:
   *
   * C++
   *
152
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
153 154 155 156 157 158
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initialization2
   * @until //#initialization2
   * @skipline //#getCoodinatessingle
   * @until //#getCoodinatessingle
159 160 161
   *
   * Python
   *
162
   * @dontinclude XdmfExampleRectilinearGrid.py
163 164 165 166 167 168
   * @skipline #//initvalues
   * @until #//initvalues
   * @skipline #//initialization2
   * @until #//initialization2
   * @skipline #//getCoodinatessingle
   * @until #//getCoodinatessingle
169
   *
170 171 172
   * @param     axisIndex       The index of the axis to retrieve, (i.e. 0 for
   *                            x-axis). If no array exists at the index,
   *                            return NULL.
173
   *
174
   * @return                    Array of coordinates along requested axis
175
   */
176
  shared_ptr<XdmfArray> getCoordinates(const unsigned int axisIndex);
177 178

  /**
179 180
   * Get the coordinates of the grid along a single axis (const
   * version).
181
   *
182 183 184 185
   * Example of use:
   *
   * C++
   *
186
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
187 188 189 190 191 192
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initialization2
   * @until //#initialization2
   * @skipline //#getCoodinatessingleconst
   * @until //#getCoodinatessingleconst
193 194 195
   *
   * Python: does not support a constant version of this function
   *
196 197 198
   * @param     axisIndex       The index of the axis to retrieve (i.e. 0 for
   *                            x-axis). If no array exists at the index,
   *                            return NULL.
199
   *
200
   * @return                    Array of coordinates along requeste axis
201
   */
202
  shared_ptr<const XdmfArray>
203 204 205 206 207
  getCoordinates(const unsigned int axisIndex) const;

  /**
   * Get the coordinates of the grid along all axes.
   *
208 209 210 211
   * Example of use:
   *
   * C++
   *
212
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
213 214 215 216 217 218
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initializationvector
   * @until //#initializationvector
   * @skipline //#getCoodinatesvector
   * @until //#getCoodinatesvector
219 220 221
   *
   * Python
   *
222
   * @dontinclude XdmfExampleRectilinearGrid.py
223 224 225 226 227 228
   * @skipline #//initvalues
   * @until #//initvalues
   * @skipline #//initializationvector
   * @until #//initializationvector
   * @skipline #//getCoodinatesvector
   * @until #//getCoodinatesvector
229
   *
230 231
   * @return    Vector containing an array of coordinates along each
   *            direction.
232
   */
233
  std::vector<shared_ptr<XdmfArray> > getCoordinates();
234 235 236 237

  /**
   * Get the coordinates of the grid along all axes (const version).
   *
238 239
   * Example of use:
   *
240 241 242
   * C++
   *
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
243 244 245 246 247 248
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initializationvector
   * @until //#initializationvector
   * @skipline //#getCoodinatesvectorconst
   * @until //#getCoodinatesvectorconst
249 250 251
   *
   * Python: does not support a constant version of this function
   *
252 253
   * @return    Vector containing an array of coordinates along each
   *            direction.
254
   */
255
  const std::vector<shared_ptr<XdmfArray> > getCoordinates() const;
256 257

  /**
258 259
   * Get the dimensions of the grid, the number of points in each
   * direction.
260
   *
261 262 263 264
   * Example of use:
   *
   * C++
   *
265
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
266 267 268 269 270 271
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initializationvector
   * @until //#initializationvector
   * @skipline //#getDimensions
   * @until //#getDimensions
272 273 274
   *
   * Python
   *
275
   * @dontinclude XdmfExampleRectilinearGrid.py
276 277 278 279 280 281
   * @skipline #//initvalues
   * @until #//initvalues
   * @skipline #//initializationvector
   * @until #//initializationvector
   * @skipline #//getDimensions
   * @until #//getDimensions
282
   *
283
   * @return    XdmfArray containing dimensions of this grid.
284
   */
285
  shared_ptr<XdmfArray> getDimensions();
286 287

  /**
288 289
   * Get the dimensions of the grid, the number of points in each
   * direction (const version).
290
   *
291 292 293 294
   * Example of use:
   *
   * C++
   *
295
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
296 297 298 299 300 301
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initializationvector
   * @until //#initializationvector
   * @skipline //#getDimensionsconst
   * @until //#getDimensionsconst
302 303 304
   *
   * Python: Doesn't support a constant version of this function
   *
305
   * @return    XdmfArray containing the dimensions of this grid.
306
   */
307
  shared_ptr<const XdmfArray> getDimensions() const;
308 309 310 311

  /**
   * Set the coordinates of the grid along a single axis.
   *
312 313 314 315
   * Example of use:
   *
   * C++
   *
316
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
317 318 319 320 321 322
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initialization3
   * @until //#initialization3
   * @skipline //#setCoordinatessingle
   * @until //#setCoordinatessingle
323 324 325
   *
   * Python
   *
326
   * @dontinclude XdmfExampleRectilinearGrid.py
327 328 329 330 331 332
   * @skipline #//initvalues
   * @until #//initvalues
   * @skipline #//initialization3
   * @until #//initialization3
   * @skipline #//setCoordinatessingle
   * @until #//setCoordinatessingle
333
   *
334 335 336 337
   * @param     axisIndex               The index of the axis to set
   *                                    (i.e. 0 for x-axis).
   * @param     axisCoordinates         The coordinates of points along
   *                                    a single axis to set.
338 339
   */
  void setCoordinates(const unsigned int axisIndex,
340
                      const shared_ptr<XdmfArray> axisCoordinates);
341 342 343 344

  /**
   * Set the coordinates of the grid along all axes.
   *
345 346 347 348
   * Example of use:
   *
   * C++
   *
349
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
350 351 352 353 354 355
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initializationvector
   * @until //#initializationvector
   * @skipline //#setCoordinatesvector
   * @until //#setCoordinatesvector
356 357 358
   *
   * Python
   *
359
   * @dontinclude XdmfExampleRectilinearGrid.py
360 361 362 363 364 365
   * @skipline #//initvalues
   * @until #//initvalues
   * @skipline #//initializationvector
   * @until #//initializationvector
   * @skipline #//setCoordinatesvector
   * @until #//setCoordinatesvector
366
   *
367 368
   * @param     axesCoordinates         The coordinates of points
   *                                    along each axis.
369 370
   */
  void
371
  setCoordinates(const std::vector<shared_ptr<XdmfArray> > axesCoordinates);
372

373
protected:
374

375
  XdmfRectilinearGrid(const std::vector<shared_ptr<XdmfArray> > & axesCoordinates);
376 377

  void populateItem(const std::map<std::string, std::string> & itemProperties,
378
                    const std::vector<shared_ptr<XdmfItem> > & childItems,
379 380
                    const XdmfCoreReader * const reader);

381
private:
382 383 384 385 386 387 388 389 390 391

  /**
   * PIMPL
   */
  class XdmfRectilinearGridImpl;

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

  XdmfRectilinearGridImpl * mImpl;
392 393 394

};

395
#ifdef _WIN32
396
XDMF_TEMPLATE template class XDMF_EXPORT
397
shared_ptr<XdmfArray>;
398
XDMF_TEMPLATE template class XDMF_EXPORT
399
shared_ptr<const XdmfArray>;
400 401
#endif

402
#endif /* XDMFRECTILINEARGRID_HPP_ */