XdmfRectilinearGrid.hpp 13.5 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
// C Compatible Includes
28
#include "Xdmf.hpp"
29 30
#include "XdmfGrid.hpp"

31 32 33 34 35
#ifdef __cplusplus

// Forward Declarations
class XdmfArray;

36
/**
37 38
 * @brief A rectilinear grid consists of cells and points arranged on
 * a regular lattice in space.
39
 *
40 41 42
 * 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.
43
 *
44 45
 * In order to define a rectilinear grid, the coordinates along each
 * axis direction must be specified.
46 47
 *
 */
48
class XDMF_EXPORT XdmfRectilinearGrid : public XdmfGrid {
49

50
public:
51 52 53 54

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

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

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

  virtual ~XdmfRectilinearGrid();

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

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

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

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

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

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

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

311 312 313 314
  virtual void read();

  virtual void release();

315 316 317
  /**
   * Set the coordinates of the grid along a single axis.
   *
318 319 320 321
   * Example of use:
   *
   * C++
   *
322
   * @dontinclude ExampleXdmfRectilinearGrid.cpp
323 324 325 326 327 328
   * @skipline //#initvalues
   * @until //#initvalues
   * @skipline //#initialization3
   * @until //#initialization3
   * @skipline //#setCoordinatessingle
   * @until //#setCoordinatessingle
329 330 331
   *
   * Python
   *
332
   * @dontinclude XdmfExampleRectilinearGrid.py
333 334 335 336 337 338
   * @skipline #//initvalues
   * @until #//initvalues
   * @skipline #//initialization3
   * @until #//initialization3
   * @skipline #//setCoordinatessingle
   * @until #//setCoordinatessingle
339
   *
340 341 342 343
   * @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.
344 345
   */
  void setCoordinates(const unsigned int axisIndex,
346
                      const shared_ptr<XdmfArray> axisCoordinates);
347 348 349 350

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

379 380
  XdmfRectilinearGrid(XdmfRectilinearGrid &);

381
protected:
382

383
  XdmfRectilinearGrid(const std::vector<shared_ptr<XdmfArray> > & axesCoordinates);
384

385 386
  void copyGrid(shared_ptr<XdmfGrid> sourceGrid);

387
  void populateItem(const std::map<std::string, std::string> & itemProperties,
388
                    const std::vector<shared_ptr<XdmfItem> > & childItems,
389 390
                    const XdmfCoreReader * const reader);

391
private:
392 393 394 395 396 397 398 399 400

  /**
   * PIMPL
   */
  class XdmfRectilinearGridImpl;

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

401 402
};

403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
#endif

#ifdef __cplusplus
extern "C" {
#endif

// C wrappers go here

struct XDMFRECTILINEARGRID; // Simply as a typedef to ensure correct typing
typedef struct XDMFRECTILINEARGRID XDMFRECTILINEARGRID;

XDMF_EXPORT XDMFRECTILINEARGRID * XdmfRectilinearGridNew(XDMFARRAY ** axesCoordinates, unsigned int numCoordinates, int passControl);

XDMF_EXPORT XDMFRECTILINEARGRID * XdmfRectilinearGridNew2D(XDMFARRAY * xCoordinates, XDMFARRAY * yCoordinates, int passControl);

XDMF_EXPORT XDMFRECTILINEARGRID * XdmfRectilinearGridNew3D(XDMFARRAY * xCoordinates, XDMFARRAY * yCoordinates, XDMFARRAY * zCoordinates, int passControl);

XDMF_EXPORT XDMFARRAY * XdmfRectilinearGridGetCoordinatesByIndex(XDMFRECTILINEARGRID * grid, unsigned int axisIndex, int * status);

XDMF_EXPORT XDMFARRAY ** XdmfRectilinearGridGetCoordinates(XDMFRECTILINEARGRID * grid, int * status);

XDMF_EXPORT int XdmfRectilinearGridGetNumberCoordinates(XDMFRECTILINEARGRID * grid, int * status);

XDMF_EXPORT XDMFARRAY * XdmfRectilinearGridGetDimensions(XDMFRECTILINEARGRID * grid, int * status);

XDMF_EXPORT void XdmfRectilinearGridSetCoordinates(XDMFRECTILINEARGRID * grid, XDMFARRAY ** axesCoordinates, unsigned int numCoordinates, int passControl, int * status);

XDMF_EXPORT void XdmfRectilinearGridSetCoordinatesByIndex(XDMFRECTILINEARGRID * grid, unsigned int index, XDMFARRAY * coordinates, int passControl, int * status);

XDMF_ITEM_C_CHILD_DECLARE(XdmfRectilinearGrid, XDMFRECTILINEARGRID, XDMF)
XDMF_GRID_C_CHILD_DECLARE(XdmfRectilinearGrid, XDMFRECTILINEARGRID, XDMF)

#ifdef __cplusplus
}
#endif

439
#endif /* XDMFRECTILINEARGRID_HPP_ */