49void Foam::domainDecomposition::mark
51 const labelList& zoneElems,
53 labelList& elementToZone
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]];
318 fileName processorCasePath
320 time().caseName()/(
"processor" +
Foam::name(proci))
332 processorDb.setTime(time());
344 autoPtr<polyMesh> procMeshPtr;
346 if (facesInstancePointsPtr_)
351 facesInstancePointsPtr_(),
365 std::move(facesInstancePoints),
366 std::move(procFaces),
382 std::move(procPoints),
383 std::move(procFaces),
387 polyMesh& procMesh = procMeshPtr();
391 const labelList& curPatchSizes = procPatchSize_[proci];
393 const labelList& curPatchStarts = procPatchStartIndex_[proci];
395 const labelList& curNeighbourProcessors =
396 procNeighbourProcessors_[proci];
398 const labelList& curProcessorPatchSizes =
399 procProcessorPatchSize_[proci];
401 const labelList& curProcessorPatchStarts =
402 procProcessorPatchStartIndex_[proci];
405 procProcessorPatchSubPatchIDs_[proci];
408 procProcessorPatchSubPatchStarts_[proci];
414 label nInterProcPatches = 0;
415 forAll(curSubPatchIDs, procPatchi)
417 nInterProcPatches += curSubPatchIDs[procPatchi].size();
422 curPatchSizes.size() + nInterProcPatches
427 forAll(curPatchSizes, patchi)
431 const polyPatch& meshPatch = meshPatches[patchi];
433 fvFieldDecomposer::patchFieldDecomposer patchMapper
438 curPatchSizes[patchi],
439 curPatchStarts[patchi]
450 procMesh.boundaryMesh(),
452 patchMapper.directAddressing(),
453 curPatchStarts[patchi]
460 forAll(curProcessorPatchSizes, procPatchi)
462 const labelList& subPatchID = curSubPatchIDs[procPatchi];
463 const labelList& subStarts = curSubStarts[procPatchi];
465 label curStart = curProcessorPatchStarts[procPatchi];
471 i < subPatchID.size()-1
472 ? subStarts[i+1] - subStarts[i]
473 : curProcessorPatchSizes[procPatchi] - subStarts[i]
476 if (subPatchID[i] == -1)
482 new processorPolyPatch
487 procMesh.boundaryMesh(),
489 curNeighbourProcessors[procPatchi]
495 const coupledPolyPatch& pcPatch
496 = refCast<const coupledPolyPatch>
498 boundaryMesh()[subPatchID[i]]
504 new processorCyclicPolyPatch
509 procMesh.boundaryMesh(),
511 curNeighbourProcessors[procPatchi],
524 procMesh.addPatches(procPatches);
535 List<DynamicList<label>> zonePoints(pz.size());
540 zonePoints[zonei].setCapacity(pz[zonei].size()/nProcs_);
545 forAll(curPointLabels, pointi)
547 label curPoint = curPointLabels[pointi];
549 label zonei = pointToZone[curPoint];
554 zonePoints[zonei].append(pointi);
556 else if (zonei == -2)
561 label index = pz[zonei].whichPoint(curPoint);
565 zonePoints[zonei].append(pointi);
571 procMesh.pointZones().clearAddressing();
572 procMesh.pointZones().setSize(zonePoints.size());
575 procMesh.pointZones().set
580 procMesh.pointZones(),
582 zonePoints[zonei].shrink()
601 List<DynamicList<label>> zoneFaces(fz.size());
602 List<DynamicList<bool>> zoneFaceFlips(fz.size());
607 label procSize = fz[zonei].size() / nProcs_;
609 zoneFaces[zonei].setCapacity(procSize);
610 zoneFaceFlips[zonei].setCapacity(procSize);
616 forAll(curFaceLabels, facei)
620 label curF =
mag(curFaceLabels[facei]) - 1;
622 label zonei = faceToZone[curF];
627 zoneFaces[zonei].append(facei);
629 label index = fz[zonei].whichFace(curF);
631 bool flip = fz[zonei].flipMap()[index];
633 if (curFaceLabels[facei] < 0)
638 zoneFaceFlips[zonei].append(flip);
640 else if (zonei == -2)
645 label index = fz[zonei].whichFace(curF);
649 zoneFaces[zonei].append(facei);
651 bool flip = fz[zonei].flipMap()[index];
653 if (curFaceLabels[facei] < 0)
658 zoneFaceFlips[zonei].append(flip);
664 procMesh.faceZones().clearAddressing();
665 procMesh.faceZones().setSize(zoneFaces.size());
668 procMesh.faceZones().set
673 zoneFaces[zonei].shrink(),
674 zoneFaceFlips[zonei].shrink(),
695 List<DynamicList<label>> zoneCells(cz.size());
700 zoneCells[zonei].setCapacity(cz[zonei].size()/nProcs_);
703 forAll(curCellLabels, celli)
705 label curCelli = curCellLabels[celli];
707 label zonei = cellToZone[curCelli];
712 zoneCells[zonei].append(celli);
714 else if (zonei == -2)
719 label index = cz[zonei].whichCell(curCelli);
723 zoneCells[zonei].append(celli);
729 procMesh.cellZones().clearAddressing();
730 procMesh.cellZones().setSize(zoneCells.size());
733 procMesh.cellZones().set
738 zoneCells[zonei].shrink(),
758 if (facesInstancePointsPtr_)
772 std::move(procPoints)
774 pointsInstancePoints.write();
783 const cellSet& cs = cellSets[i];
784 cellSet
set(procMesh, cs.name(), cs.size()/nProcs_);
787 if (cs.found(curCellLabels[i]))
796 const faceSet& cs = faceSets[i];
797 faceSet
set(procMesh, cs.name(), cs.size()/nProcs_);
800 if (cs.found(
mag(curFaceLabels[i])-1))
809 const pointSet& cs = pointSets[i];
810 pointSet
set(procMesh, cs.name(), cs.size()/nProcs_);
813 if (cs.found(curPointLabels[i]))
837 procCellAddressing_[proci],
838 procPointAddressing_[proci]
843 Info<<
nl <<
"Processor " << proci;
845 if (procMesh.nCells())
854 Info<<
"Number of cells = " << procMesh.nCells() <<
nl;
856 if (procMesh.nCells())
858 Info<<
" Number of points = " << procMesh.nPoints() <<
nl;
861 maxProcCells =
max(maxProcCells, procMesh.nCells());
863 label nBoundaryFaces = 0;
865 label nProcFaces = 0;
867 for (
const polyPatch& pp : procMesh.boundaryMesh())
869 const auto* cpp = isA<processorPolyPatch>(pp);
873 const auto& procPatch = *cpp;
875 Info<<
" Number of faces shared with processor "
876 << procPatch.neighbProcNo() <<
" = "
877 << procPatch.size() <<
nl;
879 nProcFaces += procPatch.size();
884 nBoundaryFaces += pp.size();
888 if (procMesh.nCells() && (nBoundaryFaces || nProcFaces))
891 <<
" Number of processor faces = " << nProcFaces <<
nl
892 <<
" Number of boundary faces = " << nBoundaryFaces <<
nl;
895 totProcFaces += nProcFaces;
897 maxProcFaces =
max(maxProcFaces, nProcFaces);
905 procMesh.facesInstance(),
914 ioAddr.rename(
"pointProcAddressing");
915 IOListRef<label>(ioAddr, procPointAddressing_[proci]).write();
918 ioAddr.rename(
"faceProcAddressing");
919 IOListRef<label>(ioAddr, procFaceAddressing_[proci]).write();
922 ioAddr.rename(
"cellProcAddressing");
923 IOListRef<label>(ioAddr, procCellAddressing_[proci]).write();
927 label nMeshPatches = curPatchSizes.size();
932 ioAddr.rename(
"boundaryProcAddressing");
933 IOListRef<label>(ioAddr, procBoundaryAddr).write();
939 <<
"Number of processor faces = " << (totProcFaces/2) <<
nl
940 <<
"Max number of cells = " << maxProcCells;
942 if (maxProcCells != nCells())
944 scalar avgValue = scalar(nCells())/nProcs_;
946 Info<<
" (" << 100.0*(maxProcCells-avgValue)/avgValue
947 <<
"% above average " << avgValue <<
')';
951 Info<<
"Max number of processor patches = " << maxProcPatches;
954 scalar avgValue = scalar(totProcPatches)/nProcs_;
956 Info<<
" (" << 100.0*(maxProcPatches-avgValue)/avgValue
957 <<
"% above average " << avgValue <<
')';
961 Info<<
"Max number of faces between processors = " << maxProcFaces;
964 scalar avgValue = scalar(totProcFaces)/nProcs_;
966 Info<<
" (" << 100.0*(maxProcFaces-avgValue)/avgValue
967 <<
"% above average " << avgValue <<
')';
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
static unsigned int defaultPrecision() noexcept
Return the default precision.
void setSize(const label n)
Alias for resize()
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
static word controlDictName
The default control dictionary name (normally "controlDict")
MeshObject wrapper of decompositionMethod.
Automatic domain decomposition class for finite-volume meshes.
void updateParameters(const dictionary ¶ms)
Update flags based on the decomposition model settings.
const decompositionModel & model() const
Return decomposition model used.
bool writeDecomposition()
Write decomposition.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
List< cell > cellList
A List of cells.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< labelList > labelListList
A List of labelList.
vectorIOField pointIOField
pointIOField is a vectorIOField.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
List< face > faceList
A List of faces.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.