XdmfMap.cpp 20.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 : XdmfMap.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.                                                 */
/*                                                                           */
/*****************************************************************************/

24
#include <utility>
25
#include <string.h>
26
#include "XdmfAttribute.hpp"
27
#include "XdmfError.hpp"
28 29
#include "XdmfGridCollection.hpp"
#include "XdmfGridCollectionType.hpp"
30
#include "XdmfHeavyDataController.hpp"
31
#include "XdmfMap.hpp"
32
#include "XdmfWriter.hpp"
33

34
shared_ptr<XdmfMap>
35
XdmfMap::New()
36
{
37
  shared_ptr<XdmfMap> p(new XdmfMap());
38
  return p;
39 40
}

41 42
std::vector<shared_ptr<XdmfMap> >
XdmfMap::New(const std::vector<shared_ptr<XdmfAttribute> > & globalNodeIds)
43
{
44
  // globalNodeId | taskId | localNodeId at taskId
45
  std::map<node_id, std::map<task_id, node_id> > globalNodeIdMap;
46

47
  // fill globalNodeIdMap using globalNodeIds
48
  std::vector<bool> releaseGlobalNodeIds(globalNodeIds.size(), false);
49
  for(unsigned int i=0; i<globalNodeIds.size(); ++i) {
50
    const shared_ptr<XdmfAttribute> currGlobalNodeIds = globalNodeIds[i];
51 52 53 54
    if(!currGlobalNodeIds->isInitialized()) {
      currGlobalNodeIds->read();
      releaseGlobalNodeIds[i] = true;
    }
55
    for(unsigned int j=0; j<currGlobalNodeIds->getSize(); ++j) {
56
      const node_id currGlobalNodeId = currGlobalNodeIds->getValue<node_id>(j);
57 58 59
      globalNodeIdMap[currGlobalNodeId][i] = j;
    }
  }
60

61
  std::vector<shared_ptr<XdmfMap> > returnValue;
62 63 64
  returnValue.resize(globalNodeIds.size());

  // fill maps for each partition
65
  for(unsigned int i=0; i<globalNodeIds.size(); ++i)  {
66
    shared_ptr<XdmfMap> map = XdmfMap::New();
67
    returnValue[i] = map;
68 69
    const shared_ptr<XdmfAttribute> currGlobalNodeIds = globalNodeIds[i];

70
    for(unsigned int j=0; j<currGlobalNodeIds->getSize(); ++j) {
71 72 73 74
      const node_id currGlobalNodeId = currGlobalNodeIds->getValue<node_id>(j);
      const std::map<task_id, node_id> & currMap = 
        globalNodeIdMap[currGlobalNodeId];
      if(currMap.size() > 1) {
75
        for(std::map<task_id, node_id>::const_iterator iter = currMap.begin();
76
            iter != currMap.end();
77
            ++iter) {
78
          if(iter->first != (int)i) {
79
            map->insert(iter->first, j, iter->second);
80 81 82 83
          }
        }
      }
    }
84 85 86
    if(releaseGlobalNodeIds[i]) {
      currGlobalNodeIds->release();
    }
87
  }
88

89
  return returnValue;
90 91
}

92 93
XdmfMap::XdmfMap() :
  mName("")
94 95 96 97 98 99 100 101 102
{
}

XdmfMap::~XdmfMap()
{
}

const std::string XdmfMap::ItemTag = "Map";

103 104
std::map<std::string, std::string>
XdmfMap::getItemProperties() const
105
{
106
  std::map<std::string, std::string> mapProperties;
107
  mapProperties.insert(std::make_pair("Name", mName));
108
  return mapProperties;
109 110
}

111 112
std::string
XdmfMap::getItemTag() const
113
{
114
  return ItemTag;
115 116
}

117
std::map<XdmfMap::task_id, XdmfMap::node_id_map>
118
XdmfMap::getMap() const
119
{
120 121 122
  return mMap;
}

123 124 125 126 127 128
std::string
XdmfMap::getName() const
{
  return mName;
}

129 130 131
XdmfMap::node_id_map
XdmfMap::getRemoteNodeIds(const task_id remoteTaskId)
{
132
  std::map<task_id, node_id_map>::const_iterator iter =
133
    mMap.find(remoteTaskId);
134 135 136 137
  if(iter != mMap.end()) {
    return iter->second;
  }
  // No entry, return empty map.
138
  return node_id_map();
139 140
}

141
void
142 143 144
XdmfMap::insert(const task_id remoteTaskId,
                const node_id localNodeId,
                const node_id remoteLocalNodeId)
145
{
146
  mMap[remoteTaskId][localNodeId].insert(remoteLocalNodeId);
147
  this->setIsChanged(true);
148 149
}

150 151
bool XdmfMap::isInitialized() const
{
152
  return mMap.size() > 0;
153 154
}

155 156
void
XdmfMap::populateItem(const std::map<std::string, std::string> & itemProperties,
157
                      const std::vector<shared_ptr<XdmfItem> > & childItems,
158
                      const XdmfCoreReader * const reader)
159
{
160
  XdmfItem::populateItem(itemProperties, childItems, reader);
161 162 163 164 165 166 167 168
  std::map<std::string, std::string>::const_iterator name =
    itemProperties.find("Name");
  if(name != itemProperties.end()) {
    mName = name->second;
  }
  else {
    mName = "";
  }
169
  std::vector<shared_ptr<XdmfArray> > arrayVector;
170
  arrayVector.reserve(3);
171
  for(std::vector<shared_ptr<XdmfItem> >::const_iterator iter =
172 173 174
        childItems.begin();
      iter != childItems.end();
      ++iter) {
175 176 177
    if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
      arrayVector.push_back(array);
    }
178
  }
179

180 181
  if(arrayVector.size() != 0) {
    if(arrayVector.size() != 3) {
182 183 184
      XdmfError::message(XdmfError::FATAL,
                         "Expected 3 arrays attached to "
                         "XdmfMap::populateItem");
185 186 187
    }
    if(!(arrayVector[0]->getSize() == arrayVector[1]->getSize() &&
         arrayVector[0]->getSize() == arrayVector[2]->getSize())) {
188 189 190
      XdmfError::message(XdmfError::FATAL,
                         "Arrays must be of equal size in "
                         "XdmfMap:: populateItem");
191
    }
192

193 194 195
    // check if any arrays have values in memory - if so, they need to be
    // read into map
    bool needToRead = false;
196
    for(std::vector<shared_ptr<XdmfArray> >::const_iterator iter =
197 198 199
          arrayVector.begin();
        iter != arrayVector.end();
        ++iter) {
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
      if((*iter)->isInitialized()) {
        needToRead = true;
        break;
      }
    }

    if(needToRead) {
      for(std::vector<shared_ptr<XdmfArray> >::const_iterator iter =
            arrayVector.begin();
          iter != arrayVector.end();
          ++iter) {
        if(!(*iter)->isInitialized()) {
          (*iter)->read();
        }
      }
      for(unsigned int i=0; i<arrayVector[0]->getSize(); ++i) {
        this->insert(arrayVector[0]->getValue<task_id>(i),
                     arrayVector[1]->getValue<node_id>(i),
                     arrayVector[2]->getValue<node_id>(i));
219
      }
220
    }
221
    else {
222 223

      mRemoteTaskIdsControllers.clear();
224
      for (unsigned int i = 0; i <  arrayVector[0]->getNumberHeavyDataControllers(); ++i)
225 226 227 228
      {
        mRemoteTaskIdsControllers.push_back(arrayVector[0]->getHeavyDataController(i));
      }
      mLocalNodeIdsControllers.clear();
229
      for (unsigned int i = 0; i <  arrayVector[1]->getNumberHeavyDataControllers(); ++i)
230 231 232 233
      {
        mLocalNodeIdsControllers.push_back(arrayVector[1]->getHeavyDataController(i));
      }
      mRemoteLocalNodeIdsControllers.clear();
234
      for (unsigned int i = 0; i <  arrayVector[2]->getNumberHeavyDataControllers(); ++i)
235 236 237
      {
        mRemoteLocalNodeIdsControllers.push_back(arrayVector[2]->getHeavyDataController(i));
      }
238 239
    }
  }
240 241
}

242 243
void
XdmfMap::read()
244
{
245 246 247 248
  if(mLocalNodeIdsControllers.size() > 0 &&
     mRemoteTaskIdsControllers.size() > 0 &&
     mRemoteLocalNodeIdsControllers.size() > 0) {

249
    unsigned int localNodeCount = 0;
250
    for (unsigned int i = 0; i< mLocalNodeIdsControllers.size(); ++i)
251 252 253
    {
      localNodeCount += mLocalNodeIdsControllers[i]->getSize();
    }
254
    unsigned int remoteTaskCount = 0;
255
    for (unsigned int i = 0; i< mRemoteTaskIdsControllers.size(); ++i)
256 257 258
    {
      remoteTaskCount += mRemoteTaskIdsControllers[i]->getSize();
    }
259
    unsigned int remoteNodeCount = 0;
260
    for (unsigned int i = 0; i< mRemoteLocalNodeIdsControllers.size(); ++i)
261 262 263 264 265 266 267 268
    {
      remoteNodeCount += mRemoteLocalNodeIdsControllers[i]->getSize();
    }

    if(!(localNodeCount ==
         remoteTaskCount &&
         localNodeCount ==
         remoteNodeCount)){
269 270
      XdmfError::message(XdmfError::FATAL,
                         "Arrays must be of equal size in XdmfMap::read");
271 272
    }

273 274 275
    shared_ptr<XdmfArray> remoteTaskIds = XdmfArray::New();
    shared_ptr<XdmfArray> localNodeIds = XdmfArray::New();
    shared_ptr<XdmfArray> remoteLocalNodeIds = XdmfArray::New();
276

277
    mRemoteTaskIdsControllers[0]->read(remoteTaskIds.get());
278
    for (unsigned int i = 1; i < mRemoteTaskIdsControllers.size(); ++i)
279 280 281 282 283 284
    {
      shared_ptr<XdmfArray> tempArray = XdmfArray::New();
      mRemoteTaskIdsControllers[i]->read(tempArray.get());
      remoteTaskIds->insert(remoteTaskIds->getSize(), tempArray, 0, tempArray->getSize());
    }
    mLocalNodeIdsControllers[0]->read(localNodeIds.get());
285
    for (unsigned int i = 1; i < mLocalNodeIdsControllers.size(); ++i)
286 287 288 289 290 291
    {
      shared_ptr<XdmfArray> tempArray = XdmfArray::New();
      mLocalNodeIdsControllers[i]->read(tempArray.get());
      localNodeIds->insert(localNodeIds->getSize(), tempArray, 0, tempArray->getSize());
    }
    mRemoteLocalNodeIdsControllers[0]->read(remoteLocalNodeIds.get());
292
    for (unsigned int i = 1; i < mRemoteLocalNodeIdsControllers.size(); ++i)
293 294 295 296 297
    {
      shared_ptr<XdmfArray> tempArray = XdmfArray::New();
      mRemoteLocalNodeIdsControllers[i]->read(tempArray.get());
      remoteLocalNodeIds->insert(remoteLocalNodeIds->getSize(), tempArray, 0, tempArray->getSize());
    }
298 299 300 301

    for(unsigned int i=0; i<remoteTaskIds->getSize(); ++i) {
      const unsigned int remoteTaskId = remoteTaskIds->getValue<task_id>(i);
      const unsigned int localNodeId = localNodeIds->getValue<node_id>(i);
302
      const unsigned int remoteLocalNodeId =
303 304
        remoteLocalNodeIds->getValue<node_id>(i);
      mMap[remoteTaskId][localNodeId].insert(remoteLocalNodeId);
305 306
    }
  }
307 308
}

309

310 311
void
XdmfMap::release()
312
{
313
  mMap.clear();
314 315
}

316
void
317 318 319
XdmfMap::setHeavyDataControllers(std::vector<shared_ptr<XdmfHeavyDataController> > remoteTaskIdsControllers,
                                 std::vector<shared_ptr<XdmfHeavyDataController> > localNodeIdsControllers,
                                 std::vector<shared_ptr<XdmfHeavyDataController> > remoteLocalNodeIdsControllers)
320
{
321
  unsigned int localNodeCount = 0;
322
  for (unsigned int i = 0; i< localNodeIdsControllers.size(); ++i)
323 324 325
  {
    localNodeCount += localNodeIdsControllers[i]->getSize();
  }
326
  unsigned int remoteTaskCount = 0;
327
  for (unsigned int i = 0; i< remoteTaskIdsControllers.size(); ++i)
328 329 330
  {
    remoteTaskCount += remoteTaskIdsControllers[i]->getSize();
  }
331
  unsigned int remoteNodeCount = 0;
332
  for (unsigned int i = 0; i< remoteLocalNodeIdsControllers.size(); ++i)
333 334 335 336 337 338
  {
    remoteNodeCount += remoteLocalNodeIdsControllers[i]->getSize();
  }
  if(!(localNodeCount ==
       remoteTaskCount &&
       localNodeCount ==
339
       remoteNodeCount)) {
340 341 342
    XdmfError::message(XdmfError::FATAL,
                       "Arrays must be of equal size in "
                       "XdmfMap::setHeavyDataControllers");
343
  }
344 345 346
  mRemoteTaskIdsControllers = remoteTaskIdsControllers;
  mLocalNodeIdsControllers = localNodeIdsControllers;
  mRemoteLocalNodeIdsControllers = remoteLocalNodeIdsControllers;
347
  this->setIsChanged(true);
348 349
}

350 351 352 353
void 
XdmfMap::setMap(std::map<task_id, node_id_map> map)
{
  mMap = map;
354
  this->setIsChanged(true);
355
}
356

357 358 359 360
void
XdmfMap::setName(const std::string & name)
{
  mName = name;
361
  this->setIsChanged(true);
362 363
}

364
void
365
XdmfMap::traverse(const shared_ptr<XdmfBaseVisitor> visitor)
366
{
367
  XdmfItem::traverse(visitor);
368

369 370 371
  shared_ptr<XdmfArray> remoteTaskIds = XdmfArray::New();
  shared_ptr<XdmfArray> localNodeIds = XdmfArray::New();
  shared_ptr<XdmfArray> remoteLocalNodeIds = XdmfArray::New();
372 373

  for(std::map<task_id, node_id_map>::const_iterator
374 375 376
        iter = mMap.begin();
      iter != mMap.end();
      ++iter) {
377
    for(node_id_map::const_iterator
378
          iter2 = iter->second.begin();
379 380
        iter2 != iter->second.end();
        ++iter2) {
381
      for(node_id_map::mapped_type::const_iterator iter3 =
382 383 384 385 386 387 388
            iter2->second.begin();
          iter3 != iter2->second.end();
          ++iter3) {
        remoteTaskIds->pushBack(iter->first);
        localNodeIds->pushBack(iter2->first);
        remoteLocalNodeIds->pushBack(*iter3);
      }
389 390
    }
  }
391

392
  for (unsigned int i = 0; i < mRemoteTaskIdsControllers.size(); ++i)
393 394 395
  {
    remoteTaskIds->insert(mRemoteTaskIdsControllers[i]);
  }
396
  for (unsigned int i = 0; i < mLocalNodeIdsControllers.size(); ++i)
397 398 399
  {
    localNodeIds->insert(mLocalNodeIdsControllers[i]);
  }
400
  for (unsigned int i = 0; i < mRemoteLocalNodeIdsControllers.size(); ++i)
401 402 403
  {
    remoteLocalNodeIds->insert(mRemoteLocalNodeIdsControllers[i]);
  }
404

405 406 407 408 409 410 411 412
  bool originalXPath;

  if (shared_ptr<XdmfWriter> writer =
        shared_dynamic_cast<XdmfWriter>(visitor)) {
    originalXPath = writer->getWriteXPaths();
    writer->setWriteXPaths(false);
  }

413
  remoteTaskIds->accept(visitor);
414 415
  localNodeIds->accept(visitor);
  remoteLocalNodeIds->accept(visitor);
416

417 418 419 420 421
  if (shared_ptr<XdmfWriter> writer =
        shared_dynamic_cast<XdmfWriter>(visitor)) {
    writer->setWriteXPaths(originalXPath);
  }

422 423 424 425
  mLocalNodeIdsControllers.clear();
  mRemoteTaskIdsControllers.clear();
  mRemoteLocalNodeIdsControllers.clear();

426
  for (unsigned int i = 0; i < remoteTaskIds->getNumberHeavyDataControllers(); ++i)
427 428 429
  {
    mRemoteTaskIdsControllers.push_back(remoteTaskIds->getHeavyDataController(i));
  }
430
  for (unsigned int i = 0; i < localNodeIds->getNumberHeavyDataControllers(); ++i)
431 432 433
  {
    mLocalNodeIdsControllers.push_back(localNodeIds->getHeavyDataController(i));
  }
434
  for (unsigned int i = 0; i < remoteLocalNodeIds->getNumberHeavyDataControllers(); ++i)
435 436 437
  {
    mRemoteLocalNodeIdsControllers.push_back(remoteLocalNodeIds->getHeavyDataController(i));
  }
438 439 440 441 442 443 444 445 446 447

  remoteTaskIds.reset();
  localNodeIds.reset();
  remoteLocalNodeIds.reset();
}

// C Wrappers

XDMFMAP * XdmfMapNew()
{
448 449
  shared_ptr<XdmfMap> * p = new shared_ptr<XdmfMap>(XdmfMap::New());
  return (XDMFMAP *) p;
450 451 452 453
}

XDMFMAP ** XdmfMapNewFromIdVector(int ** globalNodeIds, int * numIdsOnNode, int numIds)
{
454 455 456 457 458 459

  std::vector<shared_ptr<XdmfAttribute> > insertedAttributeVector;
  for (int i = 0; i < numIds; ++i) {
    shared_ptr<XdmfAttribute> insertedAttribute = XdmfAttribute::New();
    insertedAttribute->insert(0, globalNodeIds[i], numIdsOnNode[i], 1, 1);
    insertedAttributeVector.push_back(insertedAttribute);
460
  }
461 462 463 464 465
  std::vector<shared_ptr<XdmfMap> > generatedMaps = XdmfMap::New(insertedAttributeVector);
  unsigned int returnSize = generatedMaps.size();
  XDMFMAP ** returnArray = (XDMFMAP **)malloc(sizeof(XDMFMAP *) * (returnSize+1));
  for (unsigned int i = 0; i < returnSize; ++i) {
    returnArray[i] = (XDMFMAP *) new shared_ptr<XdmfMap>(generatedMaps[i]);
466
  }
467 468
  returnArray[returnSize] = NULL;
  return returnArray;
469 470 471 472
}

char * XdmfMapGetName(XDMFMAP * map)
{
473 474 475
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  char * returnPointer = strdup(refMap->getName().c_str());
  return returnPointer;
476 477 478 479
}

void XdmfMapInsert(XDMFMAP * map, int remoteTaskId, int localNodeId, int remoteLocalNodeId)
{
480 481
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  refMap->insert(remoteTaskId, localNodeId, remoteLocalNodeId);
482 483 484 485
}

int XdmfMapIsInitialized(XDMFMAP * map)
{
486 487
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  return refMap->isInitialized();
488 489 490 491 492
}

void XdmfMapRead(XDMFMAP * map, int * status)
{
  XDMF_ERROR_WRAP_START(status)
493 494
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  refMap->read();
495 496 497 498 499
  XDMF_ERROR_WRAP_END(status)
}

void XdmfMapRelease(XDMFMAP * map)
{
500 501
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  refMap->release();
502 503 504 505
}

int * XdmfMapRetrieveLocalNodeIds(XDMFMAP * map, int remoteTaskId)
{
506 507 508 509 510 511 512 513 514 515 516
  int * returnPointer = (int *)malloc(sizeof(int) * XdmfMapRetrieveNumberLocalNodeIds(map, remoteTaskId));
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  std::map<int, std::map<int, std::set<int> > > testMap = refMap->getMap();
  std::map<int, std::map<int, std::set<int> > >::const_iterator iter = testMap.find(remoteTaskId);
  unsigned int i = 0;
  for(std::map<int, std::set<int> >::const_iterator
	iter2 = iter->second.begin();
      iter2 != iter->second.end();
      ++iter2) {
    returnPointer[i] = iter2->first;
    ++i;
517
  }
518
  return returnPointer;
519 520 521 522
}

int XdmfMapRetrieveNumberLocalNodeIds(XDMFMAP * map, int remoteTaskId)
{
523 524
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  return refMap->getMap()[remoteTaskId].size();
525 526 527 528
}

int XdmfMapRetrieveNumberRemoteTaskIds(XDMFMAP * map)
{
529 530
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  return refMap->getMap().size();
531 532 533 534
}

int XdmfMapRetrieveNumberRemoteNodeIds(XDMFMAP * map, int remoteTaskId, int localNodeId)
{
535 536
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  return refMap->getMap()[remoteTaskId][localNodeId].size();
537 538 539 540
}

int * XdmfMapRetrieveRemoteTaskIds(XDMFMAP * map)
{
541 542 543 544 545 546 547 548 549 550
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  int * returnPointer = (int *)malloc(sizeof(int) * refMap->getMap().size());
  std::map<int, std::map<int, std::set<int> > > testMap = refMap->getMap();
  unsigned int i = 0;
  for(std::map<int, std::map<int, std::set<int> > >::const_iterator
	iter = testMap.begin();
      iter != testMap.end();
      ++iter) {
    returnPointer[i] = iter->first;
    ++i;
551
  }
552
  return returnPointer;
553 554 555 556
}

int * XdmfMapRetrieveRemoteNodeIds(XDMFMAP * map, int remoteTaskId, int localNodeId)
{
557 558 559 560 561 562 563 564 565 566 567 568
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  int * returnPointer = (int *)malloc(sizeof(int) * XdmfMapRetrieveNumberRemoteNodeIds(map, remoteTaskId, localNodeId));
  std::map<int, std::map<int, std::set<int> > > testMap = refMap->getMap();
  std::map<int, std::map<int, std::set<int> > >::const_iterator iter = testMap.find(remoteTaskId);
  std::map<int, std::set<int> >::const_iterator iter2 = iter->second.find(localNodeId);
  unsigned int i = 0;
  for(std::map<int, std::set<int> >::mapped_type::const_iterator iter3 =
	iter2->second.begin();
      iter3 != iter2->second.end();
      ++iter3) {
    returnPointer[i] = *iter3;
    i++;
569
  }
570
  return returnPointer;
571 572 573 574 575 576 577 578 579 580 581 582 583
}

void XdmfMapSetHeavyDataControllers(XDMFMAP * map,
                                    XDMFHEAVYDATACONTROLLER ** remoteTaskControllers,
                                    int numRemoteTaskControllers,
                                    XDMFHEAVYDATACONTROLLER ** localNodeControllers,
                                    int numLocalNodeControllers,
                                    XDMFHEAVYDATACONTROLLER ** remoteLocalNodeControllers,
                                    int numRemoteLocalNodeControllers,
                                    int passControl,
                                    int * status)
{
  XDMF_ERROR_WRAP_START(status)
584 585
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);

586 587
  std::vector<shared_ptr<XdmfHeavyDataController> > insertRemoteTaskControllers;
  for (int i = 0; i < numRemoteTaskControllers; ++i) {
588 589
    shared_ptr<XdmfHeavyDataController> & controller = *(shared_ptr<XdmfHeavyDataController> *)remoteTaskControllers[i];
    insertRemoteTaskControllers.push_back(controller);
590 591 592 593
  }

  std::vector<shared_ptr<XdmfHeavyDataController> > insertLocalNodeControllers;
  for (int i = 0; i < numLocalNodeControllers; ++i) {
594 595
    shared_ptr<XdmfHeavyDataController> & controller = *(shared_ptr<XdmfHeavyDataController> *)localNodeControllers[i];
    insertLocalNodeControllers.push_back(controller);
596 597 598 599
  }

  std::vector<shared_ptr<XdmfHeavyDataController> > insertRemoteLocalNodeControllers;
  for (int i = 0; i < numRemoteLocalNodeControllers; ++i) {
600 601
    shared_ptr<XdmfHeavyDataController> & controller = *(shared_ptr<XdmfHeavyDataController> *)remoteLocalNodeControllers[i];
    insertRemoteLocalNodeControllers.push_back(controller);
602
  }
603 604

  refMap->setHeavyDataControllers(insertRemoteTaskControllers, insertLocalNodeControllers, insertRemoteLocalNodeControllers);
605
  XDMF_ERROR_WRAP_END(status)
606
}
607 608 609

void XdmfMapSetName(XDMFMAP * map, char * newName)
{
610 611
  shared_ptr<XdmfMap> & refMap = *(shared_ptr<XdmfMap> *)(map);
  refMap->setName(std::string(newName));
612 613 614
}

XDMF_ITEM_C_CHILD_WRAPPER(XdmfMap, XDMFMAP)