ParMetisPartitioner.cc 17.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
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
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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
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
558
559
560
561
562
563
564
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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
#include "ParMetisPartitioner.h"
#include "Mesh.h"
#include "Traverse.h"
#include "ElInfo.h"
#include "Element.h"
#include "FixVec.h"
#include "PartitionElementData.h"
#include "DOFVector.h"
#include "mpi.h"

#include <queue>

namespace AMDiS {

  ParMetisMesh::ParMetisMesh(Mesh *mesh)
    : numElements_(0)
  {
    FUNCNAME("ParMetisMesh::ParMetisMesh()");
    int i;
    int mpiSize = MPI::COMM_WORLD.Get_size();

    int nodeCounter = 0;
    int elementCounter = 0;

    dim_ = mesh->getDim();
    int dow = Global::getGeo(WORLD);

    TraverseStack stack;
    ElInfo *elInfo = stack.traverseFirst(mesh, -1, 
					 Mesh::CALL_EVERY_EL_PREORDER);
    while(elInfo) {
      Element *element = elInfo->getElement();

      // get partition data
      PartitionElementData *partitionData = dynamic_cast<PartitionElementData*>
	(element->getElementData(PARTITION_ED));

      if(partitionData && 
	 partitionData->getPartitionStatus() == IN &&
	 partitionData->getLevel() == 0) 
      {
	elementCounter++;
      }

      elInfo = stack.traverseNext(elInfo);
    }

    numElements_ = elementCounter;

    TEST_EXIT(numElements_ > 0)("no elements in ParMETIS mesh\n");

    // allocate memory
    eptr_ = GET_MEMORY(int, numElements_ + 1);
    eind_ = GET_MEMORY(int, numElements_ * (dim_ + 1));
    elmdist_ = GET_MEMORY(int, mpiSize + 1);

    elem_p2a_ = GET_MEMORY(int, numElements_);

    if(dim_ == dow) {
      xyz_ = GET_MEMORY(float, numElements_ * dim_);
    } else {
      xyz_ = NULL;
    }

    eptr_[0] = 0;

    int *ptr_eptr = eptr_ + 1;
    int *ptr_eind = eind_;
    float *ptr_xyz = xyz_;
    
    // gather element numbers and create elmdist
    MPI::COMM_WORLD.Allgather(&numElements_, 1, MPI_INT,
			      elmdist_ + 1, 1, MPI_INT);
    elmdist_[0] = 0;
    for(i = 2; i < mpiSize + 1; i++) {
      elmdist_[i] += elmdist_[i - 1];
    }

    // traverse mesh and fill distributed ParMETIS data
    DimVec<double> bary(dim_, DEFAULT_VALUE, 1.0 / (dim_ + 1));
    WorldVector<double> world;

    elementCounter = 0;

    elInfo = stack.traverseFirst(mesh, -1, 
				 Mesh::CALL_EVERY_EL_PREORDER | 
				 Mesh::FILL_COORDS);
    while(elInfo) {
      Element *element = elInfo->getElement();
      int index = element->getIndex();

      // get partition data
      PartitionElementData *partitionData = dynamic_cast<PartitionElementData*>
	(element->getElementData(PARTITION_ED));

      // if element in partition
      if(partitionData && 
	 partitionData->getPartitionStatus() == IN &&
	 partitionData->getLevel() == 0) 
      {
	// remember index
	setParMetisIndex(index, elementCounter);
	setAMDiSIndex(elementCounter, index);

	// write eptr entry
	nodeCounter += dim_ + 1;
	*ptr_eptr = nodeCounter;
	ptr_eptr++;

	// write eind entries (element nodes)
	for(i = 0; i < dim_ + 1; i++) {
	  *ptr_eind = element->getDOF(i, 0);
	  ptr_eind++;
	}

	// write xyz element coordinates
	if(ptr_xyz) {
	  elInfo->coordToWorld(bary, &world);
	  for(i = 0; i < dim_; i++) {
	    *ptr_xyz = static_cast<float>(world[i]); 
	    ptr_xyz++;
	  }
	}

	elementCounter++;
      }
      elInfo = stack.traverseNext(elInfo);
    }
  }

  ParMetisMesh::~ParMetisMesh()
  {
    if(eptr_)     FREE_MEMORY(eptr_, int, numElements_ + 1);
    if(eind_)     FREE_MEMORY(eind_, int, numElements_ * (dim_ + 1));
    if(elmdist_)  FREE_MEMORY(elmdist_, int, MPI::COMM_WORLD.Get_size() + 1);
    if(xyz_)      FREE_MEMORY(xyz_, float, numElements_ * dim_);
    if(elem_p2a_) FREE_MEMORY(elem_p2a_, int, numElements_);
  }

  ParMetisGraph::ParMetisGraph(ParMetisMesh *parMetisMesh,
			       int ncommonnodes)
    : parMetisMesh_(parMetisMesh)
  {
    int numflag = 0;

    if(ncommonnodes == -1) ncommonnodes = parMetisMesh->getDim();

    MPI_Comm comm = MPI_COMM_WORLD; 

    ParMETIS_V3_Mesh2Dual(parMetisMesh_->getElementDist(),
			  parMetisMesh_->getElementPtr(),
			  parMetisMesh_->getElementInd(),
			  &numflag,
			  &ncommonnodes,
			  &xadj_,
			  &adjncy_,
			  &comm);
  }

  ParMetisGraph::~ParMetisGraph()
  {
    free(xadj_);
    free(adjncy_);
//     if(xadj_) delete [] xadj_;
//     if(adjncy_) delete [] adjncy_;
  }

  void ParMetisPartitioner::deletePartitionData() 
  {
    TraverseStack stack;
    ElInfo *elInfo;
    elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_EVERY_EL_PREORDER);
    while(elInfo) {
      Element *element = elInfo->getElement();
      element->deleteElementData(PARTITION_ED);
      elInfo = stack.traverseNext(elInfo);
    }
  }

  void ParMetisPartitioner::createPartitionData() {
    int mpiRank = MPI::COMM_WORLD.Get_rank();
    int mpiSize = MPI::COMM_WORLD.Get_size();

    TraverseStack stack;
    ElInfo *elInfo;

    // === create initial partitioning on AMDiS mesh ===
    int totalElementCounter = 0;
    elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_LEAF_EL);
    while(elInfo) {
      Element *element = elInfo->getElement();
      //int index = element->getIndex();

      TEST_EXIT(element->getElementData(PARTITION_ED) == NULL)
	("mesh already partitioned\n");

      PartitionElementData *elData = 
	NEW PartitionElementData(element->getElementData());
      element->setElementData(elData);

      if(totalElementCounter % mpiSize == mpiRank) {
	elData->setPartitionStatus(IN);
      } else {
	elData->setPartitionStatus(UNDEFINED);
      }
      totalElementCounter++;

      elInfo = stack.traverseNext(elInfo);
    }

//     elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_LEAF_EL);
//     while(elInfo) {
//       Element *element = elInfo->getElement();
//       int index = element->getIndex();
	
//       TEST_EXIT(element->getElementData(PARTITION_ED) == NULL)
// 	("mesh already partitioned\n");

//       PartitionElementData *elData = 
// 	NEW PartitionElementData(element->getElementData());
//       element->setElementData(elData);
//       elData->setPartitionStatus(UNDEFINED);
//       elData->setLevel(0);
//       elInfo = stack.traverseNext(elInfo);
//     }
  }

  void ParMetisPartitioner::partition(std::map<int, double> *elemWeights,
				      PartitionMode mode,
				      float itr) 
  {
    int mpiSize = MPI::COMM_WORLD.Get_size();

    TraverseStack stack;
    ElInfo *elInfo;

    // === create initial partitioning on AMDiS mesh ===

//     if(mode == INITIAL) {
//       int totalElementCounter = 0;
//       elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_EVERY_EL_PREORDER);
//       while(elInfo) {
// 	Element *element = elInfo->getElement();
// 	int index = element->getIndex();

// 	// get partition data
// 	PartitionElementData *partitionData = dynamic_cast<PartitionElementData*>
// 	  (element->getElementData(PARTITION_ED));
	
// 	if(partitionData && partitionData->getLevel() == 0) {
// 	  if(totalElementCounter % mpiSize == mpiRank) {
// 	    partitionData->setPartitionStatus(IN);
// 	  } else {
// 	    partitionData->setPartitionStatus(UNDEFINED);
// 	  }
// 	  totalElementCounter++;
// 	}
// 	elInfo = stack.traverseNext(elInfo);
//       }
//     }

    // === create parmetis mesh ===
    if(parMetisMesh_) DELETE parMetisMesh_;
    parMetisMesh_ = NEW ParMetisMesh(mesh_);

    int numElements = parMetisMesh_->getNumElements();

    // === create weight array ===
    int *wgts = elemWeights ? GET_MEMORY(int, numElements) : NULL;
    float *floatWgts = elemWeights ? GET_MEMORY(float, numElements) : NULL;
    float maxWgt = 0.0;

    float *ptr_floatWgts = floatWgts;
    //int *ptr_wgts = wgts;

    elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_EVERY_EL_PREORDER);
    while(elInfo) {
      Element *element = elInfo->getElement();

      // get partition data
      PartitionElementData *partitionData = dynamic_cast<PartitionElementData*>
	(element->getElementData(PARTITION_ED));

      if(partitionData &&
	 partitionData->getPartitionStatus() == IN &&
	 partitionData->getLevel() == 0) 
      {	
	int index = element->getIndex();

	// get weight 
	float wgt = static_cast<float>((*elemWeights)[index]);
	maxWgt = max(wgt, maxWgt);

	// write float weight
	*ptr_floatWgts = wgt;
	ptr_floatWgts++;
      }
      elInfo = stack.traverseNext(elInfo);
    }

    float tmp;
    MPI::COMM_WORLD.Allreduce(&maxWgt,
			      &tmp,
			      1,
			      MPI_FLOAT,
			      MPI_MAX);
    maxWgt = tmp;

    // === create dual graph ===
    ParMetisGraph parMetisGraph(parMetisMesh_);

    // === partitioning of dual graph ===
    MPI_Comm comm = MPI_COMM_WORLD;

    int i;
    int wgtflag = elemWeights ? 2 : 0; // weights at vertices only!
    int numflag = 0; // c numbering style!
    //int ndims = mesh_->getDim();
    int ncon = elemWeights ? 1 : 0; // one weight at each vertex!
    int nparts = mpiSize; // number of partitions
    float *tpwgts = elemWeights ? GET_MEMORY(float, mpiSize) : NULL;
    float ubvec = 1.05;
    int options[3] = {0, 0, 0}; // default options
    int edgecut = -1;
    int *part = GET_MEMORY(int, numElements);
    
    if(elemWeights) {
      for(i = 0; i < mpiSize; i++) {
	// set tpwgts
	tpwgts[i] = 1.0/nparts;
      }      

      float scale = 10000 / maxWgt;
      for(i = 0; i < numElements; i++) {
	// scale wgts
	wgts[i] = static_cast<int>(floatWgts[i] * scale);
      }
    }

    switch(mode) {
    case INITIAL:
//       if(parMetisMesh_->getXYZ()) {
// 	ParMETIS_V3_PartGeomKway(parMetisMesh_->getElementDist(),
// 				 parMetisGraph.getXAdj(),
// 				 parMetisGraph.getAdjncy(),
// 				 wgts,
// 				 NULL,
// 				 &wgtflag,
// 				 &numflag,
// 				 &ndims,
// 				 parMetisMesh_->getXYZ(),
// 				 &ncon,
// 				 &nparts,
// 				 tpwgts,
// 				 &ubvec,
// 				 options,
// 				 &edgecut,
// 				 part,
// 				 &comm);
      ParMETIS_V3_PartKway(parMetisMesh_->getElementDist(),
			   parMetisGraph.getXAdj(),
			   parMetisGraph.getAdjncy(),
			   wgts,
			   NULL,
			   &wgtflag,
			   &numflag,
			   &ncon,
			   &nparts,
			   tpwgts,
			   &ubvec,
			   options,
			   &edgecut,
			   part,
			   &comm);
//       } else {
// 	ERROR_EXIT("not yet dim != dow (no xyz)\n");
//       }
      break;
    case ADAPTIVE_REPART:
      {
	int *vsize = GET_MEMORY(int, numElements);
	for(i = 0; i < numElements; i++) {
	  vsize[i] = 1;
	}
	ParMETIS_V3_AdaptiveRepart(parMetisMesh_->getElementDist(),
				   parMetisGraph.getXAdj(),
				   parMetisGraph.getAdjncy(),
				   wgts,
				   NULL,
				   vsize,
				   &wgtflag,
				   &numflag,
				   &ncon,
				   &nparts,
				   tpwgts,
				   &ubvec,
				   &itr,
				   options,
				   &edgecut,
				   part,
				   &comm);
	FREE_MEMORY(vsize, int, numElements);
      }
      break;
    case REFINE_PART:
      ParMETIS_V3_RefineKway(parMetisMesh_->getElementDist(),
			     parMetisGraph.getXAdj(),
			     parMetisGraph.getAdjncy(),
			     wgts,
			     NULL,
			     &wgtflag,
			     &numflag,
			     &ncon,
			     &nparts,
			     tpwgts,
			     &ubvec,
			     options,
			     &edgecut,
			     part,
			     &comm);
      break;
    default: 
      ERROR_EXIT("unknown partitioning mode\n");
    }

    // === distribute new partition data ===
    distributePartitioning(part);

    if(floatWgts) FREE_MEMORY(floatWgts, float, numElements);
    if(wgts) FREE_MEMORY(wgts, int, numElements);    
    if(tpwgts) FREE_MEMORY(tpwgts, float, mpiSize);
    FREE_MEMORY(part, int, numElements);
  }

  void ParMetisPartitioner::fillCoarsePartitionVec(std::map<int, int> *partitionVec)
  {
    TEST_EXIT(partitionVec)("no partition vector\n");

    partitionVec->clear();

    // update ParMETIS mesh to new partitioning
    if(!parMetisMesh_) parMetisMesh_ = NEW ParMetisMesh(mesh_);

    int i, j;
    //int dim = mesh_->getDim();
    int mpiRank = MPI::COMM_WORLD.Get_rank();
    int mpiSize = MPI::COMM_WORLD.Get_size();

    int *numPartitionElements = GET_MEMORY(int, mpiSize);

    int *elmdist = parMetisMesh_->getElementDist();
    for(i = 0;  i < mpiSize; i++) {
      numPartitionElements[i] = elmdist[i+1] - elmdist[i];
    }

    // === count number of elements ===
    int numElements = 0;
    int localElements = parMetisMesh_->getNumElements();
    MPI::COMM_WORLD.Allreduce(&localElements,
			      &numElements,
			      1,
			      MPI_INT,
			      MPI_SUM);

    int *partitionElements = GET_MEMORY(int, numElements);

    // distribute partition elements
    MPI::COMM_WORLD.Allgatherv(parMetisMesh_->getAMDiSIndices(),
			       numPartitionElements[mpiRank], 
			       MPI_INT, 
			       partitionElements, 
			       numPartitionElements, 
			       elmdist, 
			       MPI_INT);

    // fill partitionVec
    for(i = 0; i < mpiSize; i++) {
      for(j = 0; j < numPartitionElements[i]; j++) {
	(*partitionVec)[partitionElements[elmdist[i] + j]] = i;
      }
    }

    FREE_MEMORY(partitionElements, int, numElements);
    FREE_MEMORY(numPartitionElements, int, mpiSize);
  }

  void ParMetisPartitioner::distributePartitioning(int *part) 
  {
    int i;
    int mpiSize = MPI::COMM_WORLD.Get_size();
    int mpiRank = MPI::COMM_WORLD.Get_rank();

    int numElements = parMetisMesh_->getNumElements();

    // count elements per partition in this rank
    int *numPartitionElements = GET_MEMORY(int, mpiSize);
    for(i = 0; i < mpiSize; i++) 
      numPartitionElements[i] = 0;
    for(i = 0; i < numElements; i++) {
      numPartitionElements[part[i]]++;
    }

    // collect number of partition elements from all ranks for this rank
    int *numRankElements = GET_MEMORY(int, mpiSize);
    MPI::COMM_WORLD.Alltoall(numPartitionElements, 1, MPI_INT,
			     numRankElements, 1, MPI_INT);

    // sum up partition elements over all ranks
    int *sumPartitionElements = GET_MEMORY(int, mpiSize);

    MPI::COMM_WORLD.Allreduce(numPartitionElements,
			      sumPartitionElements,
			      mpiSize,
			      MPI_INT,
			      MPI_SUM);

    
    // prepare distribution (fill partitionElements with AMDiS indices)
    int *bufferOffset = GET_MEMORY(int, mpiSize);
    bufferOffset[0] = 0;
    for(i = 1; i < mpiSize; i++) {
      bufferOffset[i] = bufferOffset[i - 1] + numPartitionElements[i - 1];
    }

    int *partitionElements = GET_MEMORY(int, numElements);
    int **partitionPtr = GET_MEMORY(int*, mpiSize);

    for(i = 0; i < mpiSize; i++) {
      partitionPtr[i] = partitionElements + bufferOffset[i];
    }

    for(i = 0; i < numElements; i++) {
      int partition = part[i];
      int amdisIndex = parMetisMesh_->getAMDiSIndex(i);
      *(partitionPtr[partition]) = amdisIndex;
      ++(partitionPtr[partition]);
    }

    // all to all: partition elements to rank elements
    int *rankElements = GET_MEMORY(int, sumPartitionElements[mpiRank]);
    int *recvBufferOffset = GET_MEMORY(int, mpiSize);
    recvBufferOffset[0] = 0;
    for(i = 1; i < mpiSize; i++) {
      recvBufferOffset[i] = recvBufferOffset[i - 1] + numRankElements[i - 1];
    }

    MPI::COMM_WORLD.Alltoallv(partitionElements, 
			      numPartitionElements,
			      bufferOffset,
			      MPI_INT,
			      rankElements,
			      numRankElements,
			      recvBufferOffset,
			      MPI_INT);
    

    // === partition AMDiS mesh ===

    // write data in stl map
    std::map<int, bool> elementInPartition;
    for(i = 0; i < mpiSize; i++) {
      int *rankPtr;
      int *rankStart = rankElements + recvBufferOffset[i];
      int *rankEnd = rankStart + numRankElements[i];
      for(rankPtr = rankStart; rankPtr < rankEnd; ++rankPtr) {
	elementInPartition[*rankPtr] = true;
      }
    }

    TraverseStack stack;
    ElInfo *elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_EVERY_EL_PREORDER);
    while(elInfo) {
      Element *element = elInfo->getElement();

      // get partition data
      PartitionElementData *partitionData = dynamic_cast<PartitionElementData*>
	(element->getElementData(PARTITION_ED));

      if(partitionData && partitionData->getLevel() == 0) {
	int amdisIndex = element->getIndex();
	if(elementInPartition[amdisIndex]) {
	  partitionData->setPartitionStatus(IN);
	} else {
	  partitionData->setPartitionStatus(OUT);
	}
	descendPartitionData(element);
      }

      elInfo = stack.traverseNext(elInfo);
    }

    DELETE parMetisMesh_;
    parMetisMesh_ = NULL;
    //parMetisMesh_ = NEW ParMetisMesh(mesh_);

//     MSG("rank %d partition elements: %d\n",
// 	mpiRank, sumPartitionElements[mpiRank]);

    FREE_MEMORY(rankElements, int, sumPartitionElements[mpiRank]);
    FREE_MEMORY(numPartitionElements, int, mpiSize);
    FREE_MEMORY(numRankElements, int, mpiSize);
    FREE_MEMORY(sumPartitionElements, int, mpiSize);
    FREE_MEMORY(partitionElements, int, numElements);
    FREE_MEMORY(partitionPtr, int*, mpiSize);
    FREE_MEMORY(bufferOffset, int, mpiSize);
    FREE_MEMORY(recvBufferOffset, int, mpiSize);
  }

  void ParMetisPartitioner::descendPartitionData(Element *element) 
  {
    if(!element->isLeaf()) {
      Element *child0 = element->getChild(0);
      Element *child1 = element->getChild(1);

      // get partition data
      PartitionElementData *parentData = dynamic_cast<PartitionElementData*>
	(element->getElementData(PARTITION_ED));
      PartitionElementData *child0Data = dynamic_cast<PartitionElementData*>
	(child0->getElementData(PARTITION_ED));
      PartitionElementData *child1Data = dynamic_cast<PartitionElementData*>
	(child1->getElementData(PARTITION_ED));
      
      TEST_EXIT(parentData && child0Data && child1Data)("no partition data\n");

      child0Data->setPartitionStatus(parentData->getPartitionStatus());
      child1Data->setPartitionStatus(parentData->getPartitionStatus());

      descendPartitionData(child0);
      descendPartitionData(child1);
    }
  }


  void ParMetisPartitioner::fillLeafPartitionVec(std::map<int, int> *coarseVec,
						 std::map<int, int> *fineVec)
  {
    int partition = -1;
    TraverseStack stack;
    ElInfo *elInfo = stack.traverseFirst(mesh_, -1, Mesh::CALL_EVERY_EL_PREORDER);
    while(elInfo) {
      Element *element = elInfo->getElement();
      PartitionElementData *partitionData = dynamic_cast<PartitionElementData*>
	(element->getElementData(PARTITION_ED));
      if(partitionData) {
	if(partitionData->getLevel() == 0) {
	  partition = (*(coarseVec))[element->getIndex()];
	}
	if(element->isLeaf()) {
	  (*(fineVec))[element->getIndex()] = partition;
	}
      }
      elInfo = stack.traverseNext(elInfo);
    }
  }
}