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");
190 IOobjectList sets(objects.lookupClass<cellSet>());
193 cellSets.append(
new cellSet(*(iter.val())));
197 IOobjectList sets(objects.lookupClass<faceSet>());
200 faceSets.append(
new faceSet(*(iter.val())));
204 IOobjectList sets(objects.lookupClass<pointSet>());
207 pointSets.append(
new pointSet(*(iter.val())));
214 hexRef8Data baseMeshData
229 label maxProcCells = 0;
230 label maxProcFaces = 0;
231 label totProcFaces = 0;
232 label maxProcPatches = 0;
233 label totProcPatches = 0;
236 for (label proci = 0; proci < nProcs_; proci++)
239 const labelList& curPointLabels = procPointAddressing_[proci];
247 forAll(curPointLabels, pointi)
249 procPoints[pointi] = meshPoints[curPointLabels[pointi]];
251 pointLookup[curPointLabels[pointi]] = pointi;
255 const labelList& curFaceLabels = procFaceAddressing_[proci];
257 const faceList& meshFaces = faces();
261 faceList procFaces(curFaceLabels.size());
263 forAll(curFaceLabels, facei)
267 label curF =
mag(curFaceLabels[facei]) - 1;
269 faceLookup[curF] = facei;
274 if (curFaceLabels[facei] >= 0)
277 origFaceLabels = meshFaces[curF];
281 origFaceLabels = meshFaces[curF].reverseFace();
285 face& procFaceLabels = procFaces[facei];
287 procFaceLabels.
setSize(origFaceLabels.size());
289 forAll(origFaceLabels, pointi)
291 procFaceLabels[pointi] = pointLookup[origFaceLabels[pointi]];
296 const labelList& curCellLabels = procCellAddressing_[proci];
300 cellList procCells(curCellLabels.size());
302 forAll(curCellLabels, celli)
304 const labelList& origCellLabels = meshCells[curCellLabels[celli]];
306 cell& curCell = procCells[celli];
308 curCell.
setSize(origCellLabels.size());
310 forAll(origCellLabels, cellFacei)
312 curCell[cellFacei] = faceLookup[origCellLabels[cellFacei]];
323 time().caseName()/(
"processor" +
Foam::name(proci)),
327 processorDb.setTime(time());
339 autoPtr<polyMesh> procMeshPtr;
341 if (facesInstancePointsPtr_)
346 facesInstancePointsPtr_(),
360 std::move(facesInstancePoints),
361 std::move(procFaces),
377 std::move(procPoints),
378 std::move(procFaces),
382 polyMesh& procMesh = procMeshPtr();
386 const labelList& curPatchSizes = procPatchSize_[proci];
388 const labelList& curPatchStarts = procPatchStartIndex_[proci];
390 const labelList& curNeighbourProcessors =
391 procNeighbourProcessors_[proci];
393 const labelList& curProcessorPatchSizes =
394 procProcessorPatchSize_[proci];
396 const labelList& curProcessorPatchStarts =
397 procProcessorPatchStartIndex_[proci];
400 procProcessorPatchSubPatchIDs_[proci];
403 procProcessorPatchSubPatchStarts_[proci];
409 label nInterProcPatches = 0;
410 forAll(curSubPatchIDs, procPatchi)
412 nInterProcPatches += curSubPatchIDs[procPatchi].size();
417 curPatchSizes.size() + nInterProcPatches
422 forAll(curPatchSizes, patchi)
426 const polyPatch& meshPatch = meshPatches[patchi];
428 fvFieldDecomposer::patchFieldDecomposer patchMapper
433 curPatchSizes[patchi],
434 curPatchStarts[patchi]
445 procMesh.boundaryMesh(),
447 patchMapper.directAddressing(),
448 curPatchStarts[patchi]
455 forAll(curProcessorPatchSizes, procPatchi)
457 const labelList& subPatchID = curSubPatchIDs[procPatchi];
458 const labelList& subStarts = curSubStarts[procPatchi];
460 label curStart = curProcessorPatchStarts[procPatchi];
466 i < subPatchID.size()-1
467 ? subStarts[i+1] - subStarts[i]
468 : curProcessorPatchSizes[procPatchi] - subStarts[i]
471 if (subPatchID[i] == -1)
477 new processorPolyPatch
482 procMesh.boundaryMesh(),
484 curNeighbourProcessors[procPatchi]
490 const coupledPolyPatch& pcPatch
491 = refCast<const coupledPolyPatch>
493 boundaryMesh()[subPatchID[i]]
499 new processorCyclicPolyPatch
504 procMesh.boundaryMesh(),
506 curNeighbourProcessors[procPatchi],
519 procMesh.addPatches(procPatches);
530 List<DynamicList<label>> zonePoints(pz.size());
535 zonePoints[zonei].setCapacity(pz[zonei].size()/nProcs_);
540 forAll(curPointLabels, pointi)
542 label curPoint = curPointLabels[pointi];
544 label zonei = pointToZone[curPoint];
549 zonePoints[zonei].append(pointi);
551 else if (zonei == -2)
556 label index = pz[zonei].whichPoint(curPoint);
560 zonePoints[zonei].append(pointi);
566 procMesh.pointZones().clearAddressing();
567 procMesh.pointZones().setSize(zonePoints.size());
570 procMesh.pointZones().set
575 procMesh.pointZones(),
577 zonePoints[zonei].shrink()
596 List<DynamicList<label>> zoneFaces(fz.size());
597 List<DynamicList<bool>> zoneFaceFlips(fz.size());
602 label procSize = fz[zonei].size() / nProcs_;
604 zoneFaces[zonei].setCapacity(procSize);
605 zoneFaceFlips[zonei].setCapacity(procSize);
611 forAll(curFaceLabels, facei)
615 label curF =
mag(curFaceLabels[facei]) - 1;
617 label zonei = faceToZone[curF];
622 zoneFaces[zonei].append(facei);
624 label index = fz[zonei].whichFace(curF);
626 bool flip = fz[zonei].flipMap()[index];
628 if (curFaceLabels[facei] < 0)
633 zoneFaceFlips[zonei].append(flip);
635 else if (zonei == -2)
640 label index = fz[zonei].whichFace(curF);
644 zoneFaces[zonei].append(facei);
646 bool flip = fz[zonei].flipMap()[index];
648 if (curFaceLabels[facei] < 0)
653 zoneFaceFlips[zonei].append(flip);
659 procMesh.faceZones().clearAddressing();
660 procMesh.faceZones().setSize(zoneFaces.size());
663 procMesh.faceZones().set
668 zoneFaces[zonei].shrink(),
669 zoneFaceFlips[zonei].shrink(),
690 List<DynamicList<label>> zoneCells(cz.size());
695 zoneCells[zonei].setCapacity(cz[zonei].size()/nProcs_);
698 forAll(curCellLabels, celli)
700 label curCelli = curCellLabels[celli];
702 label zonei = cellToZone[curCelli];
707 zoneCells[zonei].append(celli);
709 else if (zonei == -2)
714 label index = cz[zonei].whichCell(curCelli);
718 zoneCells[zonei].append(celli);
724 procMesh.cellZones().clearAddressing();
725 procMesh.cellZones().setSize(zoneCells.size());
728 procMesh.cellZones().set
733 zoneCells[zonei].shrink(),
753 if (facesInstancePointsPtr_)
767 std::move(procPoints)
769 pointsInstancePoints.write();
778 const cellSet& cs = cellSets[i];
779 cellSet
set(procMesh, cs.name(), cs.size()/nProcs_);
782 if (cs.found(curCellLabels[i]))
791 const faceSet& cs = faceSets[i];
792 faceSet
set(procMesh, cs.name(), cs.size()/nProcs_);
795 if (cs.found(
mag(curFaceLabels[i])-1))
804 const pointSet& cs = pointSets[i];
805 pointSet
set(procMesh, cs.name(), cs.size()/nProcs_);
808 if (cs.found(curPointLabels[i]))
832 procCellAddressing_[proci],
833 procPointAddressing_[proci]
838 Info<<
nl <<
"Processor " << proci;
840 if (procMesh.nCells())
849 Info<<
"Number of cells = " << procMesh.nCells() <<
nl;
851 if (procMesh.nCells())
853 Info<<
" Number of points = " << procMesh.nPoints() <<
nl;
856 maxProcCells =
max(maxProcCells, procMesh.nCells());
858 label nBoundaryFaces = 0;
860 label nProcFaces = 0;
862 for (
const polyPatch&
pp : procMesh.boundaryMesh())
864 const auto* cpp = isA<processorPolyPatch>(
pp);
868 const auto& procPatch = *cpp;
870 Info<<
" Number of faces shared with processor " 871 << procPatch.neighbProcNo() <<
" = " 872 << procPatch.size() <<
nl;
874 nProcFaces += procPatch.size();
879 nBoundaryFaces +=
pp.size();
883 if (procMesh.nCells() && (nBoundaryFaces || nProcFaces))
886 <<
" Number of processor faces = " << nProcFaces <<
nl 887 <<
" Number of boundary faces = " << nBoundaryFaces <<
nl;
890 totProcFaces += nProcFaces;
892 maxProcFaces =
max(maxProcFaces, nProcFaces);
900 procMesh.facesInstance(),
909 ioAddr.rename(
"pointProcAddressing");
910 IOListRef<label>(ioAddr, procPointAddressing_[proci]).
write();
913 ioAddr.rename(
"faceProcAddressing");
914 IOListRef<label>(ioAddr, procFaceAddressing_[proci]).
write();
917 ioAddr.rename(
"cellProcAddressing");
918 IOListRef<label>(ioAddr, procCellAddressing_[proci]).
write();
922 label nMeshPatches = curPatchSizes.size();
927 ioAddr.rename(
"boundaryProcAddressing");
928 IOListRef<label>(ioAddr, procBoundaryAddr).
write();
934 <<
"Number of processor faces = " << (totProcFaces/2) <<
nl 935 <<
"Max number of cells = " << maxProcCells;
937 if (maxProcCells != nCells())
939 scalar avgValue = scalar(nCells())/nProcs_;
941 Info<<
" (" << 100.0*(maxProcCells-avgValue)/avgValue
942 <<
"% above average " << avgValue <<
')';
946 Info<<
"Max number of processor patches = " << maxProcPatches;
949 scalar avgValue = scalar(totProcPatches)/nProcs_;
951 Info<<
" (" << 100.0*(maxProcPatches-avgValue)/avgValue
952 <<
"% above average " << avgValue <<
')';
956 Info<<
"Max number of faces between processors = " << maxProcFaces;
959 scalar avgValue = scalar(totProcFaces)/nProcs_;
961 Info<<
" (" << 100.0*(maxProcFaces-avgValue)/avgValue
962 <<
"% 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 INVALID.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
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())
forAllConstIters(mixture.phases(), phase)