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().disconnect(
false,
false);
860 completeMesh_->stitcher().connect(
false,
false,
true);
872 forAll(procMeshes_, proci)
874 procMeshes_[proci].conform();
891 const label facesCompare =
894 completeMesh().facesInstance(),
895 procMeshes_[0].facesInstance()
899 if (facesCompare == -1)
902 <<
"Cannot reconstruct at time "
903 << completeMesh().facesInstance()
904 <<
" because the complete mesh topology has evolved further"
916 if (facesCompare == +1)
924 const label pointsCompare =
927 completeMesh().pointsInstance(),
928 procMeshes_[0].pointsInstance()
932 if (pointsCompare == -1)
935 <<
"Cannot reconstruct at time "
936 << completeMesh().pointsInstance()
937 <<
" because the complete mesh geometry has evolved further"
943 if (pointsCompare == +1)
951 postReadUpdateReconstruct(stat);
952 unconformReadUpdateReconstruct(stat);
966 procFaceAddressingBf_.clear();
968 forAll(procMeshes_, proci)
970 procMeshes_[proci].stitcher().disconnect(
false,
false);
972 procMeshes_[proci].stitcher().connect(
false,
false,
true);
985 completeMesh_->conform();
998 if (procFaceAddressingBf_.empty())
1002 this->nonConformalProcFaceAddressingBf();
1005 procFaceAddressingBf_.resize(nProcs());
1006 forAll(procMeshes_, proci)
1008 const fvMesh& procMesh = procMeshes_[proci];
1010 procFaceAddressingBf_.
set
1017 calculatedFvsPatchLabelField::typeName
1025 if (isA<nonConformalFvPatch>(fvp))
1027 procFaceAddressingBf_[proci][procPatchi] =
1028 nonConformalProcFaceAddressingBf[proci][procPatchi];
1030 else if (isA<processorCyclicFvPatch>(fvp))
1032 const label completePatchi =
1033 refCast<const processorCyclicFvPatch>(fvp)
1036 procFaceAddressingBf_[proci][procPatchi] =
1038 - completeMesh().boundaryMesh()[completePatchi].start();
1040 else if (isA<processorFvPatch>(fvp))
1042 procFaceAddressingBf_[proci][procPatchi] =
1047 procFaceAddressingBf_[proci][procPatchi] =
1049 - completeMesh().boundaryMesh()[procPatchi].start();
1055 return procFaceAddressingBf_;
1061 const bool topologyWrite =
1069 completeMesh().write();
1073 if (!topologyWrite)
return;
1081 runTimes_.procTimes()[0].name(),
1100 reconstructSet<faceSet>(iter.key())->write();
1104 reconstructSet<cellSet>(iter.key())->write();
1108 reconstructSet<pointSet>(iter.key())->write();
1116 for (
label proci = 0; proci < nProcs(); proci++)
1118 const fvMesh& procMesh = procMeshes_[proci];
1120 cellMaps.
set(proci, &procCellAddressing_[proci]);
1121 pointMaps.
set(proci, &procPointAddressing_[proci]);
1130 completeMesh().facesInstance(),
1145 completeMesh().facesInstance(),
1164 const bool topologyWrite =
1169 for (
label proci = 0; proci < nProcs(); proci++)
1171 const fvMesh& procMesh = procMeshes_[proci];
1182 if (!topologyWrite)
return;
1190 completeMesh().facesInstance(),
1210 decomposeSet<cellSet>(iter.key());
1211 forAll(procCellSets, proci)
1213 procCellSets[proci].write();
1219 decomposeSet<faceSet>(iter.key());
1220 forAll(procFaceSets, proci)
1222 procFaceSets[proci].write();
1228 decomposeSet<pointSet>(iter.key());
1229 forAll(procPointSets, proci)
1231 procPointSets[proci].write();
1242 completeMesh().facesInstance(),
1250 for (
label proci = 0; proci < nProcs(); proci++)
1252 const fvMesh& procMesh = procMeshes_[proci];
1259 completeMesh().facesInstance(),
1267 procCellAddressing_[proci],
1268 procPointAddressing_[proci]
1277 template<
class SetType>
1285 const SetType completeSet(completeMesh_,
name);
1287 for (
label proci = 0; proci < nProcs(); proci++)
1289 const fvMesh& procMesh = procMeshes_[proci];
1294 new SetType(procMesh,
name, completeSet.size()/nProcs())
1297 for (
label i = 0; i < result[proci].maxSize(procMesh); ++ i)
1299 if (completeSet.found(setIndex<SetType>(proci, i)))
1301 result[proci].insert(i);
1312 Foam::domainDecomposition::decomposeSet<Foam::cellSet>
1320 Foam::domainDecomposition::decomposeSet<Foam::faceSet>
1328 Foam::domainDecomposition::decomposeSet<Foam::pointSet>
1334 template<
class SetType>
1342 for (
label proci = 0; proci < nProcs(); proci++)
1344 const fvMesh& procMesh = procMeshes_[proci];
1350 result().insert(setIndex<SetType>(proci, iter.key()));
1360 Foam::domainDecomposition::reconstructSet<Foam::cellSet>
1368 Foam::domainDecomposition::reconstructSet<Foam::faceSet>
1376 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.