48 Foam::label Foam::domainDecomposition::compareInstances
56 if (a == constant &&
b == constant)
return 0;
58 if (a == constant)
return +1;
60 if (
b == constant)
return -1;
62 const scalar aValue = instant(a).value();
63 const scalar bValue = instant(
b).value();
65 if (aValue < bValue)
return +1;
67 if (aValue > bValue)
return -1;
73 void Foam::domainDecomposition::validateComplete()
const
75 if (!completeMesh_.valid())
78 <<
"Complete data requested but complete mesh has not been "
84 void Foam::domainDecomposition::validateProcs()
const
86 if (!procMeshes_.set(0))
89 <<
"Decomposed data requested but decomposed mesh has not been "
95 void Foam::domainDecomposition::readComplete()
104 runTimes_.completeTime().name(),
105 runTimes_.completeTime(),
117 void Foam::domainDecomposition::readProcs()
119 for (
label proci = 0; proci < nProcs(); proci++)
129 runTimes_.procTimes()[proci].name(),
130 runTimes_.procTimes()[proci],
143 void Foam::domainDecomposition::readCompleteAddressing()
151 completeMesh().facesInstance(),
152 completeMesh().meshSubDir,
162 void Foam::domainDecomposition::readProcsAddressing()
164 for (
label proci = 0; proci < nProcs(); proci++)
166 const fvMesh& procMesh = procMeshes_[proci];
168 procPointAddressing_[proci] =
173 "pointProcAddressing",
174 procMesh.facesInstance(),
183 procFaceAddressing_[proci] =
188 "faceProcAddressing",
189 procMesh.facesInstance(),
198 procCellAddressing_[proci] =
203 "cellProcAddressing",
204 procMesh.facesInstance(),
216 void Foam::domainDecomposition::readAddressing()
218 readCompleteAddressing();
219 readProcsAddressing();
220 procFaceAddressingBf_.clear();
233 forAll(runTimes_.procTimes(), proci)
238 stat = procStat > stat ? procStat : stat;
245 void Foam::domainDecomposition::writeCompleteAddressing()
const
252 completeMesh().facesInstance(),
253 completeMesh().meshSubDir,
265 void Foam::domainDecomposition::writeProcsAddressing()
const
267 for (
label proci = 0; proci < nProcs(); proci++)
269 const fvMesh& procMesh = procMeshes_[proci];
275 "pointProcAddressing",
276 procMesh.facesInstance(),
282 procPointAddressing_[proci]
284 pointProcAddressing.write();
290 "faceProcAddressing",
291 procMesh.facesInstance(),
297 procFaceAddressing_[proci]
299 faceProcAddressing.write();
305 "cellProcAddressing",
306 procMesh.facesInstance(),
312 procCellAddressing_[proci]
314 cellProcAddressing.write();
319 void Foam::domainDecomposition::writeAddressing()
const
321 writeCompleteAddressing();
322 writeProcsAddressing();
326 void Foam::domainDecomposition::writeProcPoints(
const fileName& inst)
328 IOobject completePointsIo
339 if (!completePointsIo.headerOk())
return;
343 for (
label proci = 0; proci < nProcs(); proci++)
360 procPointAddressing_[proci]
369 void Foam::domainDecomposition::writeCompletePoints(
const fileName& inst)
386 for (
label proci = 0; proci < nProcs(); proci++)
388 IOobject procPointsIo
399 if (!procPointsIo.headerOk())
return;
404 procPointAddressing_[proci]
408 completePoints.write();
423 completeMesh_(nullptr),
424 procMeshes_(nProcs()),
425 regionMeshes_(regionMeshes),
427 procPointAddressing_(nProcs()),
428 procFaceAddressing_(nProcs()),
429 procCellAddressing_(nProcs()),
430 procFaceAddressingBf_()
449 completeMesh().facesInstance(),
456 completeMesh().facesInstance(),
457 completeMesh().meshDir(),
458 runTimes_.procTimes()[0]
462 "cellProcAddressing",
463 completeMesh().facesInstance(),
464 completeMesh().meshDir(),
465 runTimes_.procTimes()[0]
480 readCompleteAddressing();
483 <<
nl <<
" Processor meshes exist but have no addressing."
484 <<
nl <<
nl <<
" This could be because the processor meshes "
485 <<
"have changed. Decomposing the" <<
nl <<
" mesh would "
486 <<
"overwrite that change. If you are sure that this is "
487 <<
"appropriate," <<
nl <<
" then delete the "
489 <<
" directories and re-run this" <<
nl <<
" command."
499 completeMesh().facesInstance()
500 != runTimes_.completeTime().name()
501 && completeMesh().facesInstance()
502 != runTimes_.completeTime().constant()
506 <<
"Cannot begin mesh decomposition at time "
507 <<
fileName(runTimes_.completeTime().name()) <<
nl
508 <<
"The mesh at this instant is that of an earlier"
509 <<
" time " << completeMesh().facesInstance() <<
nl
510 <<
"Decomposition must start from this earlier time"
523 completeMesh_->stitcher().connect(
false,
false,
true);
529 if (!completeConformal())
531 procFaceAddressingBf_.clear();
533 forAll(procMeshes_, proci)
535 procMeshes_[proci].conform();
545 const bool decomposed,
553 writeProcPoints(completeMesh().facesInstance());
565 procMeshes()[0].facesInstance(),
566 procMeshes()[0].meshDir(),
567 runTimes_.completeTime()
572 procMeshes()[0].facesInstance(),
573 procMeshes()[0].meshDir(),
574 runTimes_.completeTime()
578 "cellProcAddressing",
579 procMeshes()[0].facesInstance(),
591 procMeshes()[0].pointsInstance(),
592 procMeshes()[0].meshDir(),
593 runTimes_.completeTime()
604 readProcsAddressing();
607 <<
nl <<
" A complete mesh exists but has no "
608 << addrIo.
name() <<
" addressing." <<
nl <<
nl <<
" This "
609 <<
"could be because the complete mesh has changed. "
610 <<
"Reconstructing the" <<
nl <<
" mesh would overwrite "
611 <<
"that change. If you are sure that this is appropriate,"
613 <<
" directory and re-run this command." <<
nl <<
nl
614 <<
" Or, it could be because the complete and processor "
615 <<
"meshes were decomposed" <<
nl <<
" by a version of "
616 <<
"OpenFOAM that pre-dates the automatic generation of "
617 <<
nl <<
" " << addrIo.
name() <<
" addressing. This will be "
618 <<
"assumed and the " << addrIo.
name() <<
" addressing will"
619 <<
nl <<
" be re-built" <<
nl <<
endl;
621 cellProc_ =
labelList(completeMesh().nCells(), -1);
623 for (
label proci = 0; proci < nProcs(); proci++)
628 procCellAddressing_[proci]
632 writeCompleteAddressing();
641 procMeshes()[0].facesInstance()
642 != runTimes_.procTimes()[0].name()
643 && procMeshes()[0].facesInstance()
644 != runTimes_.procTimes()[0].constant()
648 <<
"Cannot begin mesh reconstruction at time "
649 <<
fileName(runTimes_.procTimes()[0].name()) <<
nl
650 <<
"The mesh at this instant is that of an earlier"
651 <<
" time " << procMeshes()[0].facesInstance() <<
nl
652 <<
"Reconstruction must start from this earlier time"
665 forAll(procMeshes_, proci)
667 procMeshes_[proci].stitcher().connect(
false,
false,
true);
674 if (!procsConformal())
676 procFaceAddressingBf_.clear();
678 completeMesh_->conform();
687 const bool reconstructed,
691 writeComplete(doSets);
695 writeCompletePoints(procMeshes()[0].facesInstance());
706 const label facesCompare =
709 completeMesh().facesInstance(),
710 procMeshes_[0].facesInstance()
714 if (facesCompare == -1)
726 if (facesCompare == +1)
729 <<
"Cannot decompose at time "
730 << procMeshes_[0].facesInstance()
731 <<
" because the processor mesh topology has evolved further"
738 const label pointsCompare =
741 completeMesh().pointsInstance(),
742 procMeshes_[0].pointsInstance()
747 if (pointsCompare == -1)
753 if (pointsCompare == +1)
756 <<
"Cannot decompose at time "
757 << procMeshes_[0].pointsInstance()
758 <<
" because the processor mesh geometry has evolved further"
774 procFaceAddressingBf_.clear();
776 completeMesh_->stitcher().connect(
false,
false,
true);
788 forAll(procMeshes_, proci)
790 procMeshes_[proci].conform();
804 const label facesCompare =
807 completeMesh().facesInstance(),
808 procMeshes_[0].facesInstance()
812 if (facesCompare == -1)
815 <<
"Cannot reconstruct at time "
816 << completeMesh().facesInstance()
817 <<
" because the complete mesh topology has evolved further"
829 if (facesCompare == +1)
837 const label pointsCompare =
840 completeMesh().pointsInstance(),
841 procMeshes_[0].pointsInstance()
845 if (pointsCompare == -1)
848 <<
"Cannot reconstruct at time "
849 << completeMesh().pointsInstance()
850 <<
" because the complete mesh geometry has evolved further"
856 if (pointsCompare == +1)
873 procFaceAddressingBf_.clear();
875 forAll(procMeshes_, proci)
877 procMeshes_[proci].stitcher().connect(
false,
false,
true);
890 completeMesh_->conform();
903 if (procFaceAddressingBf_.empty())
907 this->nonConformalProcFaceAddressingBf();
910 procFaceAddressingBf_.resize(nProcs());
911 forAll(procMeshes_, proci)
913 const fvMesh& procMesh = procMeshes_[proci];
915 procFaceAddressingBf_.
set
922 calculatedFvsPatchLabelField::typeName
930 if (isA<nonConformalFvPatch>(fvp))
932 procFaceAddressingBf_[proci][procPatchi] =
933 nonConformalProcFaceAddressingBf[proci][procPatchi];
935 else if (isA<processorCyclicFvPatch>(fvp))
937 const label completePatchi =
938 refCast<const processorCyclicFvPatch>(fvp)
941 procFaceAddressingBf_[proci][procPatchi] =
943 - completeMesh().boundaryMesh()[completePatchi].start();
945 else if (isA<processorFvPatch>(fvp))
947 procFaceAddressingBf_[proci][procPatchi] =
952 procFaceAddressingBf_[proci][procPatchi] =
954 - completeMesh().boundaryMesh()[procPatchi].start();
960 return procFaceAddressingBf_;
966 const bool topologyWrite =
974 completeMesh().write();
978 if (!topologyWrite)
return;
987 for (
label proci = 0; proci < nProcs(); proci++)
989 const fvMesh& procMesh = procMeshes_[proci];
991 const labelList& cellMap = procCellAddressing()[proci];
993 const labelList& pointMap = procPointAddressing()[proci];
999 runTimes_.procTimes()[proci].
name(),
1018 const cellSet procSet(*iter());
1040 cSet.
insert(cellMap[iter.key()]);
1045 const faceSet procSet(*iter());
1074 if (!pointSets.
found(iter.key()))
1088 pointSet& cSet = *pointSets[iter.key()];
1094 cSet.
insert(pointMap[iter.key()]);
1118 for (
label proci = 0; proci < nProcs(); proci++)
1120 const fvMesh& procMesh = procMeshes_[proci];
1122 cellMaps.
set(proci, &procCellAddressing_[proci]);
1123 pointMaps.
set(proci, &procPointAddressing_[proci]);
1132 completeMesh().facesInstance(),
1147 completeMesh().facesInstance(),
1166 const bool topologyWrite =
1171 for (
label proci = 0; proci < nProcs(); proci++)
1173 const fvMesh& procMesh = procMeshes_[proci];
1184 if (!topologyWrite)
return;
1193 completeMesh().facesInstance(),
1227 for (
label proci = 0; proci < nProcs(); proci++)
1229 const fvMesh& procMesh = procMeshes_[proci];
1235 forAll(procCellAddressing_[proci], i)
1237 if (cs.
found(procCellAddressing_[proci][i]))
1248 forAll(procFaceAddressing_[proci], i)
1250 if (cs.
found(
mag(procFaceAddressing_[proci][i]) - 1))
1261 forAll(procPointAddressing_[proci], i)
1263 if (cs.
found(procPointAddressing_[proci][i]))
1279 completeMesh().facesInstance(),
1287 for (
label proci = 0; proci < nProcs(); proci++)
1289 const fvMesh& procMesh = procMeshes_[proci];
1296 completeMesh().facesInstance(),
1304 procCellAddressing_[proci],
1305 procPointAddressing_[proci]
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Generic GeometricBoundaryField class.
static const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
A HashTable specialisation for hashing pointers.
bool insert(const Key &key)
Insert a new entry.
bool set(const Key &, const T &newElmt)
Set a new hashedEntry, overwriting existing entries.
label size() const
Return number of elements in table.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
bool found(const Key &) const
Return true if hashedEntry is found in table.
List of IOobjects with searching and retrieving facilities.
IOobjectList lookupClass(const word &className) const
Return the list for all IOobjects of a given class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
fileName relativePath() const
Return the path relative to the case directory.
fileName & instance() const
Return the instance directory, constant, system, <time> etc.
bool headerOk()
Read header of local object without type-checking.
const word & name() const
Return name.
static unsigned int defaultPrecision()
Return the default precision.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool set(const label) const
Is element set.
void append(T *)
Append an element at the end of the list.
static const word & constant()
Return constant name.
A List with indirect addressing.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool set(const label) const
Is element set.
A collection of cell labels.
Automatic domain decomposition class for finite-volume meshes.
bool readReconstruct()
Read in the processor meshes. Read the complete mesh if it is.
void postReadReconstruct()
Post-read-construction steps for the meshes after read-reconstruct.
void postReadDecompose()
Post-read-construction steps for the meshes after read-decompose.
bool readDecompose()
Read in the complete mesh. Read the processor meshes if they are.
void unconformReadReconstruct()
Synchronise non-conformal structure after read-reconstruct.
void unconformReadUpdateReconstruct(const fvMesh::readUpdateState stat)
Synchronise non-conformal structure after read-update-reconstruct.
domainDecomposition(const processorRunTimes &procRunTimes, const word ®ionName, const multiDomainDecomposition ®ionMeshes=NullObjectRef< multiDomainDecomposition >())
Construct from processor run times and region name.
void postReadUpdateReconstruct(const fvMesh::readUpdateState stat)
Complete read-update-reconstruct.
void writeProcs(const bool doSets) const
Write the decomposed meshes and associated data.
void writeReadReconstruct(const bool reconstructed, const bool doSets)
Write following read-reconstruct.
void writeReadDecompose(const bool decomposed, const bool doSets)
Write following read-decompose.
void writeComplete(const bool doSets) const
Write the decomposed meshes and associated data.
void postReadUpdateDecompose(const fvMesh::readUpdateState stat)
Complete read-update-decompose.
const PtrList< surfaceLabelField::Boundary > & procFaceAddressingBf() const
Access the labels of faces for each processor (see notes above)
void unconformReadDecompose()
Synchronise non-conformal structure after read-decompose.
fvMesh::readUpdateState readUpdateReconstruct()
Read-update for reconstruction.
void unconformReadUpdateDecompose(const fvMesh::readUpdateState stat)
Synchronise non-conformal structure after read-update-decompose.
fvMesh::readUpdateState readUpdateDecompose()
Read-update for decomposition.
virtual ~domainDecomposition()
Destructor.
A class for handling file names.
word name() const
Return file name (part beyond last /)
Mesh data needed to do the Finite Volume discretisation.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
readUpdateState
Enumeration defining the state of the mesh after a read update.
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
const word & name() const
Return reference to name.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
const List< T >::subList patchSlice(const List< T > &l) const
Slice list to patch.
Various for reading/decomposing/reconstructing/distributing refinement data.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
const Time & completeTime() const
Access the complete run time.
Transfers refinement levels such that slow transition between levels is maintained....
virtual bool write(const bool write=true) const
Write using setting from DB.
Templated form of IOobject providing type information for file reading and header type checking.
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
tmp< VolField< typename outerProduct< vector, Type >::type > > reconstruct(const SurfaceField< Type > &ssf)
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const word & regionName(const solver ®ion)
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > mag(const dimensioned< Type > &)
vectorIOField pointIOField
pointIOField is a vectorIOField.
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
IOList< label > labelIOList
Label container classes.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)