49 void Foam::domainDecomposition::mark
56 for (
const label pointi : zoneElems)
58 if (elementToZone[pointi] == -1)
61 elementToZone[pointi] = zoneI;
63 else if (elementToZone[pointi] >= 0)
66 elementToZone[pointi] = -2;
77 const fileName& decompDictFile
81 facesInstancePointsPtr_
83 pointsInstance() != facesInstance()
99 decompDictFile_(decompDictFile),
102 decompositionMethod::nDomains
104 decompositionModel::
New 112 cellToProc_(nCells()),
113 procPointAddressing_(nProcs_),
114 procFaceAddressing_(nProcs_),
115 procCellAddressing_(nProcs_),
116 procPatchSize_(nProcs_),
117 procPatchStartIndex_(nProcs_),
118 procNeighbourProcessors_(nProcs_),
119 procProcessorPatchSize_(nProcs_),
120 procProcessorPatchStartIndex_(nProcs_),
121 procProcessorPatchSubPatchIDs_(nProcs_),
122 procProcessorPatchSubPatchStarts_(nProcs_)
124 updateParameters(this->model());
138 const dictionary& params
141 params.readIfPresent(
"distributed", distributed_);
147 Info<<
"\nConstructing processor meshes" <<
endl;
160 forAll(pointZones(), zonei)
162 mark(pointZones()[zonei], zonei, pointToZone);
166 labelList faceToZone(faces().size(), -1);
168 forAll(faceZones(), zonei)
170 mark(faceZones()[zonei], zonei, faceToZone);
176 forAll(cellZones(), zonei)
178 mark(cellZones()[zonei], zonei, cellToZone);
182 PtrDynList<const cellSet> cellSets;
183 PtrDynList<const faceSet> faceSets;
184 PtrDynList<const pointSet> pointSets;
188 IOobjectList objects(*
this, facesInstance(),
"polyMesh/sets");
189 for (
const IOobject&
io : objects.csorted<cellSet>())
191 cellSets.emplace_back(
io);
193 for (
const IOobject&
io : objects.csorted<faceSet>())
195 faceSets.emplace_back(
io);
197 for (
const IOobject&
io : objects.csorted<pointSet>())
199 pointSets.emplace_back(
io);
205 hexRef8Data baseMeshData
220 label maxProcCells = 0;
221 label maxProcFaces = 0;
222 label totProcFaces = 0;
223 label maxProcPatches = 0;
224 label totProcPatches = 0;
227 for (label proci = 0; proci < nProcs_; proci++)
230 const labelList& curPointLabels = procPointAddressing_[proci];
238 forAll(curPointLabels, pointi)
240 procPoints[pointi] = meshPoints[curPointLabels[pointi]];
242 pointLookup[curPointLabels[pointi]] = pointi;
246 const labelList& curFaceLabels = procFaceAddressing_[proci];
248 const faceList& meshFaces = faces();
252 faceList procFaces(curFaceLabels.size());
254 forAll(curFaceLabels, facei)
258 label curF =
mag(curFaceLabels[facei]) - 1;
260 faceLookup[curF] = facei;
265 if (curFaceLabels[facei] >= 0)
268 origFaceLabels = meshFaces[curF];
272 origFaceLabels = meshFaces[curF].reverseFace();
276 face& procFaceLabels = procFaces[facei];
278 procFaceLabels.
setSize(origFaceLabels.size());
280 forAll(origFaceLabels, pointi)
282 procFaceLabels[pointi] = pointLookup[origFaceLabels[pointi]];
287 const labelList& curCellLabels = procCellAddressing_[proci];
291 cellList procCells(curCellLabels.size());
293 forAll(curCellLabels, celli)
295 const labelList& origCellLabels = meshCells[curCellLabels[celli]];
297 cell& curCell = procCells[celli];
299 curCell.
setSize(origCellLabels.size());
301 forAll(origCellLabels, cellFacei)
303 curCell[cellFacei] = faceLookup[origCellLabels[cellFacei]];
314 time().caseName()/(
"processor" +
Foam::name(proci)),
318 processorDb.setTime(time());
330 autoPtr<polyMesh> procMeshPtr;
332 if (facesInstancePointsPtr_)
337 facesInstancePointsPtr_(),
351 std::move(facesInstancePoints),
352 std::move(procFaces),
368 std::move(procPoints),
369 std::move(procFaces),
373 polyMesh& procMesh = procMeshPtr();
377 const labelList& curPatchSizes = procPatchSize_[proci];
379 const labelList& curPatchStarts = procPatchStartIndex_[proci];
381 const labelList& curNeighbourProcessors =
382 procNeighbourProcessors_[proci];
384 const labelList& curProcessorPatchSizes =
385 procProcessorPatchSize_[proci];
387 const labelList& curProcessorPatchStarts =
388 procProcessorPatchStartIndex_[proci];
391 procProcessorPatchSubPatchIDs_[proci];
394 procProcessorPatchSubPatchStarts_[proci];
400 label nInterProcPatches = 0;
401 forAll(curSubPatchIDs, procPatchi)
403 nInterProcPatches += curSubPatchIDs[procPatchi].size();
408 curPatchSizes.size() + nInterProcPatches
413 forAll(curPatchSizes, patchi)
417 const polyPatch& meshPatch = meshPatches[patchi];
419 fvFieldDecomposer::patchFieldDecomposer patchMapper
424 curPatchSizes[patchi],
425 curPatchStarts[patchi]
436 procMesh.boundaryMesh(),
438 patchMapper.directAddressing(),
439 curPatchStarts[patchi]
446 forAll(curProcessorPatchSizes, procPatchi)
448 const labelList& subPatchID = curSubPatchIDs[procPatchi];
449 const labelList& subStarts = curSubStarts[procPatchi];
451 label curStart = curProcessorPatchStarts[procPatchi];
457 i < subPatchID.size()-1
458 ? subStarts[i+1] - subStarts[i]
459 : curProcessorPatchSizes[procPatchi] - subStarts[i]
462 if (subPatchID[i] == -1)
468 new processorPolyPatch
473 procMesh.boundaryMesh(),
475 curNeighbourProcessors[procPatchi]
481 const coupledPolyPatch& pcPatch
482 = refCast<const coupledPolyPatch>
484 boundaryMesh()[subPatchID[i]]
490 new processorCyclicPolyPatch
495 procMesh.boundaryMesh(),
497 curNeighbourProcessors[procPatchi],
510 procMesh.addPatches(procPatches);
521 List<DynamicList<label>> zonePoints(pz.size());
526 zonePoints[zonei].setCapacity(pz[zonei].size()/nProcs_);
531 forAll(curPointLabels, pointi)
533 label curPoint = curPointLabels[pointi];
535 label zonei = pointToZone[curPoint];
540 zonePoints[zonei].append(pointi);
542 else if (zonei == -2)
547 label index = pz[zonei].whichPoint(curPoint);
551 zonePoints[zonei].append(pointi);
557 procMesh.pointZones().clearAddressing();
558 procMesh.pointZones().setSize(zonePoints.size());
561 procMesh.pointZones().set
566 procMesh.pointZones(),
568 zonePoints[zonei].shrink()
587 List<DynamicList<label>> zoneFaces(fz.size());
588 List<DynamicList<bool>> zoneFaceFlips(fz.size());
593 label procSize = fz[zonei].size() / nProcs_;
595 zoneFaces[zonei].setCapacity(procSize);
596 zoneFaceFlips[zonei].setCapacity(procSize);
602 forAll(curFaceLabels, facei)
606 label curF =
mag(curFaceLabels[facei]) - 1;
608 label zonei = faceToZone[curF];
613 zoneFaces[zonei].append(facei);
615 label index = fz[zonei].whichFace(curF);
617 bool flip = fz[zonei].flipMap()[index];
619 if (curFaceLabels[facei] < 0)
624 zoneFaceFlips[zonei].append(flip);
626 else if (zonei == -2)
631 label index = fz[zonei].whichFace(curF);
635 zoneFaces[zonei].append(facei);
637 bool flip = fz[zonei].flipMap()[index];
639 if (curFaceLabels[facei] < 0)
644 zoneFaceFlips[zonei].append(flip);
650 procMesh.faceZones().clearAddressing();
651 procMesh.faceZones().setSize(zoneFaces.size());
654 procMesh.faceZones().set
659 zoneFaces[zonei].shrink(),
660 zoneFaceFlips[zonei].shrink(),
681 List<DynamicList<label>> zoneCells(cz.size());
686 zoneCells[zonei].setCapacity(cz[zonei].size()/nProcs_);
689 forAll(curCellLabels, celli)
691 label curCelli = curCellLabels[celli];
693 label zonei = cellToZone[curCelli];
698 zoneCells[zonei].append(celli);
700 else if (zonei == -2)
705 label index = cz[zonei].whichCell(curCelli);
709 zoneCells[zonei].append(celli);
715 procMesh.cellZones().clearAddressing();
716 procMesh.cellZones().setSize(zoneCells.size());
719 procMesh.cellZones().set
724 zoneCells[zonei].shrink(),
744 if (facesInstancePointsPtr_)
758 std::move(procPoints)
760 pointsInstancePoints.write();
769 const cellSet& cs = cellSets[i];
770 cellSet
set(procMesh, cs.name(), cs.size()/nProcs_);
773 if (cs.found(curCellLabels[i]))
782 const faceSet& cs = faceSets[i];
783 faceSet
set(procMesh, cs.name(), cs.size()/nProcs_);
786 if (cs.found(
mag(curFaceLabels[i])-1))
795 const pointSet& cs = pointSets[i];
796 pointSet
set(procMesh, cs.name(), cs.size()/nProcs_);
799 if (cs.found(curPointLabels[i]))
823 procCellAddressing_[proci],
824 procPointAddressing_[proci]
829 Info<<
nl <<
"Processor " << proci;
831 if (procMesh.nCells())
840 Info<<
"Number of cells = " << procMesh.nCells() <<
nl;
842 if (procMesh.nCells())
844 Info<<
" Number of points = " << procMesh.nPoints() <<
nl;
847 maxProcCells =
max(maxProcCells, procMesh.nCells());
849 label nBoundaryFaces = 0;
851 label nProcFaces = 0;
853 for (
const polyPatch&
pp : procMesh.boundaryMesh())
855 const auto* cpp = isA<processorPolyPatch>(
pp);
859 const auto& procPatch = *cpp;
861 Info<<
" Number of faces shared with processor " 862 << procPatch.neighbProcNo() <<
" = " 863 << procPatch.size() <<
nl;
865 nProcFaces += procPatch.size();
870 nBoundaryFaces +=
pp.size();
874 if (procMesh.nCells() && (nBoundaryFaces || nProcFaces))
877 <<
" Number of processor faces = " << nProcFaces <<
nl 878 <<
" Number of boundary faces = " << nBoundaryFaces <<
nl;
881 totProcFaces += nProcFaces;
883 maxProcFaces =
max(maxProcFaces, nProcFaces);
891 procMesh.facesInstance(),
900 ioAddr.rename(
"pointProcAddressing");
901 IOListRef<label>(ioAddr, procPointAddressing_[proci]).
write();
904 ioAddr.rename(
"faceProcAddressing");
905 IOListRef<label>(ioAddr, procFaceAddressing_[proci]).
write();
908 ioAddr.rename(
"cellProcAddressing");
909 IOListRef<label>(ioAddr, procCellAddressing_[proci]).
write();
913 label nMeshPatches = curPatchSizes.size();
918 ioAddr.rename(
"boundaryProcAddressing");
919 IOListRef<label>(ioAddr, procBoundaryAddr).
write();
925 <<
"Number of processor faces = " << (totProcFaces/2) <<
nl 926 <<
"Max number of cells = " << maxProcCells;
928 if (maxProcCells != nCells())
930 scalar avgValue = scalar(nCells())/nProcs_;
932 Info<<
" (" << 100.0*(maxProcCells-avgValue)/avgValue
933 <<
"% above average " << avgValue <<
')';
937 Info<<
"Max number of processor patches = " << maxProcPatches;
940 scalar avgValue = scalar(totProcPatches)/nProcs_;
942 Info<<
" (" << 100.0*(maxProcPatches-avgValue)/avgValue
943 <<
"% above average " << avgValue <<
')';
947 Info<<
"Max number of faces between processors = " << maxProcFaces;
950 scalar avgValue = scalar(totProcFaces)/nProcs_;
952 Info<<
" (" << 100.0*(maxProcFaces-avgValue)/avgValue
953 <<
"% above average " << avgValue <<
')';
bool writeDecomposition(const bool decomposeSets)
Write decomposition.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
List< cell > cellList
List of cell.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const word & name() const noexcept
Return the object name.
vectorIOField pointIOField
pointIOField is a vectorIOField.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
static unsigned int defaultPrecision() noexcept
Return the default precision.
Ignore writing from objectRegistry::writeObject()
static const decompositionModel & New(const polyMesh &mesh, const fileName &decompDictFile="", const dictionary *fallback=nullptr)
Read and register on mesh, optionally with alternative decomposeParDict path/name or with fallback co...
List< labelList > labelListList
List of labelList.
#define forAll(list, i)
Loop across all elements in list.
List< face > faceList
List of faces.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
vectorField pointField
pointField is a vectorField.
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
Reading is optional [identical to LAZY_READ].
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
MeshObject wrapper of decompositionMethod.
static word controlDictName
The default control dictionary name (normally "controlDict")
void updateParameters(const dictionary ¶ms)
Update flags based on the decomposition model settings.
Automatically write from objectRegistry::writeObject()
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
domainDecomposition(const IOobject &io, const fileName &decompDictFile="")
Construct from components.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
const decompositionModel & model() const
Return decomposition model used.
Do not request registration (bool: false)
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())