45 void Foam::domainDecomposition::mark
54 label pointi = zoneElems[i];
56 if (elementToZone[pointi] == -1)
59 elementToZone[pointi] = zoneI;
61 else if (elementToZone[pointi] >= 0)
64 elementToZone[pointi] = -2;
75 const fileName& dictFile
79 facesInstancePointsPtr_
101 decompositionModel::
New 105 ).
lookup(
"numberOfSubdomains")
110 procPointAddressing_(nProcs_),
111 procFaceAddressing_(nProcs_),
112 procCellAddressing_(nProcs_),
113 procPatchSize_(nProcs_),
114 procPatchStartIndex_(nProcs_),
115 procNeighbourProcessors_(nProcs_),
116 procProcessorPatchSize_(nProcs_),
117 procProcessorPatchStartIndex_(nProcs_),
118 procProcessorPatchSubPatchIDs_(nProcs_),
119 procProcessorPatchSubPatchStarts_(nProcs_)
139 Info<<
"\nConstructing processor meshes" <<
endl;
152 forAll(pointZones(), zoneI)
154 mark(pointZones()[zoneI], zoneI, pointToZone);
158 labelList faceToZone(faces().size(), -1);
160 forAll(faceZones(), zoneI)
162 mark(faceZones()[zoneI], zoneI, faceToZone);
168 forAll(cellZones(), zoneI)
170 mark(cellZones()[zoneI], zoneI, cellToZone);
174 PtrList<const cellSet> cellSets;
175 PtrList<const faceSet> faceSets;
176 PtrList<const pointSet> pointSets;
180 IOobjectList objects(*
this, facesInstance(),
"polyMesh/sets");
182 IOobjectList cSets(objects.lookupClass(cellSet::typeName));
185 cellSets.append(
new cellSet(*iter()));
189 IOobjectList fSets(objects.lookupClass(faceSet::typeName));
192 faceSets.append(
new faceSet(*iter()));
196 IOobjectList pSets(objects.lookupClass(pointSet::typeName));
199 pointSets.append(
new pointSet(*iter()));
206 hexRef8Data baseMeshData
222 label maxProcCells = 0;
223 label totProcFaces = 0;
224 label maxProcPatches = 0;
225 label totProcPatches = 0;
226 label maxProcFaces = 0;
230 for (
label proci = 0; proci < nProcs_; proci++)
233 const labelList& curPointLabels = procPointAddressing_[proci];
241 forAll(curPointLabels, pointi)
243 procPoints[pointi] = meshPoints[curPointLabels[pointi]];
245 pointLookup[curPointLabels[pointi]] = pointi;
249 const labelList& curFaceLabels = procFaceAddressing_[proci];
251 const faceList& meshFaces = faces();
255 faceList procFaces(curFaceLabels.size());
257 forAll(curFaceLabels, facei)
262 label curF =
mag(curFaceLabels[facei]) - 1;
264 faceLookup[curF] = facei;
269 if (curFaceLabels[facei] >= 0)
272 origFaceLabels = meshFaces[curF];
276 origFaceLabels = meshFaces[curF].reverseFace();
280 face& procFaceLabels = procFaces[facei];
282 procFaceLabels.
setSize(origFaceLabels.size());
284 forAll(origFaceLabels, pointi)
286 procFaceLabels[pointi] = pointLookup[origFaceLabels[pointi]];
291 const labelList& curCellLabels = procCellAddressing_[proci];
295 cellList procCells(curCellLabels.size());
297 forAll(curCellLabels, celli)
299 const labelList& origCellLabels = meshCells[curCellLabels[celli]];
301 cell& curCell = procCells[celli];
303 curCell.
setSize(origCellLabels.size());
305 forAll(origCellLabels, cellFacei)
307 curCell[cellFacei] = faceLookup[origCellLabels[cellFacei]];
313 fileName processorCasePath
315 time().caseName()/fileName(word(
"processor") +
Foam::name(proci))
327 processorDb.setTime(time());
339 autoPtr<polyMesh> procMeshPtr;
341 if (facesInstancePointsPtr_.valid())
346 facesInstancePointsPtr_(),
384 polyMesh& procMesh = procMeshPtr();
388 const labelList& curPatchSizes = procPatchSize_[proci];
390 const labelList& curPatchStarts = procPatchStartIndex_[proci];
392 const labelList& curNeighbourProcessors =
393 procNeighbourProcessors_[proci];
395 const labelList& curProcessorPatchSizes =
396 procProcessorPatchSize_[proci];
398 const labelList& curProcessorPatchStarts =
399 procProcessorPatchStartIndex_[proci];
402 procProcessorPatchSubPatchIDs_[proci];
405 procProcessorPatchSubPatchStarts_[proci];
411 label nInterProcPatches = 0;
412 forAll(curSubPatchIDs, procPatchi)
414 nInterProcPatches += curSubPatchIDs[procPatchi].size();
417 List<polyPatch*> procPatches
419 curPatchSizes.size() + nInterProcPatches,
420 reinterpret_cast<polyPatch*
>(0)
425 forAll(curPatchSizes, patchi)
429 const polyPatch& meshPatch = meshPatches[
patchi];
431 fvFieldDecomposer::patchFieldDecomposer patchMapper
436 curPatchSizes[patchi],
437 curPatchStarts[patchi]
443 procPatches[
nPatches] = meshPatch.clone
445 procMesh.boundaryMesh(),
447 patchMapper.directAddressing(),
454 forAll(curProcessorPatchSizes, procPatchi)
456 const labelList& subPatchID = curSubPatchIDs[procPatchi];
457 const labelList& subStarts = curSubStarts[procPatchi];
459 label curStart = curProcessorPatchStarts[procPatchi];
465 i < subPatchID.size()-1
466 ? subStarts[i+1] - subStarts[i]
467 : curProcessorPatchSizes[procPatchi] - subStarts[i]
470 if (subPatchID[i] == -1)
474 new processorPolyPatch
479 procMesh.boundaryMesh(),
481 curNeighbourProcessors[procPatchi]
486 const coupledPolyPatch& pcPatch
487 = refCast<const coupledPolyPatch>
489 boundaryMesh()[subPatchID[i]]
493 new processorCyclicPolyPatch
498 procMesh.boundaryMesh(),
500 curNeighbourProcessors[procPatchi],
513 procMesh.addPatches(procPatches);
524 List<DynamicList<label>> zonePoints(pz.size());
529 zonePoints[zoneI].setCapacity(pz[zoneI].size() / nProcs_);
534 forAll(curPointLabels, pointi)
536 label curPoint = curPointLabels[pointi];
538 label zoneI = pointToZone[curPoint];
543 zonePoints[zoneI].append(pointi);
545 else if (zoneI == -2)
550 label index = pz[zoneI].whichPoint(curPoint);
554 zonePoints[zoneI].append(pointi);
560 procMesh.pointZones().clearAddressing();
561 procMesh.pointZones().setSize(zonePoints.size());
564 procMesh.pointZones().set
569 procMesh.pointZones(),
571 zonePoints[zoneI].shrink()
590 List<DynamicList<label>> zoneFaces(fz.size());
591 List<DynamicList<bool>> zoneFaceFlips(fz.size());
596 label procSize = fz[zoneI].size() / nProcs_;
598 zoneFaces[zoneI].setCapacity(procSize);
599 zoneFaceFlips[zoneI].setCapacity(procSize);
605 forAll(curFaceLabels, facei)
609 label curF =
mag(curFaceLabels[facei]) - 1;
611 label zoneI = faceToZone[curF];
616 zoneFaces[zoneI].append(facei);
618 label index = fz[zoneI].whichFace(curF);
620 bool flip = fz[zoneI].flipMap()[index];
622 if (curFaceLabels[facei] < 0)
627 zoneFaceFlips[zoneI].append(flip);
629 else if (zoneI == -2)
634 label index = fz[zoneI].whichFace(curF);
638 zoneFaces[zoneI].append(facei);
640 bool flip = fz[zoneI].flipMap()[index];
642 if (curFaceLabels[facei] < 0)
647 zoneFaceFlips[zoneI].append(flip);
653 procMesh.faceZones().clearAddressing();
654 procMesh.faceZones().setSize(zoneFaces.size());
657 procMesh.faceZones().set
662 zoneFaces[zoneI].shrink(),
663 zoneFaceFlips[zoneI].shrink(),
684 List<DynamicList<label>> zoneCells(cz.size());
689 zoneCells[zoneI].setCapacity(cz[zoneI].size() / nProcs_);
692 forAll(curCellLabels, celli)
694 label curCelli = curCellLabels[celli];
696 label zoneI = cellToZone[curCelli];
701 zoneCells[zoneI].append(celli);
703 else if (zoneI == -2)
708 label index = cz[zoneI].whichCell(curCelli);
712 zoneCells[zoneI].append(celli);
718 procMesh.cellZones().clearAddressing();
719 procMesh.cellZones().setSize(zoneCells.size());
722 procMesh.cellZones().set
727 zoneCells[zoneI].shrink(),
747 if (facesInstancePointsPtr_.valid())
763 pointsInstancePoints.write();
772 const cellSet& cs = cellSets[i];
773 cellSet
set(procMesh, cs.name(), cs.size()/nProcs_);
776 if (cs.found(curCellLabels[i]))
785 const faceSet& cs = faceSets[i];
786 faceSet
set(procMesh, cs.name(), cs.size()/nProcs_);
789 if (cs.found(
mag(curFaceLabels[i])-1))
798 const pointSet& cs = pointSets[i];
799 pointSet
set(procMesh, cs.name(), cs.size()/nProcs_);
802 if (cs.found(curPointLabels[i]))
826 procCellAddressing_[proci],
827 procPointAddressing_[proci]
834 <<
"Processor " << proci <<
nl 835 <<
" Number of cells = " << procMesh.nCells()
838 maxProcCells =
max(maxProcCells, procMesh.nCells());
840 label nBoundaryFaces = 0;
841 label nProcPatches = 0;
842 label nProcFaces = 0;
846 if (isA<processorPolyPatch>(procMesh.boundaryMesh()[
patchi]))
848 const processorPolyPatch& ppp =
849 refCast<const processorPolyPatch>
851 procMesh.boundaryMesh()[
patchi]
854 Info<<
" Number of faces shared with processor " 855 << ppp.neighbProcNo() <<
" = " << ppp.size() <<
endl;
858 nProcFaces += ppp.size();
862 nBoundaryFaces += procMesh.boundaryMesh()[
patchi].size();
866 Info<<
" Number of processor patches = " << nProcPatches <<
nl 867 <<
" Number of processor faces = " << nProcFaces <<
nl 868 <<
" Number of boundary faces = " << nBoundaryFaces <<
endl;
870 totProcFaces += nProcFaces;
871 totProcPatches += nProcPatches;
872 maxProcPatches =
max(maxProcPatches, nProcPatches);
873 maxProcFaces =
max(maxProcFaces, nProcFaces);
880 "pointProcAddressing",
881 procMesh.facesInstance(),
887 procPointAddressing_[proci]
889 pointProcAddressing.write();
895 "faceProcAddressing",
896 procMesh.facesInstance(),
902 procFaceAddressing_[proci]
910 "cellProcAddressing",
911 procMesh.facesInstance(),
917 procCellAddressing_[proci]
919 cellProcAddressing.write();
923 label nMeshPatches = curPatchSizes.size();
925 procBoundaryAddressing.setSize(nMeshPatches+nProcPatches, -1);
931 "boundaryProcAddressing",
932 procMesh.facesInstance(),
938 procBoundaryAddressing
940 boundaryProcAddressing.write();
943 scalar avgProcCells = scalar(nCells())/nProcs_;
944 scalar avgProcPatches = scalar(totProcPatches)/nProcs_;
945 scalar avgProcFaces = scalar(totProcFaces)/nProcs_;
948 if (totProcPatches == 0)
952 if (totProcFaces == 0)
958 <<
"Number of processor faces = " << totProcFaces/2 <<
nl 959 <<
"Max number of cells = " << maxProcCells
960 <<
" (" << 100.0*(maxProcCells-avgProcCells)/avgProcCells
961 <<
"% above average " << avgProcCells <<
")" <<
nl 962 <<
"Max number of processor patches = " << maxProcPatches
963 <<
" (" << 100.0*(maxProcPatches-avgProcPatches)/avgProcPatches
964 <<
"% above average " << avgProcPatches <<
")" <<
nl 965 <<
"Max number of faces between processors = " << maxProcFaces
966 <<
" (" << 100.0*(maxProcFaces-avgProcFaces)/avgProcFaces
967 <<
"% above average " << avgProcFaces <<
")" <<
nl
PtrList< polyPatch > polyPatchList
container classes for polyPatch
List< labelList > labelListList
A List of labelList.
bool writeDecomposition(const bool decomposeSets)
Write decomposition.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
static const decompositionModel & New(const polyMesh &mesh, const fileName &decompDictFile="")
Read (optionallly from absolute path) & register on mesh.
domainDecomposition(const IOobject &io, const fileName &dictFile)
Construct from IOobject and decomposition dictionary name.
const fileName & facesInstance() const
Return the current instance directory for faces.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
vectorIOField pointIOField
pointIOField is a vectorIOField.
PtrList< labelIOList > & faceProcAddressing
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static unsigned int defaultPrecision()
Return the default precision.
IOobject(const word &name, const fileName &instance, const objectRegistry ®istry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true)
Construct from name, instance, registry, io options.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
~domainDecomposition()
Destructor.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
vectorField pointField
pointField is a vectorField.
const fileName & pointsInstance() const
Return the current instance directory for points.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
List< label > labelList
A List of labels.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
static word controlDictName
The default control dictionary name (normally "controlDict")
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
word name(const complex &)
Return a string representation of a complex.
fvMesh(const IOobject &io)
Construct from IOobject.
void setSize(const label)
Reset size of List.
dimensioned< scalar > mag(const dimensioned< Type > &)
List< cell > cellList
list of cells
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
IOList< label > labelIOList
Label container classes.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
polyMesh(const IOobject &io)
Construct from IOobject.