34 const label fineLevelIndex
48 if (
min(restrictMap) == -1)
54 if (restrictMap.
size() != fineMeshAddr.
size())
57 <<
"restrict map does not correspond to fine level. " <<
endl
58 <<
" Sizes: restrictMap: " << restrictMap.
size()
59 <<
" nEqns: " << fineMeshAddr.
size()
76 labelList cCellFaces(maxNnbrs*nCoarseCells);
90 forAll(upperAddr, fineFacei)
92 label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
93 label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
95 if (rmUpperAddr == rmLowerAddr)
100 faceRestrictAddr[fineFacei] = -(rmUpperAddr + 1);
106 label cOwn = rmUpperAddr;
107 label cNei = rmLowerAddr;
110 if (rmUpperAddr > rmLowerAddr)
117 label* ccFaces = &cCellFaces[maxNnbrs*cOwn];
119 bool nbrFound =
false;
120 label& ccnFaces = cCellnFaces[cOwn];
122 for (
int i=0; i<ccnFaces; i++)
124 if (initCoarseNeighb[ccFaces[i]] == cNei)
127 faceRestrictAddr[fineFacei] = ccFaces[i];
134 if (ccnFaces >= maxNnbrs)
136 label oldMaxNnbrs = maxNnbrs;
139 cCellFaces.
setSize(maxNnbrs*nCoarseCells);
143 label* oldCcNbrs = &cCellFaces[oldMaxNnbrs*i];
144 label* newCcNbrs = &cCellFaces[maxNnbrs*i];
146 for (
int j=0; j<cCellnFaces[i]; j++)
148 newCcNbrs[j] = oldCcNbrs[j];
152 ccFaces = &cCellFaces[maxNnbrs*cOwn];
155 ccFaces[ccnFaces] = nCoarseFaces;
156 initCoarseNeighb[nCoarseFaces] = cNei;
157 faceRestrictAddr[fineFacei] = nCoarseFaces;
174 label coarseFacei = 0;
178 label* cFaces = &cCellFaces[maxNnbrs*cci];
179 label ccnFaces = cCellnFaces[cci];
181 for (
int i=0; i<ccnFaces; i++)
183 coarseOwner[coarseFacei] = cci;
184 coarseNeighbour[coarseFacei] = initCoarseNeighb[cFaces[i]];
185 coarseFaceMap[cFaces[i]] = coarseFacei;
190 forAll(faceRestrictAddr, fineFacei)
192 if (faceRestrictAddr[fineFacei] >= 0)
194 faceRestrictAddr[fineFacei] =
195 coarseFaceMap[faceRestrictAddr[fineFacei]];
205 forAll(faceRestrictAddr, fineFacei)
207 label coarseFacei = faceRestrictAddr[fineFacei];
209 if (coarseFacei >= 0)
212 label cOwn = coarseOwner[coarseFacei];
213 label cNei = coarseNeighbour[coarseFacei];
215 label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
216 label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
218 if (cOwn == rmUpperAddr && cNei == rmLowerAddr)
222 else if (cOwn == rmLowerAddr && cNei == rmUpperAddr)
230 <<
" fineFacei:" << fineFacei
231 <<
" rmUpperAddr:" << rmUpperAddr
232 <<
" rmLowerAddr:" << rmLowerAddr
233 <<
" coarseFacei:" << coarseFacei
268 forAll(fineInterfaces, inti)
270 if (fineInterfaces.
set(inti))
272 fineInterfaces[inti].initInternalFieldTransfer
302 forAll(fineInterfaces, inti)
304 if (fineInterfaces.
set(inti))
313 fineInterfaces[inti],
314 fineInterfaces[inti].interfaceInternalField(restrictMap),
315 fineInterfaces[inti].internalFieldTransfer
326 patchFineToCoarse[inti] = refCast<const GAMGInterface>
328 coarseInterfaces[inti]
329 ).faceRestrictAddressing();
336 lduPrimitiveMesh::nonBlockingSchedule<processorGAMGInterface>
345 Pout<<
"GAMGAgglomeration :"
346 <<
" agglomerated level " << fineLevelIndex
347 <<
" from nCells:" << fineMeshAddr.
size()
348 <<
" nFaces:" << upperAddr.
size()
349 <<
" to nCells:" << nCoarseCells
350 <<
" nFaces:" << nCoarseFaces
358 const label meshComm,
361 const label allMeshComm,
363 const label levelIndex
366 const lduMesh& myMesh = meshLevels_[levelIndex-1];
369 procAgglomMap_.set(levelIndex,
new labelList(procAgglomMap));
370 agglomProcIndices_.set(levelIndex,
new labelList(procIDs));
371 procCommunicator_[levelIndex] = allMeshComm;
375 procCellOffsets_.set(levelIndex,
new labelList(0));
402 procCellOffsets_[levelIndex],
404 procFaceMap_[levelIndex],
405 procBoundaryMap_[levelIndex],
406 procBoundaryFaceMap_[levelIndex]
415 procAgglomerateRestrictAddressing
424 clearLevel(levelIndex);
433 const label levelIndex
442 restrictAddressing_[levelIndex].size(),
451 offsets[i+1] = offsets[i] + nFineCells[i];
473 restrictAddressing_[levelIndex],
474 procRestrictAddressing,
485 coarseCellOffsets[0] = 0;
488 coarseCellOffsets[i+1] = coarseCellOffsets[i]+nCoarseCells[i];
492 nCells_[levelIndex] = coarseCellOffsets.
last();
495 for (
label proci = 1; proci < procIDs.
size(); proci++)
499 procRestrictAddressing,
500 offsets[proci+1]-offsets[proci],
505 procSlot[i] += coarseCellOffsets[proci];
509 restrictAddressing_[levelIndex].
transfer(procRestrictAddressing);
516 label prevLevel = curLevel - 1;
519 nCells_[prevLevel] = nCells_[curLevel];
520 nFaces_[prevLevel] = nFaces_[curLevel];
525 const labelList& curResAddr = restrictAddressing_[curLevel];
526 labelList& prevResAddr = restrictAddressing_[prevLevel];
528 const labelList& curFaceResAddr = faceRestrictAddressing_[curLevel];
529 labelList& prevFaceResAddr = faceRestrictAddressing_[prevLevel];
530 const boolList& curFaceFlipMap = faceFlipMap_[curLevel];
531 boolList& prevFaceFlipMap = faceFlipMap_[prevLevel];
533 forAll(prevFaceResAddr, i)
535 if (prevFaceResAddr[i] >= 0)
537 label fineFacei = prevFaceResAddr[i];
538 prevFaceResAddr[i] = curFaceResAddr[fineFacei];
539 prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
543 label fineFacei = -prevFaceResAddr[i] - 1;
544 prevFaceResAddr[i] = -curResAddr[fineFacei] - 1;
545 prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
550 faceRestrictAddressing_.set(curLevel,
nullptr);
551 faceFlipMap_.set(curLevel,
nullptr);
555 prevResAddr[i] = curResAddr[prevResAddr[i]];
559 patchFaceRestrictAddressing_[curLevel];
561 patchFaceRestrictAddressing_[prevLevel];
563 forAll(prevPatchFaceResAddr, inti)
565 const labelList& curResAddr = curPatchFaceResAddr[inti];
566 labelList& prevResAddr = prevPatchFaceResAddr[inti];
569 label fineFacei = prevResAddr[i];
570 prevResAddr[i] = curResAddr[fineFacei];
575 restrictAddressing_.set(curLevel,
nullptr);
578 nPatchFaces_[prevLevel] = nPatchFaces_[curLevel];
584 meshLevels_[curLevel].rawInterfaces();
586 meshLevels_[prevLevel].rawInterfaces();
588 forAll(prevInterLevel, inti)
590 if (prevInterLevel.
set(inti))
609 meshLevels_.set(prevLevel, meshLevels_.set(curLevel,
nullptr));
669 forAll(procAgglomMap, proci)
671 label coarseI = procAgglomMap[proci];
674 if (fnd == agglomToMaster.
end())
676 agglomToMaster.
insert(coarseI, proci);
680 fnd() =
min(fnd(), proci);
687 masterProcs[iter.key()] = iter();
693 label myAgglom = procAgglomMap[myProcID];
697 agglomProcIDs =
findIndices(procAgglomMap, myAgglom);
702 agglomToMaster[myAgglom]
704 Swap(agglomProcIDs[0], agglomProcIDs[index]);
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
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:
const boolList & faceFlipMap(const label leveli) const
Return face flip map of given level.
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.
PtrList< lduPrimitiveMesh > meshLevels_
Hierarchy of mesh addressing.
labelList nCells_
The number of cells in each level.
const labelList & nPatchFaces(const label leveli) const
Return number of coarse patch faces (before processor.
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.
static autoPtr< GAMGInterface > New(const label index, const lduInterfacePtrsList &coarseInterfaces, const lduInterface &fineInterface, const labelField &localRestrictAddressing, const labelField &neighbourRestrictAddressing, const label fineLevelIndex, const label coarseComm)
Return a pointer to a new interface created on freestore given.
label size() const
Return number of elements in table.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
A List obtained as a section of another List.
label size() const
Return the number of elements in the UList.
T & last()
Return the last element of the list.
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
static bool & parRun()
Is this a parallel run?
static int & msgType()
Message tag of standard messages.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
bool set(const label) const
Is element set.
label size() const
Return the number of elements in the UPtrList.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
static void gather(const labelUList &offsets, const label comm, const labelList &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
The class contains the addressing required by the lduMatrix: upper, lower and losort.
label size() const
Return number of equations.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
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 which 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].
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
errorManip< error > abort(error &err)
List< bool > boolList
Bool container classes.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< labelList > labelListList
A List of labelList.
List< labelListList > labelListListList
A List of labelListList.
prefixOSstream Pout(cout, "Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable