XdmfRegularGrid.cpp 23.2 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
/*****************************************************************************/
/*                                    XDMF                                   */
/*                       eXtensible Data Model and Format                    */
/*                                                                           */
/*  Id : XdmfRegularGrid.cpp                                                 */
/*                                                                           */
/*  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.                                                 */
/*                                                                           */
/*****************************************************************************/
23 24 25 26 27

#include <cmath>
#include "XdmfArray.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGeometryType.hpp"
28
#include "XdmfRegularGrid.hpp"
29 30
#include "XdmfTopology.hpp"
#include "XdmfTopologyType.hpp"
31
#include "XdmfError.hpp"
32 33 34 35

/**
 * PIMPL
 */
36
class XdmfRegularGrid::XdmfRegularGridImpl : public XdmfGridImpl {
37 38 39

public:

40 41 42 43 44
  class XdmfGeometryRegular : public XdmfGeometry
  {

  public:

45
    static shared_ptr<XdmfGeometryRegular>
46 47
    New(XdmfRegularGrid * const regularGrid)
    {
48
      shared_ptr<XdmfGeometryRegular> p(new XdmfGeometryRegular(regularGrid));
49 50 51 52 53 54
      return p;
    }

    unsigned int
    getNumberPoints() const
    {
55
      const shared_ptr<const XdmfArray> dimensions = 
56 57 58 59 60 61 62 63 64 65 66
        mRegularGrid->getDimensions();
      if(dimensions->getSize() == 0) {
        return 0;
      }
      unsigned int toReturn = 1;
      for(unsigned int i=0; i<dimensions->getSize(); ++i) {
        toReturn *= dimensions->getValue<unsigned int>(i);
      }
      return toReturn;
    }

67 68 69 70 71
    bool isInitialized() const
    {
      return true;
    }

72
    void
73
    traverse(const shared_ptr<XdmfBaseVisitor> visitor)
74
    {
75 76
      shared_ptr<XdmfArray> origin = mRegularGrid->getOrigin();
      shared_ptr<XdmfArray> brickSize = mRegularGrid->getBrickSize();
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
      origin->accept(visitor);
      brickSize->accept(visitor);
    }

  private:

    XdmfGeometryRegular(XdmfRegularGrid * const regularGrid) :
      mRegularGrid(regularGrid)
    {
      this->setType(XdmfGeometryTypeRegular::New(mRegularGrid));
    }

    XdmfRegularGrid * const mRegularGrid;
  };

  class XdmfGeometryTypeRegular : public XdmfGeometryType
  {

  public:

97
    static shared_ptr<const XdmfGeometryTypeRegular>
98 99
    New(const XdmfRegularGrid * const regularGrid)
    {
100
      shared_ptr<const XdmfGeometryTypeRegular> 
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
        p(new XdmfGeometryTypeRegular(regularGrid));
      return p;
    }

    unsigned int
    getDimensions() const
    {
      return mRegularGrid->getDimensions()->getSize();
    }

    void
    getProperties(std::map<std::string, std::string> & collectedProperties) const
    {
      const unsigned int dimensions = this->getDimensions();
      if(dimensions == 3) {
        collectedProperties["Type"] = "ORIGIN_DXDYDZ";
      }
      else if(dimensions == 2) {
        collectedProperties["Type"] = "ORIGIN_DXDY";
      }
      else {
122 123
        collectedProperties["Type"] = "ORIGIN_DISPLACEMENT";
//        XdmfError::message(XdmfError::FATAL, "Dimensions not 2 or 3 in XdmfGeometryTypeRegular::getProperties");
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
      }
    }

  private:

    XdmfGeometryTypeRegular(const XdmfRegularGrid * const regularGrid) :
      XdmfGeometryType("", 0),
      mRegularGrid(regularGrid)
    {
    }

    const XdmfRegularGrid * const mRegularGrid;

  };

  class XdmfTopologyRegular : public XdmfTopology
  {

  public:

144
    static shared_ptr<XdmfTopologyRegular>
145 146
    New(const XdmfRegularGrid * const regularGrid)
    {
147
      shared_ptr<XdmfTopologyRegular> p(new XdmfTopologyRegular(regularGrid));
148 149 150
      return p;
    }

151 152 153 154 155
    bool isInitialized() const
    {
      return true;
    }

156 157 158
    unsigned int
    getNumberElements() const
    {
159
      const shared_ptr<const XdmfArray> dimensions = 
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
        mRegularGrid->getDimensions();
      if(dimensions->getSize() == 0) {
        return 0;
      }
      unsigned int toReturn = 1;
      for(unsigned int i=0; i<dimensions->getSize(); ++i) {
        toReturn *= (dimensions->getValue<unsigned int>(i) - 1);
      }
      return toReturn;
    }

  private:

    XdmfTopologyRegular(const XdmfRegularGrid * const regularGrid) :
      mRegularGrid(regularGrid)
    {
      this->setType(XdmfTopologyTypeRegular::New(regularGrid));
    }

    const XdmfRegularGrid * const mRegularGrid;
  };

  class XdmfTopologyTypeRegular : public XdmfTopologyType
  {

  public:

187
    static shared_ptr<const XdmfTopologyTypeRegular>
188 189
    New(const XdmfRegularGrid * const regularGrid)
    {
190
      shared_ptr<const XdmfTopologyTypeRegular>
191 192 193 194
        p(new XdmfTopologyTypeRegular(regularGrid));
      return p;
    }

195 196 197
    unsigned int
    getEdgesPerElement() const
    {
198
      return calculateHypercubeNumElements(mRegularGrid->getDimensions()->getSize(), 1);
199 200 201 202 203
    }

    unsigned int
    getFacesPerElement() const
    {
204
      return calculateHypercubeNumElements(mRegularGrid->getDimensions()->getSize(), 2);
205 206
    }

207 208 209
    unsigned int
    getNodesPerElement() const
    {
210
      return calculateHypercubeNumElements(mRegularGrid->getDimensions()->getSize(), 0);
211 212 213 214 215
    }

    void
    getProperties(std::map<std::string, std::string> & collectedProperties) const
    {
216
      shared_ptr<const XdmfArray> dimensions = mRegularGrid->getDimensions();
217 218 219 220 221 222 223
      if(dimensions->getSize() == 3){
        collectedProperties["Type"] = "3DCoRectMesh";
      }
      else if(dimensions->getSize() == 2) {
        collectedProperties["Type"] = "2DCoRectMesh";
      }
      else {
224 225 226 227 228
        // If not 2 or 3 just mark it as a mesh of unknown dims
        collectedProperties["Type"] = "CoRectMesh";
//        XdmfError::message(XdmfError::FATAL, 
//                           "Dimensions not 2 or 3 in "
//                           "XdmfTopologyTypeRegular::getProperties");
229 230 231 232 233 234 235
      }
      collectedProperties["Dimensions"] = dimensions->getValuesString();
    }

  private:

    XdmfTopologyTypeRegular(const XdmfRegularGrid * const regularGrid) :
236
      XdmfTopologyType(0, 0, std::vector<shared_ptr<const XdmfTopologyType> >(), 0, "foo", XdmfTopologyType::Structured, 0x1102),
237 238 239 240 241 242 243 244
      mRegularGrid(regularGrid)
    {
    }

    const XdmfRegularGrid * const mRegularGrid;

  };

245 246 247
  XdmfRegularGridImpl(const shared_ptr<XdmfArray> brickSize,
                      const shared_ptr<XdmfArray> numPoints,
                      const shared_ptr<XdmfArray> origin) :
248 249 250 251
    mBrickSize(brickSize),
    mDimensions(numPoints),
    mOrigin(origin)
  {
252 253 254 255 256 257
    mGridType = "Regular";
  }

  XdmfGridImpl * duplicate()
  {
    return new XdmfRegularGridImpl(mBrickSize, mDimensions, mOrigin);
258 259
  }

260 261 262
  shared_ptr<XdmfArray> mBrickSize;
  shared_ptr<XdmfArray> mDimensions;
  shared_ptr<XdmfArray> mOrigin;
263 264
};

265
shared_ptr<XdmfRegularGrid>
266 267 268 269 270 271
XdmfRegularGrid::New(const double xBrickSize,
                     const double yBrickSize,
                     const unsigned int xNumPoints,
                     const unsigned int yNumPoints,
                     const double xOrigin,
                     const double yOrigin)
272
{
273
  shared_ptr<XdmfArray> brickSize = XdmfArray::New();
274
  brickSize->initialize<double>(2);
275 276
  brickSize->insert(0, xBrickSize);
  brickSize->insert(1, yBrickSize);
277
  shared_ptr<XdmfArray> numPoints = XdmfArray::New();
278
  numPoints->initialize<unsigned int>(2);
279 280
  numPoints->insert(0, xNumPoints);
  numPoints->insert(1, yNumPoints);
281
  shared_ptr<XdmfArray> origin = XdmfArray::New();
282
  origin->initialize<double>(2);
283 284
  origin->insert(0, xOrigin);
  origin->insert(1, yOrigin);
285 286 287
  shared_ptr<XdmfRegularGrid> p(new XdmfRegularGrid(brickSize,
                                                    numPoints,
                                                    origin));
288
  return p;
289 290
}

291
shared_ptr<XdmfRegularGrid>
292 293 294 295 296 297 298 299 300
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)
301
{
302
  shared_ptr<XdmfArray> brickSize = XdmfArray::New();
303
  brickSize->initialize<double>(3);
304 305 306
  brickSize->insert(0, xBrickSize);
  brickSize->insert(1, yBrickSize);
  brickSize->insert(2, zBrickSize);
307
  shared_ptr<XdmfArray> numPoints = XdmfArray::New();
308
  numPoints->initialize<unsigned int>(3);
309 310 311
  numPoints->insert(0, xNumPoints);
  numPoints->insert(1, yNumPoints);
  numPoints->insert(2, zNumPoints);
312
  shared_ptr<XdmfArray> origin = XdmfArray::New();
313
  origin->initialize<double>(3);
314 315 316
  origin->insert(0, xOrigin);
  origin->insert(1, yOrigin);
  origin->insert(2, zOrigin);
317 318 319
  shared_ptr<XdmfRegularGrid> p(new XdmfRegularGrid(brickSize,
                                                    numPoints,
                                                    origin));
320
  return p;
321 322
}

323 324 325 326
shared_ptr<XdmfRegularGrid>
XdmfRegularGrid::New(const shared_ptr<XdmfArray> brickSize,
                     const shared_ptr<XdmfArray> numPoints,
                     const shared_ptr<XdmfArray> origin)
327
{
328 329 330
  shared_ptr<XdmfRegularGrid> p(new XdmfRegularGrid(brickSize,
                                                    numPoints,
                                                    origin));
331
  return p;
332 333
}

334 335 336
XdmfRegularGrid::XdmfRegularGrid(const shared_ptr<XdmfArray> brickSize,
                                 const shared_ptr<XdmfArray> numPoints,
                                 const shared_ptr<XdmfArray> origin) :
337
  XdmfGrid(XdmfRegularGridImpl::XdmfGeometryRegular::New(this),
338
           XdmfRegularGridImpl::XdmfTopologyRegular::New(this))
339
{
340 341 342 343 344 345 346 347
  mImpl = new XdmfRegularGridImpl(brickSize, numPoints, origin);
}

XdmfRegularGrid::XdmfRegularGrid(XdmfRegularGrid & refGrid) :
  XdmfGrid(refGrid)
{
  mGeometry = XdmfRegularGridImpl::XdmfGeometryRegular::New(this);
  mTopology = XdmfRegularGridImpl::XdmfTopologyRegular::New(this);  
348 349
}

350
XdmfRegularGrid::~XdmfRegularGrid()
351
{
352 353 354 355
  if (mImpl) {
    delete mImpl;
  }
  mImpl = NULL;
356 357
}

358
const std::string XdmfRegularGrid::ItemTag = "Grid";
359

360 361 362 363 364 365 366 367 368 369 370 371 372
void
XdmfRegularGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
{
  XdmfGrid::copyGrid(sourceGrid); 
  if (shared_ptr<XdmfRegularGrid> classedGrid = shared_dynamic_cast<XdmfRegularGrid>(sourceGrid))
  { 
    // Copy stucture from read grid to this grid
    this->setOrigin(classedGrid->getOrigin());
    this->setDimensions(classedGrid->getDimensions());
    this->setBrickSize(classedGrid->getBrickSize());
  }
}

373
shared_ptr<XdmfArray>
374
XdmfRegularGrid::getBrickSize()
375
{
376
  return boost::const_pointer_cast<XdmfArray>
377
    (static_cast<const XdmfRegularGrid &>(*this).getBrickSize());
378 379
}

380
shared_ptr<const XdmfArray>
381
XdmfRegularGrid::getBrickSize() const
382
{
383
  return ((XdmfRegularGridImpl *)mImpl)->mBrickSize;
384 385
}

386
shared_ptr<XdmfArray>
387
XdmfRegularGrid::getDimensions()
388
{
389
  return boost::const_pointer_cast<XdmfArray>
390
    (static_cast<const XdmfRegularGrid &>(*this).getDimensions());
391 392
}

393
shared_ptr<const XdmfArray>
394
XdmfRegularGrid::getDimensions() const
395
{
396
  return ((XdmfRegularGridImpl *)mImpl)->mDimensions;
397 398
}

399
shared_ptr<XdmfArray>
400
XdmfRegularGrid::getOrigin()
401
{
402
  return boost::const_pointer_cast<XdmfArray>
403
    (static_cast<const XdmfRegularGrid &>(*this).getOrigin());
404 405
}

406
shared_ptr<const XdmfArray>
407
XdmfRegularGrid::getOrigin() const
408
{
409
  return ((XdmfRegularGridImpl *)mImpl)->mOrigin;
410 411
}

412 413
void
XdmfRegularGrid::populateItem(const std::map<std::string, std::string> & itemProperties,
414
                              const std::vector<shared_ptr<XdmfItem> > & childItems,
415
                              const XdmfCoreReader * const reader)
416
{
417 418
  XdmfGrid::populateItem(itemProperties, childItems, reader);

419
  for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
420 421 422
        childItems.begin();
      iter != childItems.end();
      ++iter) {
423 424
    if(shared_ptr<XdmfRegularGrid> regularGrid =
       shared_dynamic_cast<XdmfRegularGrid>(*iter)) {
425
      if(regularGrid->getBrickSize()) {
426
        ((XdmfRegularGridImpl *)mImpl)->mBrickSize = regularGrid->getBrickSize();
427 428 429
      }

      if(regularGrid->getDimensions()) {
430
        ((XdmfRegularGridImpl *)mImpl)->mDimensions = regularGrid->getDimensions();
431 432 433
      }

      if(regularGrid->getOrigin()) {
434
        ((XdmfRegularGridImpl *)mImpl)->mOrigin = regularGrid->getOrigin();
435 436 437
      }
    }
  }
438 439
}

440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
void
XdmfRegularGrid::read()
{
  if (mGridController)
  {
    if (shared_ptr<XdmfRegularGrid> grid = shared_dynamic_cast<XdmfRegularGrid>(mGridController->read()))
    { 
      // Copy stucture from read grid to this grid
      copyGrid(grid);
    }
    else if (shared_ptr<XdmfGrid> grid = shared_dynamic_cast<XdmfGrid>(mGridController->read()))
    {
      XdmfError::message(XdmfError::FATAL, "Error: Grid Type Mismatch");
    }
    else
    {
      XdmfError::message(XdmfError::FATAL, "Error: Invalid Grid Reference");
    }
  }
}

void
XdmfRegularGrid::release()
{
  XdmfGrid::release();
  this->setOrigin(shared_ptr<XdmfArray>());
  this->setDimensions(shared_ptr<XdmfArray>());
  this->setBrickSize(shared_ptr<XdmfArray>());
}

470
void
471
XdmfRegularGrid::setBrickSize(const shared_ptr<XdmfArray> brickSize)
472
{
473
  ((XdmfRegularGridImpl *)mImpl)->mBrickSize = brickSize;
474
  this->setIsChanged(true);
475 476
}

477
void
478
XdmfRegularGrid::setDimensions(const shared_ptr<XdmfArray> dimensions)
479
{
480
  ((XdmfRegularGridImpl *)mImpl)->mDimensions = dimensions;
481
  this->setIsChanged(true);
482 483
}

484
void
485
XdmfRegularGrid::setOrigin(const shared_ptr<XdmfArray> origin)
486
{
487
  ((XdmfRegularGridImpl *)mImpl)->mOrigin = origin;
488 489 490 491 492 493 494 495 496 497 498 499
  this->setIsChanged(true);
}

// C Wrappers

XDMFREGULARGRID * XdmfRegularGridNew2D(double xBrickSize,
                                       double yBrickSize,
                                       unsigned int xNumPoints,
                                       unsigned int yNumPoints,
                                       double xOrigin,
                                       double yOrigin)
{
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
  try
  {
    shared_ptr<XdmfRegularGrid> generatedGrid = XdmfRegularGrid::New(xBrickSize,
                                                                     yBrickSize,
                                                                     xNumPoints,
                                                                     yNumPoints,
                                                                     xOrigin,
                                                                     yOrigin);
    return (XDMFREGULARGRID *)((void *)((XdmfItem *)(new XdmfRegularGrid(*generatedGrid.get()))));
  }
  catch (...)
  {
    shared_ptr<XdmfRegularGrid> generatedGrid = XdmfRegularGrid::New(xBrickSize,
                                                                     yBrickSize,
                                                                     xNumPoints,
                                                                     yNumPoints,
                                                                     xOrigin,
                                                                     yOrigin);
    return (XDMFREGULARGRID *)((void *)((XdmfItem *)(new XdmfRegularGrid(*generatedGrid.get()))));
  }
520 521 522 523 524 525 526 527 528 529 530 531
}

XDMFREGULARGRID * XdmfRegularGridNew3D(double xBrickSize,
                                       double yBrickSize,
                                       double zBrickSize,
                                       unsigned int xNumPoints,
                                       unsigned int yNumPoints,
                                       unsigned int zNumPoints,
                                       double xOrigin,
                                       double yOrigin,
                                       double zOrigin)
{
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557
  try
  {
    shared_ptr<XdmfRegularGrid> generatedGrid = XdmfRegularGrid::New(xBrickSize,
                                                                     yBrickSize,
                                                                     zBrickSize,
                                                                     xNumPoints,
                                                                     yNumPoints,
                                                                     zNumPoints,
                                                                     xOrigin,
                                                                     yOrigin,
                                                                     zOrigin);
    return (XDMFREGULARGRID *)((void *)((XdmfItem *)(new XdmfRegularGrid(*generatedGrid.get()))));
  }
  catch (...)
  {
    shared_ptr<XdmfRegularGrid> generatedGrid = XdmfRegularGrid::New(xBrickSize,
                                                                     yBrickSize,
                                                                     zBrickSize,
                                                                     xNumPoints,
                                                                     yNumPoints,
                                                                     zNumPoints,
                                                                     xOrigin,
                                                                     yOrigin,
                                                                     zOrigin);
    return (XDMFREGULARGRID *)((void *)((XdmfItem *)(new XdmfRegularGrid(*generatedGrid.get()))));
  }
558 559 560 561 562 563 564
}

XDMFREGULARGRID * XdmfRegularGridNew(XDMFARRAY * brickSize,
                                     XDMFARRAY * numPoints,
                                     XDMFARRAY * origin,
                                     int passControl)
{
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
  try
  {
    if (passControl) {
      shared_ptr<XdmfRegularGrid> generatedGrid = XdmfRegularGrid::New(shared_ptr<XdmfArray>((XdmfArray *)brickSize),
                                                                       shared_ptr<XdmfArray>((XdmfArray *)numPoints),
                                                                       shared_ptr<XdmfArray>((XdmfArray *)origin));
      return (XDMFREGULARGRID *)((void *)((XdmfItem *)(new XdmfRegularGrid(*generatedGrid.get()))));
    }
    else {
      shared_ptr<XdmfRegularGrid> generatedGrid = XdmfRegularGrid::New(shared_ptr<XdmfArray>((XdmfArray *)brickSize, XdmfNullDeleter()),
                                                                       shared_ptr<XdmfArray>((XdmfArray *)numPoints, XdmfNullDeleter()),
                                                                       shared_ptr<XdmfArray>((XdmfArray *)origin, XdmfNullDeleter()));
      return (XDMFREGULARGRID *)((void *)((XdmfItem *)(new XdmfRegularGrid(*generatedGrid.get()))));
    }
  }
  catch (...)
  {
    if (passControl) {
      shared_ptr<XdmfRegularGrid> generatedGrid = XdmfRegularGrid::New(shared_ptr<XdmfArray>((XdmfArray *)brickSize),
                                                                       shared_ptr<XdmfArray>((XdmfArray *)numPoints),
                                                                       shared_ptr<XdmfArray>((XdmfArray *)origin));
      return (XDMFREGULARGRID *)((void *)((XdmfItem *)(new XdmfRegularGrid(*generatedGrid.get()))));
    }
    else {
      shared_ptr<XdmfRegularGrid> generatedGrid = XdmfRegularGrid::New(shared_ptr<XdmfArray>((XdmfArray *)brickSize, XdmfNullDeleter()),
                                                                       shared_ptr<XdmfArray>((XdmfArray *)numPoints, XdmfNullDeleter()),
                                                                       shared_ptr<XdmfArray>((XdmfArray *)origin, XdmfNullDeleter()));
      return (XDMFREGULARGRID *)((void *)((XdmfItem *)(new XdmfRegularGrid(*generatedGrid.get()))));
    }
  }
595 596 597 598 599
}

XDMFARRAY * XdmfRegularGridGetBrickSize(XDMFREGULARGRID * grid, int * status)
{
  XDMF_ERROR_WRAP_START(status)
600 601 602 603
  XdmfItem * classedPointer = (XdmfItem *)grid;
  XdmfRegularGrid * gridPointer = dynamic_cast<XdmfRegularGrid *>(classedPointer);
  shared_ptr<XdmfArray> generatedBrick = gridPointer->getBrickSize();
  return (XDMFARRAY *)((void *)(generatedBrick.get()));
604 605 606 607 608 609 610
  XDMF_ERROR_WRAP_END(status)
  return NULL;
}

XDMFARRAY * XdmfRegularGridGetDimensions(XDMFREGULARGRID * grid, int * status)
{
  XDMF_ERROR_WRAP_START(status)
611 612 613 614
  XdmfItem * classedPointer = (XdmfItem *)grid;
  XdmfRegularGrid * gridPointer = dynamic_cast<XdmfRegularGrid *>(classedPointer);
  shared_ptr<XdmfArray> generatedDimensions = gridPointer->getDimensions();
  return (XDMFARRAY *)((void *)(generatedDimensions.get()));
615 616 617 618 619 620 621
  XDMF_ERROR_WRAP_END(status)
  return NULL;
}

XDMFARRAY * XdmfRegularGridGetOrigin(XDMFREGULARGRID * grid, int * status)
{
  XDMF_ERROR_WRAP_START(status)
622 623 624 625
  XdmfItem * classedPointer = (XdmfItem *)grid;
  XdmfRegularGrid * gridPointer = dynamic_cast<XdmfRegularGrid *>(classedPointer);
  shared_ptr<XdmfArray> generatedOrigin = gridPointer->getOrigin();
  return (XDMFARRAY *)((void *)(generatedOrigin.get()));
626 627 628 629 630 631 632
  XDMF_ERROR_WRAP_END(status)
  return NULL;
}

void XdmfRegularGridSetBrickSize(XDMFREGULARGRID * grid, XDMFARRAY * brickSize, int passControl, int * status)
{
  XDMF_ERROR_WRAP_START(status)
633 634 635 636 637 638 639 640
  XdmfItem * classedPointer = (XdmfItem *)grid;
  XdmfRegularGrid * gridPointer = dynamic_cast<XdmfRegularGrid *>(classedPointer);
  if (passControl) {
    gridPointer->setBrickSize(shared_ptr<XdmfArray>((XdmfArray *)brickSize));
  }
  else {
    gridPointer->setBrickSize(shared_ptr<XdmfArray>((XdmfArray *)brickSize, XdmfNullDeleter()));
  }
641
  XDMF_ERROR_WRAP_END(status)
642
}
643 644 645 646

void XdmfRegularGridSetDimensions(XDMFREGULARGRID * grid, XDMFARRAY * dimensions, int passControl, int * status)
{
  XDMF_ERROR_WRAP_START(status)
647 648 649 650 651 652 653 654
  XdmfItem * classedPointer = (XdmfItem *)grid;
  XdmfRegularGrid * gridPointer = dynamic_cast<XdmfRegularGrid *>(classedPointer);
  if (passControl) {
    gridPointer->setDimensions(shared_ptr<XdmfArray>((XdmfArray *)dimensions));
  }
  else {
    gridPointer->setDimensions(shared_ptr<XdmfArray>((XdmfArray *)dimensions, XdmfNullDeleter()));
  }
655 656 657 658 659 660
  XDMF_ERROR_WRAP_END(status)
}

void XdmfRegularGridSetOrigin(XDMFREGULARGRID * grid, XDMFARRAY * origin, int passControl, int * status)
{
  XDMF_ERROR_WRAP_START(status)
661 662 663 664 665 666 667 668
  XdmfItem * classedPointer = (XdmfItem *)grid;
  XdmfRegularGrid * gridPointer = dynamic_cast<XdmfRegularGrid *>(classedPointer);
  if (passControl) {
    gridPointer->setOrigin(shared_ptr<XdmfArray>((XdmfArray *)origin));
  }
  else {
    gridPointer->setOrigin(shared_ptr<XdmfArray>((XdmfArray *)origin, XdmfNullDeleter()));
  }
669 670 671 672 673
  XDMF_ERROR_WRAP_END(status)
}

XDMF_ITEM_C_CHILD_WRAPPER(XdmfRegularGrid, XDMFREGULARGRID)
XDMF_GRID_C_CHILD_WRAPPER(XdmfRegularGrid, XDMFREGULARGRID)