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
78 <<
"Complete data requested but complete mesh has not been "
84 void Foam::domainDecomposition::validateProcs()
const
89 <<
"Decomposed data requested but decomposed mesh has not been "
104 runTimes_.completeTime().name(),
106 runTimes_.completeTime(),
114 completeMesh_->postConstruct
123 void Foam::domainDecomposition::readProcs(
const bool doPost)
125 for (
label proci = 0; proci < nProcs(); proci++)
135 runTimes_.procTimes()[proci].name(),
137 runTimes_.procTimes()[proci],
145 procMeshes_[proci].postConstruct
155 void Foam::domainDecomposition::readCompleteAddressing()
163 completeMesh().facesInstance(),
164 completeMesh().meshSubDir,
174 void Foam::domainDecomposition::readProcsAddressing()
176 for (
label proci = 0; proci < nProcs(); proci++)
178 const fvMesh& procMesh = procMeshes_[proci];
180 procPointAddressing_[proci] =
185 "pointProcAddressing",
186 procMesh.facesInstance(),
195 procFaceAddressing_[proci] =
200 "faceProcAddressing",
201 procMesh.facesInstance(),
210 procCellAddressing_[proci] =
215 "cellProcAddressing",
216 procMesh.facesInstance(),
228 void Foam::domainDecomposition::readAddressing()
230 readCompleteAddressing();
231 readProcsAddressing();
232 procFaceAddressingBf_.clear();
245 forAll(runTimes_.procTimes(), proci)
250 stat = procStat > stat ? procStat : stat;
257 void Foam::domainDecomposition::writeCompleteAddressing()
const
264 completeMesh().facesInstance(),
265 completeMesh().meshSubDir,
277 void Foam::domainDecomposition::writeProcsAddressing()
const
279 for (
label proci = 0; proci < nProcs(); proci++)
281 const fvMesh& procMesh = procMeshes_[proci];
287 "pointProcAddressing",
288 procMesh.facesInstance(),
294 procPointAddressing_[proci]
296 pointProcAddressing.write();
302 "faceProcAddressing",
303 procMesh.facesInstance(),
309 procFaceAddressing_[proci]
311 faceProcAddressing.write();
317 "cellProcAddressing",
318 procMesh.facesInstance(),
324 procCellAddressing_[proci]
326 cellProcAddressing.write();
331 void Foam::domainDecomposition::writeAddressing()
const
333 writeCompleteAddressing();
334 writeProcsAddressing();
338 void Foam::domainDecomposition::writeProcPoints(
const fileName& inst)
340 IOobject completePointsIo
351 if (!completePointsIo.headerOk())
return;
355 for (
label proci = 0; proci < nProcs(); proci++)
372 procPointAddressing_[proci]
381 void Foam::domainDecomposition::writeCompletePoints(
const fileName& inst)
398 for (
label proci = 0; proci < nProcs(); proci++)
400 IOobject procPointsIo
411 if (!procPointsIo.headerOk())
return;
416 procPointAddressing_[proci]
420 completePoints.write();
425 inline Foam::label Foam::domainDecomposition::setIndex<Foam::cellSet>
428 const label procCelli
431 return procCellAddressing_[proci][procCelli];
436 inline Foam::label Foam::domainDecomposition::setIndex<Foam::faceSet>
439 const label procFacei
442 return mag(procFaceAddressing_[proci][procFacei]) - 1;
447 inline Foam::label Foam::domainDecomposition::setIndex<Foam::pointSet>
450 const label procPointi
453 return procPointAddressing_[proci][procPointi];
470 completeMesh_(nullptr),
471 procMeshes_(nProcs()),
472 regionMeshes_(regionMeshes),
474 procPointAddressing_(nProcs()),
475 procFaceAddressing_(nProcs()),
476 procCellAddressing_(nProcs()),
477 procFaceAddressingBf_()
502 completeMesh().facesInstance(),
509 completeMesh().facesInstance(),
510 completeMesh().meshDir(),
511 runTimes_.procTimes()[0]
515 "cellProcAddressing",
516 completeMesh().facesInstance(),
517 completeMesh().meshDir(),
518 runTimes_.procTimes()[0]
533 readCompleteAddressing();
536 <<
nl <<
" Processor meshes exist but have no addressing."
537 <<
nl <<
nl <<
" This could be because the processor meshes "
538 <<
"have changed. Decomposing the" <<
nl <<
" mesh would "
539 <<
"overwrite that change. If you are sure that this is "
540 <<
"appropriate," <<
nl <<
" then delete the "
542 <<
" directories and re-run this" <<
nl <<
" command."
552 completeMesh().facesInstance()
553 != runTimes_.completeTime().name()
554 && completeMesh().facesInstance()
555 != runTimes_.completeTime().constant()
559 <<
"Cannot begin mesh decomposition at time "
560 <<
fileName(runTimes_.completeTime().name()) <<
nl
561 <<
"The mesh at this instant is that of an earlier"
562 <<
" time " << completeMesh().facesInstance() <<
nl
563 <<
"Decomposition must start from this earlier time"
573 unconformReadDecompose();
582 completeMesh_->stitcher().connect(
false,
false,
true);
588 if (!completeConformal())
590 procFaceAddressingBf_.clear();
592 forAll(procMeshes_, proci)
594 procMeshes_[proci].conform();
604 const bool decomposed,
612 writeProcPoints(completeMesh().facesInstance());
624 procMeshes()[0].facesInstance(),
625 procMeshes()[0].meshDir(),
626 runTimes_.completeTime()
631 procMeshes()[0].facesInstance(),
632 procMeshes()[0].meshDir(),
633 runTimes_.completeTime()
637 "cellProcAddressing",
638 procMeshes()[0].facesInstance(),
650 procMeshes()[0].pointsInstance(),
651 procMeshes()[0].meshDir(),
652 runTimes_.completeTime()
663 readProcsAddressing();
666 <<
nl <<
" A complete mesh exists but has no "
667 << addrIo.
name() <<
" addressing." <<
nl <<
nl <<
" This "
668 <<
"could be because the complete mesh has changed. "
669 <<
"Reconstructing the" <<
nl <<
" mesh would overwrite "
670 <<
"that change. If you are sure that this is appropriate,"
672 <<
" directory and re-run this command." <<
nl <<
nl
673 <<
" Or, it could be because the complete and processor "
674 <<
"meshes were decomposed" <<
nl <<
" by a version of "
675 <<
"OpenFOAM that pre-dates the automatic generation of "
676 <<
nl <<
" " << addrIo.
name() <<
" addressing. This will be "
677 <<
"assumed and the " << addrIo.
name() <<
" addressing will"
678 <<
nl <<
" be re-built" <<
nl <<
endl;
680 cellProc_ =
labelList(completeMesh().nCells(), -1);
682 for (
label proci = 0; proci < nProcs(); proci++)
687 procCellAddressing_[proci]
691 writeCompleteAddressing();
700 procMeshes()[0].facesInstance()
701 != runTimes_.procTimes()[0].name()
702 && procMeshes()[0].facesInstance()
703 != runTimes_.procTimes()[0].constant()
707 <<
"Cannot begin mesh reconstruction at time "
708 <<
fileName(runTimes_.procTimes()[0].name()) <<
nl
709 <<
"The mesh at this instant is that of an earlier"
710 <<
" time " << procMeshes()[0].facesInstance() <<
nl
711 <<
"Reconstruction must start from this earlier time"
720 postReadReconstruct();
721 unconformReadReconstruct();
730 forAll(procMeshes_, proci)
732 procMeshes_[proci].stitcher().connect(
false,
false,
true);
739 if (!procsConformal())
741 procFaceAddressingBf_.clear();
743 completeMesh_->conform();
752 const bool reconstructed,
756 writeComplete(doSets);
760 writeCompletePoints(procMeshes()[0].facesInstance());
782 const label facesCompare =
785 completeMesh().facesInstance(),
786 procMeshes_[0].facesInstance()
790 if (facesCompare == -1)
802 if (facesCompare == +1)
805 <<
"Cannot decompose at time "
806 << procMeshes_[0].facesInstance()
807 <<
" because the processor mesh topology has evolved further"
814 const label pointsCompare =
817 completeMesh().pointsInstance(),
818 procMeshes_[0].pointsInstance()
823 if (pointsCompare == -1)
829 if (pointsCompare == +1)
832 <<
"Cannot decompose at time "
833 << procMeshes_[0].pointsInstance()
834 <<
" because the processor mesh geometry has evolved further"
841 postReadUpdateDecompose(stat);
842 unconformReadUpdateDecompose(stat);
856 procFaceAddressingBf_.clear();
858 completeMesh_->stitcher().connect(
false,
false,
true);
870 forAll(procMeshes_, proci)
872 procMeshes_[proci].conform();
889 const label facesCompare =
892 completeMesh().facesInstance(),
893 procMeshes_[0].facesInstance()
897 if (facesCompare == -1)
900 <<
"Cannot reconstruct at time "
901 << completeMesh().facesInstance()
902 <<
" because the complete mesh topology has evolved further"
914 if (facesCompare == +1)
922 const label pointsCompare =
925 completeMesh().pointsInstance(),
926 procMeshes_[0].pointsInstance()
930 if (pointsCompare == -1)
933 <<
"Cannot reconstruct at time "
934 << completeMesh().pointsInstance()
935 <<
" because the complete mesh geometry has evolved further"
941 if (pointsCompare == +1)
949 postReadUpdateReconstruct(stat);
950 unconformReadUpdateReconstruct(stat);
964 procFaceAddressingBf_.clear();
966 forAll(procMeshes_, proci)
968 procMeshes_[proci].stitcher().connect(
false,
false,
true);
981 completeMesh_->conform();
995 this->nonConformalProcFaceAddressingBf();
998 procFaceAddressingBf_.resize(nProcs());
999 forAll(procMeshes_, proci)
1001 const fvMesh& procMesh = procMeshes_[proci];
1003 procFaceAddressingBf_.
set
1010 calculatedFvsPatchLabelField::typeName
1018 if (isA<nonConformalFvPatch>(fvp))
1020 procFaceAddressingBf_[proci][procPatchi] =
1021 nonConformalProcFaceAddressingBf[proci][procPatchi];
1023 else if (isA<processorCyclicFvPatch>(fvp))
1025 const label completePatchi =
1026 refCast<const processorCyclicFvPatch>(fvp)
1029 procFaceAddressingBf_[proci][procPatchi] =
1031 - completeMesh().boundaryMesh()[completePatchi].start();
1033 else if (isA<processorFvPatch>(fvp))
1035 procFaceAddressingBf_[proci][procPatchi] =
1040 procFaceAddressingBf_[proci][procPatchi] =
1042 - completeMesh().boundaryMesh()[procPatchi].start();
1048 return procFaceAddressingBf_;
1054 const bool topologyWrite =
1062 completeMesh().write();
1066 if (!topologyWrite)
return;
1074 runTimes_.procTimes()[0].name(),
1093 reconstructSet<faceSet>(iter.key())->write();
1097 reconstructSet<cellSet>(iter.key())->write();
1101 reconstructSet<pointSet>(iter.key())->write();
1109 for (
label proci = 0; proci < nProcs(); proci++)
1111 const fvMesh& procMesh = procMeshes_[proci];
1113 cellMaps.
set(proci, &procCellAddressing_[proci]);
1114 pointMaps.
set(proci, &procPointAddressing_[proci]);
1123 completeMesh().facesInstance(),
1138 completeMesh().facesInstance(),
1157 const bool topologyWrite =
1162 for (
label proci = 0; proci < nProcs(); proci++)
1164 const fvMesh& procMesh = procMeshes_[proci];
1175 if (!topologyWrite)
return;
1183 completeMesh().facesInstance(),
1203 decomposeSet<cellSet>(iter.key());
1204 forAll(procCellSets, proci)
1206 procCellSets[proci].write();
1212 decomposeSet<faceSet>(iter.key());
1213 forAll(procFaceSets, proci)
1215 procFaceSets[proci].write();
1221 decomposeSet<pointSet>(iter.key());
1222 forAll(procPointSets, proci)
1224 procPointSets[proci].write();
1235 completeMesh().facesInstance(),
1243 for (
label proci = 0; proci < nProcs(); proci++)
1245 const fvMesh& procMesh = procMeshes_[proci];
1252 completeMesh().facesInstance(),
1260 procCellAddressing_[proci],
1261 procPointAddressing_[proci]
1270 template<
class SetType>
1278 const SetType completeSet(completeMesh_,
name);
1280 for (
label proci = 0; proci < nProcs(); proci++)
1282 const fvMesh& procMesh = procMeshes_[proci];
1287 new SetType(procMesh,
name, completeSet.size()/nProcs())
1290 for (
label i = 0; i < result[proci].maxSize(procMesh); ++ i)
1292 if (completeSet.found(setIndex<SetType>(proci, i)))
1294 result[proci].insert(i);
1305 Foam::domainDecomposition::decomposeSet<Foam::cellSet>
1313 Foam::domainDecomposition::decomposeSet<Foam::faceSet>
1321 Foam::domainDecomposition::decomposeSet<Foam::pointSet>
1327 template<
class SetType>
1335 for (
label proci = 0; proci < nProcs(); proci++)
1337 const fvMesh& procMesh = procMeshes_[proci];
1343 result().insert(setIndex<SetType>(proci, iter.key()));
1353 Foam::domainDecomposition::reconstructSet<Foam::cellSet>
1361 Foam::domainDecomposition::reconstructSet<Foam::faceSet>
1369 Foam::domainDecomposition::reconstructSet<Foam::pointSet>
#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, GeoMesh, PrimitiveField > & null()
Return a null geometric field.
bool set(const Key &, const T &newElmt)
Set a new hashedEntry, overwriting existing entries.
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.
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.
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.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Automatic domain decomposition class for finite-volume meshes.
bool readDecompose(const bool doPost)
Read in the complete mesh. Read the processor meshes if they are.
fvMesh::readUpdateState readUpdateDecompose(const bool doPost)
Read-update for decomposition.
fvMesh::readUpdateState readUpdateReconstruct(const bool doPost)
Read-update for reconstruction.
void postReadReconstruct()
Post-read-construction steps for the meshes after read-reconstruct.
void postReadDecompose()
Post-read-construction steps for the meshes after read-decompose.
PtrList< SetType > decomposeSet(const word &name) const
Decompose a set.
void unconformReadReconstruct()
Synchronise non-conformal structure after read-reconstruct.
void readComplete()
Read the complete mesh only.
autoPtr< SetType > reconstructSet(const word &name) const
Reconstruct a set.
void unconformReadUpdateReconstruct(const fvMesh::readUpdateState stat)
Synchronise non-conformal structure after read-update-reconstruct.
void postReadUpdateReconstruct(const fvMesh::readUpdateState stat)
Complete read-update-reconstruct.
fvMesh::readUpdateState readUpdateComplete()
Read-update the complete mesh only.
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.
bool readReconstruct(const bool doPost)
Read in the processor meshes. Read the complete mesh if it is.
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)
domainDecomposition(const processorRunTimes &procRunTimes, const fileName &meshPath, const word ®ionName, const multiDomainDecomposition ®ionMeshes=NullObjectRef< multiDomainDecomposition >())
Construct from processor run times and region name.
void unconformReadDecompose()
Synchronise non-conformal structure after read-decompose.
void unconformReadUpdateDecompose(const fvMesh::readUpdateState stat)
Synchronise non-conformal structure after read-update-decompose.
virtual ~domainDecomposition()
Destructor.
A class for handling file names.
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.
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....
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.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
vectorIOField pointIOField
pointIOField is a vectorIOField.
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
IOList< label > labelIOList
Label container classes.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.