38 const label fineLevelIndex
47 const label nFineFaces = upperAddr.
size();
52 if (
min(restrictMap) == -1)
58 if (restrictMap.
size() != fineMeshAddr.
size())
61 <<
"restrict map does not correspond to fine level. " <<
endl
62 <<
" Sizes: restrictMap: " << restrictMap.
size()
63 <<
" nEqns: " << fineMeshAddr.
size()
69 const label nCoarseCells =
nCells_[fineLevelIndex];
80 labelList cCellFaces(maxNnbrs*nCoarseCells);
90 label& nCoarseFaces =
nFaces_[fineLevelIndex];
94 forAll(upperAddr, fineFacei)
96 label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
97 label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
99 if (rmUpperAddr == rmLowerAddr)
104 faceRestrictAddr[fineFacei] = -(rmUpperAddr + 1);
110 label cOwn = rmUpperAddr;
111 label cNei = rmLowerAddr;
114 if (rmUpperAddr > rmLowerAddr)
121 label* ccFaces = &cCellFaces[maxNnbrs*cOwn];
123 bool nbrFound =
false;
124 label& ccnFaces = cCellnFaces[cOwn];
126 for (
int i=0; i<ccnFaces; i++)
128 if (initCoarseNeighb[ccFaces[i]] == cNei)
131 faceRestrictAddr[fineFacei] = ccFaces[i];
138 if (ccnFaces >= maxNnbrs)
140 label oldMaxNnbrs = maxNnbrs;
143 cCellFaces.
setSize(maxNnbrs*nCoarseCells);
147 label* oldCcNbrs = &cCellFaces[oldMaxNnbrs*i];
148 label* newCcNbrs = &cCellFaces[maxNnbrs*i];
150 for (
int j=0; j<cCellnFaces[i]; j++)
152 newCcNbrs[j] = oldCcNbrs[j];
156 ccFaces = &cCellFaces[maxNnbrs*cOwn];
159 ccFaces[ccnFaces] = nCoarseFaces;
160 initCoarseNeighb[nCoarseFaces] = cNei;
161 faceRestrictAddr[fineFacei] = nCoarseFaces;
178 label coarseFacei = 0;
182 label* cFaces = &cCellFaces[maxNnbrs*cci];
183 label ccnFaces = cCellnFaces[cci];
185 for (
int i=0; i<ccnFaces; i++)
187 coarseOwner[coarseFacei] = cci;
188 coarseNeighbour[coarseFacei] = initCoarseNeighb[cFaces[i]];
189 coarseFaceMap[cFaces[i]] = coarseFacei;
194 forAll(faceRestrictAddr, fineFacei)
196 if (faceRestrictAddr[fineFacei] >= 0)
198 faceRestrictAddr[fineFacei] =
199 coarseFaceMap[faceRestrictAddr[fineFacei]];
209 forAll(faceRestrictAddr, fineFacei)
211 label coarseFacei = faceRestrictAddr[fineFacei];
213 if (coarseFacei >= 0)
216 label cOwn = coarseOwner[coarseFacei];
217 label cNei = coarseNeighbour[coarseFacei];
219 label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
220 label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
222 if (cOwn == rmUpperAddr && cNei == rmLowerAddr)
226 else if (cOwn == rmLowerAddr && cNei == rmUpperAddr)
234 <<
" fineFacei:" << fineFacei
235 <<
" rmUpperAddr:" << rmUpperAddr
236 <<
" rmLowerAddr:" << rmLowerAddr
237 <<
" coarseFacei:" << coarseFacei
280 forAll(fineInterfaces, inti)
282 if (fineInterfaces.
set(inti))
284 if (fineLevelIndex == 0)
286 fineInterfaces[inti].initInternalFieldTransfer
295 fineInterfaces[inti].initInternalFieldTransfer
326 forAll(fineInterfaces, inti)
328 if (fineInterfaces.
set(inti))
334 if (fineLevelIndex == 0)
336 restrictMapInternalField =
337 fineInterfaces[inti].interfaceInternalField
345 restrictMapInternalField =
346 fineInterfaces[inti].interfaceInternalField
353 fineInterfaces[inti].internalFieldTransfer
366 fineInterfaces[inti],
367 restrictMapInternalField(),
368 nbrRestrictMapInternalField(),
396 patchFineToCoarse[inti] = refCast<const GAMGInterface>
398 coarseInterfaces[inti]
399 ).faceRestrictAddressing();
406 lduPrimitiveMesh::nonBlockingSchedule<processorGAMGInterface>
415 Pout<<
"GAMGAgglomeration :"
416 <<
" agglomerated level " << fineLevelIndex
417 <<
" from nCells:" << fineMeshAddr.
size()
418 <<
" nFaces:" << upperAddr.
size()
419 <<
" to nCells:" << nCoarseCells
420 <<
" nFaces:" << nCoarseFaces
428 const label meshComm,
431 const label allMeshComm,
433 const label levelIndex
436 const lduMesh& myMesh = meshLevels_[levelIndex-1];
439 procAgglomMap_.set(levelIndex,
new labelList(procAgglomMap));
440 agglomProcIDs_.set(levelIndex,
new labelList(procIDs));
441 procCommunicator_[levelIndex] = allMeshComm;
445 procCellOffsets_.set(levelIndex,
new labelList(0));
472 procCellOffsets_[levelIndex],
474 procFaceMap_[levelIndex],
475 procBoundaryMap_[levelIndex],
476 procBoundaryFaceMap_[levelIndex]
485 procAgglomerateRestrictAddressing
494 clearLevel(levelIndex);
503 const label levelIndex
512 restrictAddressing_[levelIndex].size(),
518 labelList fineOffsets(globalIndex::calcOffsets(nFineCells));
532 labelList coarseOffsets(globalIndex::calcOffsets(nCoarseCells));
541 restrictAddressing_[levelIndex],
542 procRestrictAddressing,
551 nCells_[levelIndex] = coarseOffsets.
last();
554 for (label proci = 1; proci < procIDs.
size(); ++proci)
558 procRestrictAddressing,
559 fineOffsets[proci+1]-fineOffsets[proci],
566 procSlot[i] += coarseOffsets[proci];
570 restrictAddressing_[levelIndex].
transfer(procRestrictAddressing);
577 label prevLevel = curLevel - 1;
580 nCells_[prevLevel] = nCells_[curLevel];
581 nFaces_[prevLevel] = nFaces_[curLevel];
586 const labelList& curResAddr = restrictAddressing_[curLevel];
587 labelList& prevResAddr = restrictAddressing_[prevLevel];
589 const labelList& curFaceResAddr = faceRestrictAddressing_[curLevel];
590 labelList& prevFaceResAddr = faceRestrictAddressing_[prevLevel];
591 const boolList& curFaceFlipMap = faceFlipMap_[curLevel];
592 boolList& prevFaceFlipMap = faceFlipMap_[prevLevel];
594 forAll(prevFaceResAddr, i)
596 if (prevFaceResAddr[i] >= 0)
598 label fineFacei = prevFaceResAddr[i];
599 prevFaceResAddr[i] = curFaceResAddr[fineFacei];
600 prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
604 label fineFacei = -prevFaceResAddr[i] - 1;
605 prevFaceResAddr[i] = -curResAddr[fineFacei] - 1;
606 prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
611 faceRestrictAddressing_.
set(curLevel,
nullptr);
612 faceFlipMap_.set(curLevel,
nullptr);
616 prevResAddr[i] = curResAddr[prevResAddr[i]];
620 patchFaceRestrictAddressing_[curLevel];
622 patchFaceRestrictAddressing_[prevLevel];
624 forAll(prevPatchFaceResAddr, inti)
626 const labelList& curResAddr = curPatchFaceResAddr[inti];
627 labelList& prevResAddr = prevPatchFaceResAddr[inti];
630 label fineFacei = prevResAddr[i];
631 prevResAddr[i] = curResAddr[fineFacei];
636 restrictAddressing_.
set(curLevel,
nullptr);
639 nPatchFaces_[prevLevel] = nPatchFaces_[curLevel];
645 meshLevels_[curLevel].rawInterfaces();
647 meshLevels_[prevLevel].rawInterfaces();
649 forAll(prevInterLevel, inti)
651 if (prevInterLevel.
set(inti))
670 meshLevels_.set(prevLevel, meshLevels_.set(curLevel,
nullptr));
685 forAll(procAgglomMap, proci)
687 const label coarsei = procAgglomMap[proci];
689 auto iter = agglomToMaster.
find(coarsei);
692 iter.val() =
min(iter.val(), proci);
696 agglomToMaster.
insert(coarsei, proci);
703 masterProcs[iter.key()] = iter.val();
709 label myAgglom = procAgglomMap[myProcID];
713 agglomProcIDs =
findIndices(procAgglomMap, myAgglom);
717 agglomProcIDs.
find(agglomToMaster[myAgglom]);
719 std::swap(agglomProcIDs[0], agglomProcIDs[index]);
const labelList & nPatchFaces(const label leveli) const
void procAgglomerateRestrictAddressing(const label comm, const labelList &procIDs, const label levelIndex)
Collect and combine basic restriction addressing:
void agglomerateLduAddressing(const label fineLevelIndex)
Assemble coarse mesh addressing.
static void calculateRegionMaster(const label comm, const labelList &procAgglomMap, labelList &masterProcs, List< label > &agglomProcIDs)
Given fine to coarse processor map determine:
PtrList< labelListList > patchFaceRestrictAddressing_
Patch-local face restriction addressing array.
PtrList< boolList > faceFlipMap_
Face flip: for faces mapped to internal faces stores whether.
PtrList< labelList > nPatchFaces_
The number of (coarse) patch faces in each level.
void procAgglomerateLduAddressing(const label comm, const labelList &procAgglomMap, const labelList &procIDs, const label allMeshComm, const label levelIndex)
Collect and combine processor meshes into allMesh:
labelList nFaces_
The number of (coarse) faces in each level.
const boolList & faceFlipMap(const label leveli) const
Return face flip map of given level.
PtrList< lduPrimitiveMesh > meshLevels_
Hierarchy of mesh addressing.
labelList nCells_
The number of cells in each level.
void combineLevels(const label curLevel)
Combine a level with the previous one.
PtrList< labelList > faceRestrictAddressing_
Face restriction addressing array.
const lduInterfacePtrsList & interfaceLevel(const label leveli) const
Return LDU interface addressing of given level.
const labelField & restrictAddressing(const label leveli) const
Return cell restrict addressing of given level.
const lduMesh & meshLevel(const label leveli) const
Return LDU mesh of given level.
Abstract base class for GAMG agglomerated interfaces.
void combine(const GAMGInterface &)
Merge the next level with this level.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
void transfer(List< T > &list)
void setSize(const label n)
Alias for resize()
A HashTable to objects of type <T> with a label key.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
A List obtained as a section of another List.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
@ nonBlocking
"nonBlocking"
static int & msgType() noexcept
Message tag of standard messages.
static label nRequests()
Get number of outstanding requests.
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
static bool & parRun() noexcept
Test if this a parallel run.
const T * set(const label i) const
label size() const noexcept
The number of elements in the list.
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
static void gatherValues(const label comm, const ProcIDsContainer &procIDs, const Type &localValue, List< Type > &allValues, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Which processor does global id come from?
The class contains the addressing required by the lduMatrix: upper, lower and losort.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
label size() const
Return number of equations.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
virtual label comm() const =0
Return communicator used for parallel communication.
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
static void gather(const label comm, const lduMesh &mesh, const labelList &procIDs, PtrList< lduPrimitiveMesh > &otherMeshes)
Gather meshes from other processors onto procIDs[0].
int myProcNo() const noexcept
Return processor number.
A class for managing temporary objects.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< labelList > labelListList
A List of labelList.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
List< labelListList > labelListListList
A List of labelListList.
errorManip< error > abort(error &err)
List< bool > boolList
A List of bools.
static constexpr const zero Zero
Global zero (0)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.