regionSplit.C 21.3 KB
Newer Older
Henry's avatar
Henry committed
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
5
    \\  /    A nd           | Copyright (C) 2004-2010, 2018 OpenCFD Ltd.
OpenFOAM bot's avatar
OpenFOAM bot committed
6
7
8
     \\/     M anipulation  |
-------------------------------------------------------------------------------
                            | Copyright (C) 2011-2013 OpenFOAM Foundation
Henry's avatar
Henry committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "regionSplit.H"
#include "cyclicPolyPatch.H"
#include "processorPolyPatch.H"
#include "globalIndex.H"
#include "syncTools.H"
33
#include "clockValue.H"
Henry's avatar
Henry committed
34
35
36
37
38

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
39
    defineTypeNameAndDebug(regionSplit, 0);
Henry's avatar
Henry committed
40
41
}

42
43
static constexpr Foam::label UNASSIGNED = -1;
static constexpr Foam::label BLOCKED = -2;
Henry's avatar
Henry committed
44
45


46
47
48
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //

namespace Foam
Henry's avatar
Henry committed
49
{
50

51
52
53
54
55
//- The sizes of a List of containers (eg, labelHashSet)
template<class Container>
static labelList containerSizes(const UList<Container>& input)
{
    const label len = input.size();
56

57
    labelList output(len);
58

59
    for (label i = 0; i < len; ++i)
60
    {
61
        output[i] = input[i].size();
Henry's avatar
Henry committed
62
63
    }

64
65
    return output;
}
Henry's avatar
Henry committed
66

67
} // End namespace Foam
68

69

70
// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
71

72
73
74
75
void Foam::regionSplit::updateFacePair
(
    const label face0,
    const label face1,
76

77
78
79
80
81
82
83
84
85
86
    labelList& faceRegion,
    DynamicList<label>& facesChanged
) const
{
    if (faceRegion[face0] == UNASSIGNED)
    {
        if (faceRegion[face1] >= 0)
        {
            faceRegion[face0] = faceRegion[face1];
            facesChanged.append(face0);
87
        }
88
        else if (faceRegion[face1] == BLOCKED)
89
        {
90
91
            // face1 blocked but not face0.
            // - illegal for coupled faces, OK for explicit connections.
Henry's avatar
Henry committed
92
93
        }
    }
94
    else if (faceRegion[face0] >= 0)
95
    {
96
        if (faceRegion[face1] == UNASSIGNED)
Henry's avatar
Henry committed
97
        {
98
99
            faceRegion[face1] = faceRegion[face0];
            facesChanged.append(face1);
Henry's avatar
Henry committed
100
        }
101
        else if (faceRegion[face1] == BLOCKED)
Henry's avatar
Henry committed
102
        {
103
104
105
106
107
108
109
110
111
112
113
114
115
116
            // face1 blocked but not face0.
            // - illegal for coupled faces, OK for explicit connections.
        }
        else if (faceRegion[face1] != faceRegion[face0])
        {
            FatalErrorInFunction
                << "Problem : coupled face " << face0
                << " on patch " << mesh().boundaryMesh().whichPatch(face0)
                << " has region " << faceRegion[face0]
                << " but coupled face " << face1
                << " has region " << faceRegion[face1] << nl
                << "Is your blocked faces specification"
                << " synchronized across coupled boundaries?" << endl
                << abort(FatalError);
Henry's avatar
Henry committed
117
118
119
120
121
        }
    }
}


122
void Foam::regionSplit::fillSeedMask
Henry's avatar
Henry committed
123
124
(
    const List<labelPair>& explicitConnections,
125
126
127
128
    const label seedCellId,
    const label markValue,
    labelList& cellRegion,
    labelList& faceRegion
Henry's avatar
Henry committed
129
130
) const
{
131
132
    // Seed cell
    cellRegion[seedCellId] = markValue;
Henry's avatar
Henry committed
133

134
135
136
137
138
139
140
141
142
143
    // Faces on seed cell
    changedFaces_.clear();
    for (const label facei : mesh().cells()[seedCellId])
    {
        if (faceRegion[facei] == UNASSIGNED)
        {
            faceRegion[facei] = markValue;
            changedFaces_.append(facei);
        }
    }
Henry's avatar
Henry committed
144

145
146
147
148
149
    const polyBoundaryMesh& patches = mesh().boundaryMesh();

    // Loop over changed faces. FaceCellWave in small.

    while (changedFaces_.size())
Henry's avatar
Henry committed
150
    {
151
        changedCells_.clear();
Henry's avatar
Henry committed
152

153
        for (const label facei : changedFaces_)
Henry's avatar
Henry committed
154
        {
155
156
157
158
159
160
161
162
163
            const label own = mesh().faceOwner()[facei];

            if (cellRegion[own] == UNASSIGNED)
            {
                cellRegion[own] = markValue;
                changedCells_.append(own);
            }

            if (mesh().isInternalFace(facei))
Henry's avatar
Henry committed
164
            {
165
166
167
                const label nei = mesh().faceNeighbour()[facei];

                if (cellRegion[nei] == UNASSIGNED)
168
                {
169
170
                    cellRegion[nei] = markValue;
                    changedCells_.append(nei);
171
                }
Henry's avatar
Henry committed
172
173
174
            }
        }

175
        if (debug & 2)
Henry's avatar
Henry committed
176
        {
177
178
179
            Pout<< " Changed cells / faces : "
                << changedCells_.size() << " / " << changedFaces_.size()
                << " before sync" << endl;
Henry's avatar
Henry committed
180
181
        }

182
183
184
        // Loop over changedCells and collect faces
        changedFaces_.clear();
        for (const label celli : changedCells_)
Henry's avatar
Henry committed
185
        {
186
            for (const label facei : mesh().cells()[celli])
187
            {
188
189
190
191
192
                if (faceRegion[facei] == UNASSIGNED)
                {
                    faceRegion[facei] = markValue;
                    changedFaces_.append(facei);
                }
193
            }
Henry's avatar
Henry committed
194
195
        }

196

197
198
199
200
        // Update locally coupled faces
        // Global connections are done later.

        for (const polyPatch& pp : patches)
Henry's avatar
Henry committed
201
        {
202
203
204
205
206
207
208
            if
            (
                isA<cyclicPolyPatch>(pp)
             && refCast<const cyclicPolyPatch>(pp).owner()
            )
            {
                // Transfer from neighbourPatch to here or vice versa.
209

210
211
                const cyclicPolyPatch& cycPatch =
                    refCast<const cyclicPolyPatch>(pp);
Henry's avatar
Henry committed
212

213
                label face0 = cycPatch.start();
Henry's avatar
Henry committed
214

215
216
217
                forAll(cycPatch, i)
                {
                    const label face1 = cycPatch.transformGlobalFace(face0);
Henry's avatar
Henry committed
218

219
220
221
222
223
224
225
                    updateFacePair
                    (
                        face0,
                        face1,
                        faceRegion,
                        changedFaces_
                    );
Henry's avatar
Henry committed
226

227
228
229
230
                    ++face0;
                }
            }
        }
Henry's avatar
Henry committed
231

232
233
234
235
236
237
238
239
240
241
        for (const labelPair& pr : explicitConnections)
        {
            updateFacePair
            (
                pr.first(),
                pr.second(),
                faceRegion,
                changedFaces_
            );
        }
Henry's avatar
Henry committed
242

243
244
245
246
247
248
249
250
        if (debug & 2)
        {
            Pout<< " Changed faces : "
                << changedFaces_.size()
                << " after sync" << endl;
        }
    }
}
Henry's avatar
Henry committed
251
252


253
254
255
256
257
258
259
260
261
262
263
264
265
Foam::label Foam::regionSplit::calcLocalRegionSplit
(
    const boolList& blockedFace,
    const List<labelPair>& explicitConnections,

    labelList& cellRegion
) const
{
    clockValue timing(debug);

    if (debug)
    {
        if (blockedFace.size())
Henry's avatar
Henry committed
266
        {
267
268
269
            // Check that blockedFace is synced.
            boolList syncBlockedFace(blockedFace);
            syncTools::swapFaceList(mesh(), syncBlockedFace);
Henry's avatar
Henry committed
270

271
            forAll(syncBlockedFace, facei)
Henry's avatar
Henry committed
272
            {
273
                if (syncBlockedFace[facei] != blockedFace[facei])
Henry's avatar
Henry committed
274
                {
275
276
277
278
279
                    FatalErrorInFunction
                        << "Face " << facei << " not synchronised. My value:"
                        << blockedFace[facei] << "  coupled value:"
                        << syncBlockedFace[facei]
                        << abort(FatalError);
Henry's avatar
Henry committed
280
281
282
283
284
                }
            }
        }
    }

285
286
    changedCells_.reserve(mesh_.nCells());
    changedFaces_.reserve(mesh_.nFaces());
Henry's avatar
Henry committed
287

288
289
290
291
    // Region per face.
    // -1 = unassigned
    // -2 = blocked
    labelList faceRegion(mesh().nFaces(), UNASSIGNED);
Henry's avatar
Henry committed
292

293
    if (blockedFace.size())
Henry's avatar
Henry committed
294
    {
295
        forAll(blockedFace, facei)
296
        {
297
298
299
300
            if (blockedFace[facei])
            {
                faceRegion[facei] = BLOCKED;
            }
301
        }
Henry's avatar
Henry committed
302
303
    }

304
305
306
307
308
309
310
311

    // Assign local regions
    // ~~~~~~~~~~~~~~~~~~~~

    // Start with region 0
    label nLocalRegions = 0;

    for (label seedCellId = 0; seedCellId < cellRegion.size(); ++seedCellId)
Henry's avatar
Henry committed
312
    {
313
314
315
        // Find next unset cell - use as seed

        for (; seedCellId < cellRegion.size(); ++seedCellId)
Henry's avatar
Henry committed
316
        {
317
318
319
320
            if (cellRegion[seedCellId] == UNASSIGNED)
            {
                break;
            }
Henry's avatar
Henry committed
321
        }
322
323

        if (seedCellId >= cellRegion.size())
Henry's avatar
Henry committed
324
        {
325
            break;
Henry's avatar
Henry committed
326
327
        }

328
329
330
331
332
333
334
335
        fillSeedMask
        (
            explicitConnections,
            seedCellId,
            nLocalRegions,
            cellRegion,
            faceRegion
        );
Henry's avatar
Henry committed
336

337
        ++nLocalRegions; // Next region
Henry's avatar
Henry committed
338
339
    }

340
341
342
343
    // Discard temporary working data
    changedCells_.clearStorage();
    changedFaces_.clearStorage();

Henry's avatar
Henry committed
344
345
    if (debug)
    {
346
        forAll(cellRegion, celli)
Henry's avatar
Henry committed
347
        {
348
349
350
351
352
353
            if (cellRegion[celli] < 0)
            {
                FatalErrorInFunction
                    << "cell:" << celli << " region:" << cellRegion[celli]
                    << abort(FatalError);
            }
Henry's avatar
Henry committed
354
355
        }

356
        forAll(faceRegion, facei)
Henry's avatar
Henry committed
357
        {
358
359
360
361
362
363
            if (faceRegion[facei] == UNASSIGNED)
            {
                FatalErrorInFunction
                    << "face:" << facei << " region:" << faceRegion[facei]
                    << abort(FatalError);
            }
Henry's avatar
Henry committed
364
365
366
        }
    }

367
368
369
370
    if (debug)
    {
        Info<<"regionSplit = " << double(timing.elapsed()) << "s\n";
    }
Henry's avatar
Henry committed
371

372
373
    return nLocalRegions;
}
Henry's avatar
Henry committed
374
375


376
377
378
379
380
Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::calcRegionSplit
(
    const bool doGlobalRegions,
    const boolList& blockedFace,
    const List<labelPair>& explicitConnections,
Henry's avatar
Henry committed
381

382
383
384
385
386
387
388
389
390
    labelList& cellRegion
) const
{
    const label nLocalRegions = calcLocalRegionSplit
    (
        blockedFace,
        explicitConnections,
        cellRegion
    );
Henry's avatar
Henry committed
391

392
    if (!doGlobalRegions)
Henry's avatar
Henry committed
393
    {
394
        return autoPtr<globalIndex>::New(nLocalRegions);
Henry's avatar
Henry committed
395
396
    }

397
    return reduceRegions(nLocalRegions, blockedFace, cellRegion);
Henry's avatar
Henry committed
398
399
400
401
402
}


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

403
404
405
406
407
Foam::regionSplit::regionSplit
(
    const polyMesh& mesh,
    const bool doGlobalRegions
)
Henry's avatar
Henry committed
408
409
410
411
412
413
:
    MeshObject<polyMesh, Foam::TopologicalMeshObject, regionSplit>(mesh),
    labelList(mesh.nCells(), -1)
{
    globalNumberingPtr_ = calcRegionSplit
    (
414
415
416
        doGlobalRegions,
        boolList(),         // No blockedFace
        List<labelPair>(),  // No explicitConnections
Henry's avatar
Henry committed
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
        *this
    );
}


Foam::regionSplit::regionSplit
(
    const polyMesh& mesh,
    const boolList& blockedFace,
    const bool doGlobalRegions
)
:
    MeshObject<polyMesh, Foam::TopologicalMeshObject, regionSplit>(mesh),
    labelList(mesh.nCells(), -1)
{
    globalNumberingPtr_ = calcRegionSplit
    (
        doGlobalRegions,
435
436
        blockedFace,
        List<labelPair>(),  // No explicitConnections
Henry's avatar
Henry committed
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
        *this
    );
}


Foam::regionSplit::regionSplit
(
    const polyMesh& mesh,
    const boolList& blockedFace,
    const List<labelPair>& explicitConnections,
    const bool doGlobalRegions
)
:
    MeshObject<polyMesh, Foam::TopologicalMeshObject, regionSplit>(mesh),
    labelList(mesh.nCells(), -1)
{
    globalNumberingPtr_ = calcRegionSplit
    (
        doGlobalRegions,
456
457
        blockedFace,
        explicitConnections,
Henry's avatar
Henry committed
458
459
460
461
462
        *this
    );
}


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
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::reduceRegions
(
    const label numLocalRegions,
    const boolList& blockedFace,

    labelList& cellRegion
) const
{
    clockValue timing(debug);

    if (cellRegion.size() != mesh().nCells())
    {
        FatalErrorInFunction
            << "The cellRegion size " << cellRegion.size()
            << " is not equal to the of number of cells "
            << mesh().nCells() << endl
            << abort(FatalError);
    }


    // (numLocalRegions < 0) to signal that region information should be
    // determined ourselves. This is not really efficient, but can be useful

    const label nLocalRegions =
    (
        numLocalRegions < 0
      ? labelHashSet(cellRegion).size()
      : numLocalRegions
    );


    // Preliminary global region numbers
    const globalIndex globalRegions(nLocalRegions);


    // Lookup table of local region to global region.
    // Initially an identity mapping of the uncombined global values.

    Map<label> localToGlobal(2*nLocalRegions);
    for (const label regioni : cellRegion)
    {
        localToGlobal.insert(regioni, globalRegions.toGlobal(regioni));
    }

    // To update the localToGlobal mapping during traversal of the boundaries
    // and later when finalizing things.
    Map<label> updateLookup(2*nLocalRegions);


    // Note that we use two separate maps during the process.
    // The localToGlobal is used to map the local to global regions.
    // Merging across processors will normally make this a many->few mapping.
    // However, we may need to walk up and down processor boundaries several
    // times before all the information propagates through.
    // During these traversals, it will normally be more efficient to just
    // update the mapping without updating the cellRegion immediately.
    // Only after everything is finalized do we renumber all of the cell
    // regions.


    // Merge global regions
    // ~~~~~~~~~~~~~~~~~~~~
    // Regions across non-blocked proc patches get merged.
    // This will set merged global regions to be the min of both.
    // (this will create gaps in the global region list so they will get
    // merged later on)

    const polyBoundaryMesh& patches = mesh().boundaryMesh();

    // Buffer for swapping boundary information
535
    labelList nbrRegion(mesh().nBoundaryFaces());
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
656
657
658
659
660
661
662
663
664

    do
    {
        if (debug)
        {
            Pout<< nl << "-- Starting Iteration --" << endl;
        }

        updateLookup.clear();
        nbrRegion = UNASSIGNED;

        // Region information to send
        for (const polyPatch& pp : patches)
        {
            if (pp.coupled())
            {
                const labelUList& faceCells = pp.faceCells();
                SubList<label> patchNbrRegion
                (
                    nbrRegion,
                    pp.size(),
                    pp.start()-mesh().nInternalFaces()
                );

                forAll(faceCells, patchFacei)
                {
                    const label meshFacei = pp.start()+patchFacei;

                    if (!blockedFace[meshFacei])
                    {
                        // Send the most currently updated region Id
                        const label orig = cellRegion[faceCells[patchFacei]];

                        patchNbrRegion[patchFacei] = localToGlobal[orig];
                    }
                }
            }
        }
        syncTools::swapBoundaryFaceList(mesh(), nbrRegion);

        // Receive and reduce region information
        for (const polyPatch& pp : patches)
        {
            if (pp.coupled())
            {
                const labelUList& faceCells = pp.faceCells();
                SubList<label> patchNbrRegion
                (
                    nbrRegion,
                    pp.size(),
                    pp.start()-mesh().nInternalFaces()
                );

                forAll(faceCells, patchFacei)
                {
                    const label meshFacei = pp.start()+patchFacei;

                    if (!blockedFace[meshFacei])
                    {
                        // Reduction by retaining the min region id.

                        const label orig = cellRegion[faceCells[patchFacei]];

                        const label sent = localToGlobal[orig];
                        const label recv = patchNbrRegion[patchFacei];

                        // Record the minimum value seen
                        if (recv < sent)
                        {
                            auto fnd = updateLookup.find(sent);
                            if (!fnd.found())
                            {
                                updateLookup.insert(sent, recv);
                            }
                            else if (recv < *fnd)
                            {
                                *fnd = recv;
                            }
                        }
                    }
                }
            }
        }


        // Note: by always using the minimum region number across the
        // processor faces, we effect a consolidation of connected regions
        // and converge to a unique number for each distinct region.


        // Update localToGlobal according to newly exchanged information

        inplaceMapValue(updateLookup, localToGlobal);

        if (debug & 2)
        {
            labelList keys(localToGlobal.sortedToc());
            labelList vals(keys.size());
            forAll(keys, i)
            {
                vals[i] = localToGlobal[keys[i]];
            }

            Pout<< "Updated local regions:" << nl
                << "old: " << flatOutput(keys) << nl
                << "new: " << flatOutput(vals) << endl;
        }
        else if (debug)
        {
            Pout<< "Updated " << localToGlobal.size()
                << " local regions" << endl;
        }

        // Continue until there are no further changes
    }
    while (returnReduce(!updateLookup.empty(), orOp<bool>()));


    //
    // We will need compact numbers locally and non-locally
    //

    // Determine the local compact numbering
    label nCompact = 0;
    {
        labelHashSet localRegion(2*localToGlobal.size());

        forAllConstIters(localToGlobal, iter)
        {
665
            const label regioni = iter.val();
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710

            if (globalRegions.isLocal(regioni))
            {
                localRegion.insert(regioni);
            }
        }

        nCompact = localRegion.size();
    }


    // The new global numbering using compacted local regions
    auto globalCompactPtr = autoPtr<globalIndex>::New(nCompact);
    const auto& globalCompact = *globalCompactPtr;


    // Determine the following:
    // - the local compact regions (store as updateLookup)
    // - the non-local regions, ordered according to the processor on which
    //   they are local.


    // The local compaction map (updated local to compact local numbering)
    updateLookup.clear();

    labelListList sendNonLocal(Pstream::nProcs());

    {
        List<labelHashSet> nonLocal(Pstream::nProcs(), labelHashSet(0));

        // Use estimate of sizing for non-local regions
        forAll(nonLocal, proci)
        {
            if (proci != Pstream::myProcNo())
            {
                nonLocal[proci].resize
                (
                    2*((nLocalRegions-nCompact)/Pstream::nProcs())
                );
            }
        }


        forAllConstIters(localToGlobal, iter)
        {
711
            const label regioni = iter.val();
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812

            if (globalRegions.isLocal(regioni))
            {
                updateLookup.insert
                (
                    regioni,
                    globalCompact.toGlobal(updateLookup.size())
                );
            }
            else
            {
                nonLocal[globalRegions.whichProcID(regioni)].insert(regioni);
            }
        }

        if (debug)
        {
            Pout<< " per processor nonLocal regions: "
                << flatOutput(containerSizes(nonLocal)) << endl;
        }


        // Convert to label list
        forAll(sendNonLocal, proci)
        {
            sendNonLocal[proci] = nonLocal[proci].toc();
        }
    }


    // Get the wanted region labels into recvNonLocal
    labelListList recvNonLocal;
    Pstream::exchange<labelList, label>
    (
        sendNonLocal,
        recvNonLocal
    );


    // The recvNonLocal[proci] region labels are what proci requires.
    // Transcribe into their compacted number.

    {
        labelListList sendLocal(std::move(recvNonLocal));

        for (labelList& send : sendLocal)
        {
            for (label& regioni : send)
            {
                regioni = updateLookup[regioni];
            }
        }

        // Send back (into recvNonLocal)
        Pstream::exchange<labelList, label>
        (
            sendLocal,
            recvNonLocal
        );
    }


    // Now recvNonLocal and sendNonLocal contain matched pairs with
    // sendNonLocal being the non-compact region and recvNonLocal being
    // the compact region.
    //
    // Insert these into the local compaction map.

    forAll(recvNonLocal, proci)
    {
        const labelList& send = sendNonLocal[proci];
        const labelList& recv = recvNonLocal[proci];

        forAll(send, i)
        {
            updateLookup.insert(send[i], recv[i]);
        }
    }


    // Now renumber the localToGlobal to use the final compact global values
    inplaceMapValue(updateLookup, localToGlobal);


    // Can now finally use localToGlobal to renumber cellRegion

    forAll(cellRegion, celli)
    {
        cellRegion[celli] = localToGlobal[cellRegion[celli]];
    }

    if (debug)
    {
        Info<<"regionSplit::reduceRegions = "
            << double(timing.elapsed()) << "s\n";
    }

    return globalCompactPtr;
}


Henry's avatar
Henry committed
813
// ************************************************************************* //