XdmfRegularGrid.hpp 12.9 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

  /**
   * Create a new structured grid (Two dimensional).
   *
53
54
55
56
   * Example of use:
   *
   * C++
   *
57
   * @dontinclude ExampleXdmfRegularGrid.cpp
58
59
60
61
   * @skipline //#initvalue
   * @until //#initvalue
   * @skipline //#initialization2
   * @until //#initialization2
62
63
64
   *
   * Python
   *
65
   * @dontinclude XdmfExampleRegularGrid.py
66
67
68
69
   * @skipline #//initvalue
   * @until #//initvalue
   * @skipline #//initialization2
   * @until #//initialization2
70
   *
71
72
73
74
75
76
77
78
   * @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.
79
   */
80
81
82
83
84
85
  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);
86
87
88
89

  /**
   * Create a new structured grid (Three dimensional).
   *
90
91
92
93
   * Example of use:
   *
   * C++
   *
94
   * @dontinclude ExampleXdmfRegularGrid.cpp
95
96
97
98
   * @skipline //#initvalue
   * @until //#initvalue
   * @skipline //#initialization3
   * @until //#initialization3
99
100
101
   *
   * Python
   *
102
   * @dontinclude XdmfExampleRegularGrid.py
103
104
105
106
   * @skipline #//initvalue
   * @until #//initvalue
   * @skipline #//initialization3
   * @until #//initialization3
107
   *
108
109
110
111
112
113
114
115
116
117
118
   * @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.
119
   */
120
121
122
123
124
125
126
127
128
  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);
129
130
131
132

  /**
   * Create a new structured grid (N dimensional).
   *
133
134
135
136
   * Example of use:
   *
   * C++
   *
137
   * @dontinclude ExampleXdmfRegularGrid.cpp
138
139
   * @skipline //#initializationvector
   * @until //#initializationvector
140
141
142
   *
   * Python
   *
143
   * @dontinclude XdmfExampleRegularGrid.py
144
145
   * @skipline #//initializationvector
   * @until #//initializationvector
146
   *
147
148
149
   * @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.
150
   *
151
   * @return                    Constructed structured grid.
152
   */
153
154
155
156
  static shared_ptr<XdmfRegularGrid>
  New(const shared_ptr<XdmfArray> brickSize,
      const shared_ptr<XdmfArray> numPoints,
      const shared_ptr<XdmfArray> origin);
157
158
159

  virtual ~XdmfRegularGrid();

160
  LOKI_DEFINE_VISITABLE(XdmfRegularGrid, XdmfGrid)
161
162
163
  static const std::string ItemTag;

  /**
164
   * Get the size of the bricks composing the grid.
165
   *
166
167
168
169
   * Example of use:
   *
   * C++
   *
170
   * @dontinclude ExampleXdmfRegularGrid.cpp
171
172
173
174
175
176
   * @skipline //#initvalue
   * @until //#initvalue
   * @skipline //#initialization2
   * @until //#initialization2
   * @skipline //#getBrickSize
   * @until //#getBrickSize
177
178
179
   *
   * Python
   *
180
   * @dontinclude XdmfExampleRegularGrid.py
181
182
183
184
185
186
   * @skipline #//initvalue
   * @until #//initvalue
   * @skipline #//initialization2
   * @until #//initialization2
   * @skipline #//getBrickSize
   * @until #//getBrickSize
187
   *
188
   * @return    XdmfArray containing brick sizes for this grid.
189
   */
190
  shared_ptr<XdmfArray> getBrickSize();
191
192

  /**
193
   * Get the size of the bricks composing the grid (const version).
194
   *
195
196
197
198
   * Example of use:
   *
   * C++
   *
199
   * @dontinclude ExampleXdmfRegularGrid.cpp
200
201
202
203
204
205
   * @skipline //#initvalue
   * @until //#initvalue
   * @skipline //#initialization2
   * @until //#initialization2
   * @skipline //#getBrickSizeconst
   * @until //#getBrickSizeconst
206
207
208
   *
   * Python: Does not support a constant version of this function
   *
209
   * @return    XdmfArray containing brick sizes for this grid.
210
   */
211
  shared_ptr<const XdmfArray> getBrickSize() const;
212
213

  /**
214
215
   * Get the dimensions of the grid, the number of points in each
   * direction.
216
   *
217
218
219
220
   * Example of use:
   *
   * C++
   *
221
   * @dontinclude ExampleXdmfRegularGrid.cpp
222
223
224
225
226
227
   * @skipline //#initvalue
   * @until //#initvalue
   * @skipline //#initialization2
   * @until //#initialization2
   * @skipline //#getDimensions
   * @until //#getDimensions
228
229
230
   *
   * Python
   *
231
   * @dontinclude XdmfExampleRegularGrid.py
232
233
234
235
236
237
   * @skipline #//initvalue
   * @until #//initvalue
   * @skipline #//initialization2
   * @until #//initialization2
   * @skipline #//getDimensions
   * @until #//getDimensions
238
   *
239
   * @return    XdmfArray containing dimensions of this grid.
240
   */
241
  shared_ptr<XdmfArray> getDimensions();
242
243

  /**
244
245
   * Get the dimensions of the grid, the number of points in each
   * direction (const version).
246
   *
247
248
249
250
   * Example of use:
   *
   * C++
   *
251
   * @dontinclude ExampleXdmfRegularGrid.cpp
252
253
254
255
256
257
   * @skipline //#initvalue
   * @until //#initvalue
   * @skipline //#initialization2
   * @until //#initialization2
   * @skipline //#getDimensionsconst
   * @until //#getDimensionsconst
258
259
260
   *
   * Python: Does not support a constant version of this function
   *
261
   * @return    XdmfArray containing the dimensions of this grid.
262
   */
263
  shared_ptr<const XdmfArray> getDimensions() const;
264
265
266
267

  /**
   * Get the location of the origin of the grid.
   *
268
269
270
271
   * Example of use:
   *
   * C++
   *
272
   * @dontinclude ExampleXdmfRegularGrid.cpp
273
274
275
276
277
278
   * @skipline //#initvalue
   * @until //#initvalue
   * @skipline //#initialization2
   * @until //#initialization2
   * @skipline //#getOrigin
   * @until //#getOrigin
279
280
281
   *
   * Python
   *
282
   * @dontinclude XdmfExampleRegularGrid.py
283
284
285
286
287
288
   * @skipline #//initvalue
   * @until #//initvalue
   * @skipline #//initialization2
   * @until #//initialization2
   * @skipline #//getOrigin
   * @until #//getOrigin
289
   *
290
291
   * @return    XdmfArray containing the location of the origin of the
   *            grid.
292
   */
293
  shared_ptr<XdmfArray> getOrigin();
294
295
296
297

  /**
   * Get the location of the origin of the grid.
   *
298
299
300
301
   * Example of use:
   *
   * C++
   *
302
   * @dontinclude ExampleXdmfRegularGrid.cpp
303
304
305
306
307
308
   * @skipline //#initvalue
   * @until //#initvalue
   * @skipline //#initialization2
   * @until //#initialization2
   * @skipline //#getOriginconst
   * @until //#getOriginconst
309
310
311
   *
   * Python: Does not support a constant version of this function
   *
312
313
   * @return    XdmfArray containing the location of the origin of the
   *            grid (const version).
314
   */
315
  shared_ptr<const XdmfArray> getOrigin() const;
316
317
318
319

  /**
   * Set the size of the points composing the grid.
   *
320
321
322
323
   * Example of use:
   *
   * C++
   *
324
   * @dontinclude ExampleXdmfRegularGrid.cpp
325
326
327
328
   * @skipline //#initializationvector
   * @until //#initializationvector
   * @skipline //#setBrickSize
   * @until //#setBrickSize
329
330
331
   *
   * Python
   *
332
   * @dontinclude XdmfExampleRegularGrid.py
333
334
335
336
   * @skipline #//initializationvector
   * @until #//initializationvector
   * @skipline #//setBrickSize
   * @until #//setBrickSize
337
   *
338
339
340
   * @param     brickSize       The sizes of the points composing the mesh. This
   *                            should have the same number of terms as the
   *                            dimensionality of the mesh.
341
   */
342
  void setBrickSize(const shared_ptr<XdmfArray> brickSize);
343
344

  /**
345
346
   * Set the dimensions of the grid, the number of points in each
   * direction.
347
   *
348
349
350
351
   * Example of use:
   *
   * C++
   *
352
   * @dontinclude ExampleXdmfRegularGrid.cpp
353
354
355
356
   * @skipline //#initializationvector
   * @until //#initializationvector
   * @skipline //#setDimensions
   * @until //#setDimensions
357
358
359
   *
   * Python
   *
360
   * @dontinclude XdmfExampleRegularGrid.py
361
362
363
364
   * @skipline #//initializationvector
   * @until #//initializationvector
   * @skipline #//setDimensions
   * @until #//setDimensions
365
   *
366
   * @param     dimensions      The dimension of the grid.
367
   */
368
  void setDimensions(const shared_ptr<XdmfArray> dimensions);
369
370
371
372

  /**
   * Set the origin of the grid.
   *
373
374
375
376
   * Example of use:
   *
   * C++
   *
377
   * @dontinclude ExampleXdmfRegularGrid.cpp
378
379
380
381
   * @skipline //#initializationvector
   * @until //#initializationvector
   * @skipline //#setOrigin
   * @until //#setOrigin
382
383
384
   *
   * Python
   *
385
   * @dontinclude XdmfExampleRegularGrid.py
386
387
388
389
   * @skipline #//initializationvector
   * @until #//initializationvector
   * @skipline #//setOrigin
   * @until #//setOrigin
390
   *
391
392
393
   * @param     origin  Location of the origin of the grid.  This should
   *                    have the same number of terms as the dimensionality
   *                    of the mesh.
394
   */
395
  void setOrigin(const shared_ptr<XdmfArray> origin);
396

397
protected:
398

399
400
401
  XdmfRegularGrid(const shared_ptr<XdmfArray> brickSize,
                  const shared_ptr<XdmfArray> numPoints,
                  const shared_ptr<XdmfArray> origin);
402
403

  void populateItem(const std::map<std::string, std::string> & itemProperties,
404
                    const std::vector<shared_ptr<XdmfItem> > & childItems,
405
406
                    const XdmfCoreReader * const reader);

407
private:
408
409
410
411
412
413
414
415
416
417

  /**
   * PIMPL
   */
  class XdmfRegularGridImpl;

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

  XdmfRegularGridImpl * mImpl;
418
419
420

};

421
#ifdef _WIN32
422
XDMF_TEMPLATE template class XDMF_EXPORT
423
shared_ptr<XdmfArray>;
424
XDMF_TEMPLATE template class XDMF_EXPORT
425
shared_ptr<const XdmfArray>;
426
427
#endif

428
#endif /* XDMFREGULARGRID_HPP_ */