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;
433 IOobject::READ_IF_PRESENT
436 pointFieldReconstructor reconstructor
439 procMeshes.pointMeshes(),
440 procMeshes.pointProcAddressing(),
441 procMeshes.pointMeshBoundaryProcAddressing()
444 reconstructor.reconstructAllFields(objects, selectedFields);
446 if (reconstructor.nReconstructed() == 0)
462 HashTable<IOobjectList> allCloudObjects;
466 fileName lagrangianDir
470 databases[proci].timePath()
477 if (!lagrangianDir.empty())
486 for (
const fileName& cloudDir : cloudDirs)
490 if (!allCloudObjects.found(cloudDir))
493 IOobjectList localObjs
495 procMeshes.meshes()[proci],
496 databases[proci].timeName(),
497 cloud::prefix/cloudDir
502 localObjs.found(
"coordinates")
503 || localObjs.found(
"positions")
506 allCloudObjects.insert(cloudDir, localObjs);
513 if (allCloudObjects.size())
515 lagrangianReconstructor reconstructor
519 procMeshes.faceProcAddressing(),
520 procMeshes.cellProcAddressing()
529 const IOobjectList& cloudObjs = iter.val();
531 Info<<
"Reconstructing lagrangian fields for cloud " 534 reconstructor.reconstructPositions(
cloudName);
536 reconstructor.reconstructAllFields
540 selectedLagrangianFields
566 Info <<
"Reconstructing FA fields" <<
nl <<
endl;
570 processorFaMeshes procFaMeshes(procMeshes.meshes());
572 faFieldReconstructor reconstructor
575 procFaMeshes.meshes(),
576 procFaMeshes.edgeProcAddressing(),
577 procFaMeshes.faceProcAddressing(),
578 procFaMeshes.boundaryProcAddressing()
581 reconstructor.reconstructAllFields(faObjects);
588 if (doReconstructSets)
591 HashTable<label> cSetNames;
592 HashTable<label> fSetNames;
593 HashTable<label> pSetNames;
595 forAll(procMeshes.meshes(), proci)
597 const fvMesh& procMesh = procMeshes.meshes()[proci];
607 polyMesh::meshSubDir/
"sets" 610 for (
const IOobject&
io : objects.csorted<cellSet>())
612 cSetNames.insert(
io.name(), cSetNames.size());
615 for (
const IOobject&
io : objects.csorted<faceSet>())
617 fSetNames.insert(
io.name(), fSetNames.size());
620 for (
const IOobject&
io : objects.csorted<pointSet>())
622 pSetNames.insert(
io.name(), pSetNames.size());
626 if (cSetNames.size() || fSetNames.size() || pSetNames.size())
629 PtrList<cellSet> cellSets(cSetNames.size());
630 PtrList<faceSet> faceSets(fSetNames.size());
631 PtrList<pointSet> pointSets(pSetNames.size());
633 Info<<
"Reconstructing sets:" <<
endl;
634 if (cSetNames.size())
637 << cSetNames.sortedToc() <<
endl;
639 if (fSetNames.size())
642 << fSetNames.sortedToc() <<
endl;
644 if (pSetNames.size())
647 << pSetNames.sortedToc() <<
endl;
651 forAll(procMeshes.meshes(), proci)
653 const fvMesh& procMesh = procMeshes.meshes()[proci];
659 polyMesh::meshSubDir/
"sets" 664 procMeshes.cellProcAddressing()[proci];
666 for (
const IOobject&
io : objects.csorted<cellSet>())
669 const cellSet procSet(
io);
670 const label seti = cSetNames[
io.name()];
671 if (!cellSets.set(seti))
684 cellSet& cSet = cellSets[seti];
685 cSet.instance() =
runTime.timeName();
687 for (
const label celli : procSet)
689 cSet.insert(cellMap[celli]);
695 procMeshes.faceProcAddressing()[proci];
697 for (
const IOobject&
io : objects.csorted<faceSet>())
700 const faceSet procSet(
io);
701 const label seti = fSetNames[
io.name()];
702 if (!faceSets.set(seti))
715 faceSet& fSet = faceSets[seti];
716 fSet.instance() =
runTime.timeName();
718 for (
const label facei : procSet)
725 procMeshes.pointProcAddressing()[proci];
727 for (
const IOobject&
io : objects.csorted<pointSet>())
730 const pointSet procSet(
io);
731 const label seti = pSetNames[
io.name()];
732 if (!pointSets.set(seti))
745 pointSet& pSet = pointSets[seti];
746 pSet.instance() =
runTime.timeName();
748 for (
const label pointi : procSet)
750 pSet.insert(pointMap[pointi]);
757 for (
const auto&
set : cellSets)
761 for (
const auto&
set : faceSets)
765 for (
const auto&
set : pointSets)
774 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
776 forAll(procMeshes.meshes(), procI)
778 const fvMesh& procMesh = procMeshes.meshes()[procI];
788 procMesh.time().timeName(),
789 polyMesh::meshSubDir,
791 IOobject::READ_IF_PRESENT,
793 IOobject::NO_REGISTER
801 const PtrList<labelIOList>& cellAddr =
802 procMeshes.cellProcAddressing();
804 UPtrList<const labelList> cellMaps(cellAddr.size());
807 cellMaps.set(i, &cellAddr[i]);
810 const PtrList<labelIOList>& pointAddr =
811 procMeshes.pointProcAddressing();
813 UPtrList<const labelList> pointMaps(pointAddr.size());
816 pointMaps.set(i, &pointAddr[i]);
819 UPtrList<const hexRef8Data> procRefs(procData.size());
822 procRefs.set(i, &procData[i]);
830 mesh.time().timeName(),
831 polyMesh::meshSubDir,
835 IOobject::NO_REGISTER
847 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
849 forAll(procMeshes.meshes(), procI)
851 const fvMesh& procMesh = procMeshes.meshes()[procI];
861 procMesh.time().timeName(),
862 polyMesh::meshSubDir,
864 IOobject::READ_IF_PRESENT,
866 IOobject::NO_REGISTER
874 const PtrList<labelIOList>& cellAddr =
875 procMeshes.cellProcAddressing();
877 UPtrList<const labelList> cellMaps(cellAddr.size());
880 cellMaps.set(i, &cellAddr[i]);
883 const PtrList<labelIOList>& pointAddr =
884 procMeshes.pointProcAddressing();
886 UPtrList<const labelList> pointMaps(pointAddr.size());
889 pointMaps.set(i, &pointAddr[i]);
892 UPtrList<const hexRef8Data> procRefs(procData.size());
895 procRefs.set(i, &procData[i]);
903 mesh.time().timeName(),
904 polyMesh::meshSubDir,
908 IOobject::NO_REGISTER
923 databases[0].timePath()/
regionDir/
"uniform" 927 if (!uniformDir0.empty() &&
fileHandler().isDir(uniformDir0))
941 databases[0].timePath()/
"uniform" 945 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)
StringType validate(const std::string &str, const UnaryPredicate &accept, const bool invert=false)
Return a copy of the input string with validated characters.
#define forAll(list, i)
Loop across all elements in list.
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