70 for (
const instant& t : timeDirs)
72 if (!masterTimeDirSet.found(t.name()))
81 int main(
int argc,
char *argv[])
85 "Reconstruct fields of a parallel case" 90 timeSelector::addOptions(
true,
true);
91 argList::noParallel();
95 argList::addVerboseOption();
100 "Specify single or multiple fields to reconstruct (all by default)." 101 " Eg, 'T' or '(p T U \"alpha.*\")'" 103 argList::addBoolOption
106 "Skip reconstructing fields" 108 argList::addOptionCompat(
"no-fields", {
"noFields", 2106});
113 "Specify single or multiple lagrangian fields to reconstruct" 116 " - Positions are always included." 118 argList::addBoolOption
121 "Skip reconstructing lagrangian positions and fields" 123 argList::addOptionCompat(
"no-lagrangian", {
"noLagrangian", 2106});
125 argList::addBoolOption
128 "Skip reconstructing cellSets, faceSets, pointSets" 130 argList::addOptionCompat(
"no-sets", {
"noSets", 2106});
132 argList::addBoolOption
135 "Only reconstruct new times (i.e. that do not exist already)" 142 const bool doFields = !
args.
found(
"no-fields");
143 wordRes selectedFields;
151 Info<<
"Skipping reconstructing fields";
154 Info<<
". Ignore -fields option";
160 const bool doFiniteArea = !
args.
found(
"no-finite-area");
163 Info<<
"Skipping reconstructing finiteArea mesh/fields" 168 const bool doLagrangian = !
args.
found(
"no-lagrangian");
169 wordRes selectedLagrangianFields;
175 "lagrangianFields", selectedLagrangianFields
180 Info<<
"Skipping reconstructing lagrangian positions/fields";
183 Info<<
". Ignore -lagrangianFields option";
189 const bool doReconstructSets = !
args.
found(
"no-sets");
191 if (!doReconstructSets)
193 Info<<
"Skipping reconstructing cellSets, faceSets and pointSets" 197 const bool newTimes =
args.
found(
"newTimes");
208 <<
"No regions specified or detected." 211 else if (
regionNames[0] == polyMesh::defaultRegion)
228 <<
"No processor* directories found" 233 const_cast<fileOperation&
>(
fileHandler()).nProcs(nProcs);
236 PtrList<Time> databases(nProcs);
245 Time::controlDictName,
258 databases[0].times(),
269 if (timeDirs.empty())
280 masterTimeDirs =
runTime.times();
282 wordHashSet masterTimeDirSet(2*masterTimeDirs.size());
283 for (
const instant& t : masterTimeDirs)
285 masterTimeDirSet.
insert(t.name());
292 databases[proci].setTime(
runTime);
301 Info<<
"\n\nReconstructing fields" <<
nl 309 && haveAllTimes(masterTimeDirSet, timeDirs)
313 <<
" since already have all times" 332 processorMeshes procMeshes(databases,
regionName);
337 if (newTimes && masterTimeDirSet.found(timeDirs[timei].name()))
339 Info<<
"Skipping time " << timeDirs[timei].name()
346 runTime.setTime(timeDirs[timei], timei);
353 databases[proci].setTime(timeDirs[timei], timei);
357 polyMesh::readUpdateState meshStat =
mesh.readUpdate();
359 polyMesh::readUpdateState procStat = procMeshes.readUpdate();
361 if (procStat == polyMesh::POINTS_MOVED)
365 procMeshes.reconstructPoints(
mesh);
367 else if (meshStat != procStat)
370 <<
"readUpdate for the reconstructed mesh:" 372 <<
"readUpdate for the processor meshes :" 374 <<
"These should be equal or your addressing" 375 <<
" might be incorrect." 376 <<
" Please check your time directories for any " 377 <<
"mesh directories." <<
endl;
384 procMeshes.meshes()[0],
385 databases[0].timeName(),
386 IOobjectOption::NO_REGISTER
389 IOobjectList faObjects;
391 if (doFiniteArea && doFields)
395 faObjects = IOobjectList
397 procMeshes.meshes()[0],
398 databases[0].timeName(),
399 faMesh::dbDir(word::null),
400 IOobjectOption::NO_REGISTER
407 Info<<
"Reconstructing FV fields" <<
nl <<
endl;
409 fvFieldReconstructor reconstructor
413 procMeshes.faceProcAddressing(),
414 procMeshes.cellProcAddressing(),
415 procMeshes.boundaryProcAddressing()
418 reconstructor.reconstructAllFields(objects, selectedFields);
420 if (reconstructor.nReconstructed() == 0)
428 Info<<
"Reconstructing point fields" <<
nl <<
endl;
431 PtrList<pointMesh> pMeshes(procMeshes.meshes().size());
438 new pointMesh(procMeshes.meshes()[proci])
442 pointFieldReconstructor reconstructor
446 procMeshes.pointProcAddressing(),
447 procMeshes.boundaryProcAddressing()
450 reconstructor.reconstructAllFields(objects, selectedFields);
452 if (reconstructor.nReconstructed() == 0)
468 HashTable<IOobjectList> allCloudObjects;
472 fileName lagrangianDir
476 databases[proci].timePath()
483 if (!lagrangianDir.empty())
492 for (
const fileName& cloudDir : cloudDirs)
496 if (!allCloudObjects.found(cloudDir))
499 IOobjectList localObjs
501 procMeshes.meshes()[proci],
502 databases[proci].timeName(),
503 cloud::prefix/cloudDir
508 localObjs.found(
"coordinates")
509 || localObjs.found(
"positions")
512 allCloudObjects.insert(cloudDir, localObjs);
519 if (allCloudObjects.size())
521 lagrangianReconstructor reconstructor
525 procMeshes.faceProcAddressing(),
526 procMeshes.cellProcAddressing()
535 const IOobjectList& cloudObjs = iter.val();
537 Info<<
"Reconstructing lagrangian fields for cloud " 540 reconstructor.reconstructPositions(
cloudName);
542 reconstructor.reconstructAllFields
546 selectedLagrangianFields
572 Info <<
"Reconstructing FA fields" <<
nl <<
endl;
576 processorFaMeshes procFaMeshes(procMeshes.meshes());
578 faFieldReconstructor reconstructor
581 procFaMeshes.meshes(),
582 procFaMeshes.edgeProcAddressing(),
583 procFaMeshes.faceProcAddressing(),
584 procFaMeshes.boundaryProcAddressing()
587 reconstructor.reconstructAllFields(faObjects);
594 if (doReconstructSets)
597 HashTable<label> cSetNames;
598 HashTable<label> fSetNames;
599 HashTable<label> pSetNames;
601 forAll(procMeshes.meshes(), proci)
603 const fvMesh& procMesh = procMeshes.meshes()[proci];
613 polyMesh::meshSubDir/
"sets" 616 for (
const IOobject&
io : objects.csorted<cellSet>())
618 cSetNames.insert(
io.name(), cSetNames.size());
621 for (
const IOobject&
io : objects.csorted<faceSet>())
623 fSetNames.insert(
io.name(), fSetNames.size());
626 for (
const IOobject&
io : objects.csorted<pointSet>())
628 pSetNames.insert(
io.name(), pSetNames.size());
632 if (cSetNames.size() || fSetNames.size() || pSetNames.size())
635 PtrList<cellSet> cellSets(cSetNames.size());
636 PtrList<faceSet> faceSets(fSetNames.size());
637 PtrList<pointSet> pointSets(pSetNames.size());
639 Info<<
"Reconstructing sets:" <<
endl;
640 if (cSetNames.size())
643 << cSetNames.sortedToc() <<
endl;
645 if (fSetNames.size())
648 << fSetNames.sortedToc() <<
endl;
650 if (pSetNames.size())
653 << pSetNames.sortedToc() <<
endl;
657 forAll(procMeshes.meshes(), proci)
659 const fvMesh& procMesh = procMeshes.meshes()[proci];
665 polyMesh::meshSubDir/
"sets" 670 procMeshes.cellProcAddressing()[proci];
672 for (
const IOobject&
io : objects.csorted<cellSet>())
675 const cellSet procSet(
io);
676 const label seti = cSetNames[
io.name()];
677 if (!cellSets.set(seti))
690 cellSet& cSet = cellSets[seti];
691 cSet.instance() =
runTime.timeName();
693 for (
const label celli : procSet)
695 cSet.insert(cellMap[celli]);
701 procMeshes.faceProcAddressing()[proci];
703 for (
const IOobject&
io : objects.csorted<faceSet>())
706 const faceSet procSet(
io);
707 const label seti = fSetNames[
io.name()];
708 if (!faceSets.set(seti))
721 faceSet& fSet = faceSets[seti];
722 fSet.instance() =
runTime.timeName();
724 for (
const label facei : procSet)
731 procMeshes.pointProcAddressing()[proci];
733 for (
const IOobject&
io : objects.csorted<pointSet>())
736 const pointSet procSet(
io);
737 const label seti = pSetNames[
io.name()];
738 if (!pointSets.set(seti))
751 pointSet& pSet = pointSets[seti];
752 pSet.instance() =
runTime.timeName();
754 for (
const label pointi : procSet)
756 pSet.insert(pointMap[pointi]);
763 for (
const auto&
set : cellSets)
767 for (
const auto&
set : faceSets)
771 for (
const auto&
set : pointSets)
780 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
782 forAll(procMeshes.meshes(), procI)
784 const fvMesh& procMesh = procMeshes.meshes()[procI];
794 procMesh.time().timeName(),
795 polyMesh::meshSubDir,
797 IOobject::READ_IF_PRESENT,
799 IOobject::NO_REGISTER
807 const PtrList<labelIOList>& cellAddr =
808 procMeshes.cellProcAddressing();
810 UPtrList<const labelList> cellMaps(cellAddr.size());
813 cellMaps.set(i, &cellAddr[i]);
816 const PtrList<labelIOList>& pointAddr =
817 procMeshes.pointProcAddressing();
819 UPtrList<const labelList> pointMaps(pointAddr.size());
822 pointMaps.set(i, &pointAddr[i]);
825 UPtrList<const hexRef8Data> procRefs(procData.size());
828 procRefs.set(i, &procData[i]);
836 mesh.time().timeName(),
837 polyMesh::meshSubDir,
841 IOobject::NO_REGISTER
853 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
855 forAll(procMeshes.meshes(), procI)
857 const fvMesh& procMesh = procMeshes.meshes()[procI];
867 procMesh.time().timeName(),
868 polyMesh::meshSubDir,
870 IOobject::READ_IF_PRESENT,
872 IOobject::NO_REGISTER
880 const PtrList<labelIOList>& cellAddr =
881 procMeshes.cellProcAddressing();
883 UPtrList<const labelList> cellMaps(cellAddr.size());
886 cellMaps.set(i, &cellAddr[i]);
889 const PtrList<labelIOList>& pointAddr =
890 procMeshes.pointProcAddressing();
892 UPtrList<const labelList> pointMaps(pointAddr.size());
895 pointMaps.set(i, &pointAddr[i]);
898 UPtrList<const hexRef8Data> procRefs(procData.size());
901 procRefs.set(i, &procData[i]);
909 mesh.time().timeName(),
910 polyMesh::meshSubDir,
914 IOobject::NO_REGISTER
929 databases[0].timePath()/
regionDir/
"uniform" 933 if (!uniformDir0.empty() &&
fileHandler().isDir(uniformDir0))
947 databases[0].timePath()/
"uniform" 951 if (!uniformDir0.empty() &&
fileHandler().isDir(uniformDir0))
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
constexpr char nl
The newline '\n' character (0x0a)
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.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
GeometricField< symmTensor, faPatchField, areaMesh > areaSymmTensorField
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
bool allowFunctionObjects() const
The controlDict 'functions' entry is allowed to be used.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
#define forAll(list, i)
Loop across all elements in list.
StringType validate(const std::string &str, const UnaryPredicate &accept, const bool invert=false)
Return a copy of the input string with validated characters.
bool allowLibs() const
The controlDict 'libs' entry is allowed to be used. (eg, has not been disabled by the -no-libs option...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
const word cloudName(propsDict.get< word >("cloud"))
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
GeometricField< tensor, faPatchField, areaMesh > areaTensorField
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
GeometricField< sphericalTensor, faPatchField, areaMesh > areaSphericalTensorField
const fileName & rootPath() const noexcept
Return root path.
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
fileName path() const
Return the full path to the (processor local) case.
#define WarningInFunction
Report a warning using Foam::Warning.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
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)
List< instant > instantList
List of instants.
List< fileName > fileNameList
List of fileName.
Foam::argList args(argc, argv)
GeometricField< vector, faPatchField, areaMesh > areaVectorField
bool found(const word &optName) const
Return true if the named option is found.
forAllConstIters(mixture.phases(), phase)
GeometricField< scalar, faPatchField, areaMesh > areaScalarField