34 const label fineLevelIndex
37 const lduMesh& fineMesh = meshLevel(fineLevelIndex);
46 const labelField& restrictMap = restrictAddressing(fineLevelIndex);
48 if (
min(restrictMap) == -1)
50 FatalErrorIn(
"GAMGAgglomeration::agglomerateLduAddressing")
54 if (restrictMap.
size() != fineMeshAddr.
size())
58 "GAMGAgglomeration::agglomerateLduAddressing" 59 "(const label fineLevelIndex)" 60 ) <<
"restrict map does not correspond to fine level. " <<
endl 61 <<
" Sizes: restrictMap: " << restrictMap.
size()
62 <<
" nEqns: " << fineMeshAddr.
size()
68 const label nCoarseCells = nCells_[fineLevelIndex];
79 labelList cCellFaces(maxNnbrs*nCoarseCells);
82 faceRestrictAddressing_.set(fineLevelIndex,
new labelList(nFineFaces));
83 labelList& faceRestrictAddr = faceRestrictAddressing_[fineLevelIndex];
89 label& nCoarseFaces = nFaces_[fineLevelIndex];
93 forAll(upperAddr, fineFacei)
95 label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
96 label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
98 if (rmUpperAddr == rmLowerAddr)
103 faceRestrictAddr[fineFacei] = -(rmUpperAddr + 1);
109 label cOwn = rmUpperAddr;
110 label cNei = rmLowerAddr;
113 if (rmUpperAddr > rmLowerAddr)
120 label* ccFaces = &cCellFaces[maxNnbrs*cOwn];
122 bool nbrFound =
false;
123 label& ccnFaces = cCellnFaces[cOwn];
125 for (
int i=0; i<ccnFaces; i++)
127 if (initCoarseNeighb[ccFaces[i]] == cNei)
130 faceRestrictAddr[fineFacei] = ccFaces[i];
137 if (ccnFaces >= maxNnbrs)
139 label oldMaxNnbrs = maxNnbrs;
142 cCellFaces.
setSize(maxNnbrs*nCoarseCells);
146 label* oldCcNbrs = &cCellFaces[oldMaxNnbrs*i];
147 label* newCcNbrs = &cCellFaces[maxNnbrs*i];
149 for (
int j=0; j<cCellnFaces[i]; j++)
151 newCcNbrs[j] = oldCcNbrs[j];
155 ccFaces = &cCellFaces[maxNnbrs*cOwn];
158 ccFaces[ccnFaces] = nCoarseFaces;
159 initCoarseNeighb[nCoarseFaces] = cNei;
160 faceRestrictAddr[fineFacei] = nCoarseFaces;
177 label coarseFacei = 0;
181 label* cFaces = &cCellFaces[maxNnbrs*cci];
182 label ccnFaces = cCellnFaces[cci];
184 for (
int i=0; i<ccnFaces; i++)
186 coarseOwner[coarseFacei] = cci;
187 coarseNeighbour[coarseFacei] = initCoarseNeighb[cFaces[i]];
188 coarseFaceMap[cFaces[i]] = coarseFacei;
193 forAll(faceRestrictAddr, fineFacei)
195 if (faceRestrictAddr[fineFacei] >= 0)
197 faceRestrictAddr[fineFacei] =
198 coarseFaceMap[faceRestrictAddr[fineFacei]];
204 faceFlipMap_.set(fineLevelIndex,
new boolList(nFineFaces,
false));
205 boolList& faceFlipMap = faceFlipMap_[fineLevelIndex];
209 label nDissapear = 0;
211 forAll(faceRestrictAddr, fineFacei)
213 label coarseFacei = faceRestrictAddr[fineFacei];
215 if (coarseFacei >= 0)
218 label cOwn = coarseOwner[coarseFacei];
219 label cNei = coarseNeighbour[coarseFacei];
221 label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
222 label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
224 if (cOwn == rmUpperAddr && cNei == rmLowerAddr)
226 faceFlipMap[fineFacei] =
true;
229 else if (cOwn == rmLowerAddr && cNei == rmUpperAddr)
235 FatalErrorIn(
"GAMGAgglomeration::agglomerateLduAddressing(..)")
237 <<
" fineFacei:" << fineFacei
238 <<
" rmUpperAddr:" << rmUpperAddr
239 <<
" rmLowerAddr:" << rmLowerAddr
240 <<
" coarseFacei:" << coarseFacei
266 nPatchFaces_.set(fineLevelIndex,
new labelList(fineInterfaces.
size(), 0));
267 labelList& nPatchFaces = nPatchFaces_[fineLevelIndex];
269 patchFaceRestrictAddressing_.set
275 patchFaceRestrictAddressing_[fineLevelIndex];
279 forAll(fineInterfaces, inti)
281 if (fineInterfaces.
set(inti))
283 fineInterfaces[inti].initInternalFieldTransfer
285 Pstream::nonBlocking,
291 if (Pstream::parRun())
293 Pstream::waitRequests();
313 forAll(fineInterfaces, inti)
315 if (fineInterfaces.
set(inti))
323 meshLevels_[fineLevelIndex].rawInterfaces(),
324 fineInterfaces[inti],
325 fineInterfaces[inti].interfaceInternalField(restrictMap),
326 fineInterfaces[inti].internalFieldTransfer
328 Pstream::nonBlocking,
336 nPatchFaces[inti] = coarseInterfaces[inti].faceCells().
size();
337 patchFineToCoarse[inti] = refCast<const GAMGInterface>
339 coarseInterfaces[inti]
340 ).faceRestrictAddressing();
344 meshLevels_[fineLevelIndex].addInterfaces
347 lduPrimitiveMesh::nonBlockingSchedule<processorGAMGInterface>
356 Pout<<
"GAMGAgglomeration :" 357 <<
" agglomerated level " << fineLevelIndex
358 <<
" from nCells:" << fineMeshAddr.
size()
359 <<
" nFaces:" << upperAddr.
size()
360 <<
" to nCells:" << nCoarseCells
361 <<
" nFaces:" << nCoarseFaces
369 const label meshComm,
372 const label allMeshComm,
374 const label levelIndex
377 const lduMesh& myMesh = meshLevels_[levelIndex-1];
380 label oldWarn = UPstream::warnComm;
381 UPstream::warnComm = meshComm;
384 procAgglomMap_.set(levelIndex,
new labelList(procAgglomMap));
385 agglomProcIDs_.set(levelIndex,
new labelList(procIDs));
386 procCommunicator_[levelIndex] = allMeshComm;
390 procCellOffsets_.set(levelIndex,
new labelList(0));
398 lduPrimitiveMesh::gather(meshComm, myMesh, procIDs, otherMeshes);
400 if (Pstream::myProcNo(meshComm) == procIDs[0])
417 procCellOffsets_[levelIndex],
419 procFaceMap_[levelIndex],
420 procBoundaryMap_[levelIndex],
421 procBoundaryFaceMap_[levelIndex]
430 procAgglomerateRestrictAddressing
437 if (Pstream::myProcNo(meshComm) != procIDs[0])
439 clearLevel(levelIndex);
442 UPstream::warnComm = oldWarn;
450 const label levelIndex
459 restrictAddressing_[levelIndex].size(),
468 offsets[i+1] = offsets[i] + nFineCells[i];
490 restrictAddressing_[levelIndex],
491 procRestrictAddressing,
498 if (Pstream::myProcNo(comm) == procIDs[0])
502 coarseCellOffsets[0] = 0;
505 coarseCellOffsets[i+1] = coarseCellOffsets[i]+nCoarseCells[i];
509 nCells_[levelIndex] = coarseCellOffsets.
last();
512 for (
label procI = 1; procI < procIDs.
size(); procI++)
516 procRestrictAddressing,
517 offsets[procI+1]-offsets[procI],
522 procSlot[i] += coarseCellOffsets[procI];
526 restrictAddressing_[levelIndex].transfer(procRestrictAddressing);
533 label prevLevel = curLevel - 1;
550 forAll(prevFaceResAddr, i)
552 if (prevFaceResAddr[i] >= 0)
554 label fineFaceI = prevFaceResAddr[i];
555 prevFaceResAddr[i] = curFaceResAddr[fineFaceI];
556 prevFaceFlipMap[i] = curFaceFlipMap[fineFaceI];
560 label fineFaceI = -prevFaceResAddr[i] - 1;
561 prevFaceResAddr[i] = -curResAddr[fineFaceI] - 1;
562 prevFaceFlipMap[i] = curFaceFlipMap[fineFaceI];
572 prevResAddr[i] = curResAddr[prevResAddr[i]];
580 forAll(prevPatchFaceResAddr, inti)
582 const labelList& curResAddr = curPatchFaceResAddr[inti];
583 labelList& prevResAddr = prevPatchFaceResAddr[inti];
586 label fineFaceI = prevResAddr[i];
587 prevResAddr[i] = curResAddr[fineFaceI];
605 forAll(prevInterLevel, inti)
607 if (prevInterLevel.
set(inti))
686 forAll(procAgglomMap, procI)
688 label coarseI = procAgglomMap[procI];
691 if (fnd == agglomToMaster.
end())
693 agglomToMaster.insert(coarseI, procI);
697 fnd() =
min(fnd(), procI);
701 masterProcs.
setSize(agglomToMaster.size());
704 masterProcs[iter.key()] = iter();
710 label myAgglom = procAgglomMap[myProcID];
714 agglomProcIDs =
findIndices(procAgglomMap, myAgglom);
719 agglomToMaster[myAgglom]
721 Swap(agglomProcIDs[0], agglomProcIDs[index]);
label size() const
Return number of equations.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
void combineLevels(const label curLevel)
Combine a level with the previous one.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
static void calculateRegionMaster(const label comm, const labelList &procAgglomMap, labelList &masterProcs, List< label > &agglomProcIDs)
Given fine to coarse processor map determine:
virtual label comm() const =0
Return communicator used for parallel communication.
PtrList< boolList > faceFlipMap_
Face flip: for faces mapped to internal faces stores whether.
PtrList< lduPrimitiveMesh > meshLevels_
Hierarchy of mesh addressing.
T & last()
Return the last element of the list.
List< labelListList > labelListListList
A List of labelListList.
void procAgglomerateRestrictAddressing(const label comm, const labelList &procIDs, const label levelIndex)
Collect and combine basic restriction addressing:
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
PtrList< labelList > nPatchFaces_
The number of (coarse) patch faces in each level.
PtrList< labelListList > patchFaceRestrictAddressing_
Patch-local face restriction addressing array.
void combine(const GAMGInterface &)
Merge the next level with this level.
label size() const
Return the number of elements in the UList.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
void procAgglomerateLduAddressing(const label comm, const labelList &procAgglomMap, const labelList &procIDs, const label allMeshComm, const label levelIndex)
Collect and combine processor meshes into allMesh.
PtrList< labelList > faceRestrictAddressing_
Face restriction addressing array.
errorManip< error > abort(error &err)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
bool set(const label) const
Is element set.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
#define forAllReverse(list, i)
label size() const
Return the number of elements in the UPtrList.
List< label > labelList
A List of labels.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
Abstract base class for GAMG agglomerated interfaces.
A List obtained as a section of another List.
labelList nCells_
The number of cells in each level.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
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::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
labelList nFaces_
The number of (coarse) faces in each level.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
List< labelList > labelListList
A List of labelList.
PtrList< labelField > restrictAddressing_
Cell restriction addressing array.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurences of given element. Linear search.
void agglomerateLduAddressing(const label fineLevelIndex)
Assemble coarse mesh addressing.
Simplest contrete lduMesh which stores the addressing needed by lduMatrix.
prefixOSstream Pout(cout,"Pout")
List< bool > boolList
Bool container classes.