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()
391 Info<<
"Reconstructing FV fields" <<
nl <<
endl;
393 fvFieldReconstructor reconstructor
397 procMeshes.faceProcAddressing(),
398 procMeshes.cellProcAddressing(),
399 procMeshes.boundaryProcAddressing()
402 reconstructor.reconstructAllFields(objects, selectedFields);
404 if (reconstructor.nReconstructed() == 0)
412 Info<<
"Reconstructing point fields" <<
nl <<
endl;
415 PtrList<pointMesh> pMeshes(procMeshes.meshes().size());
422 new pointMesh(procMeshes.meshes()[proci])
426 pointFieldReconstructor reconstructor
430 procMeshes.pointProcAddressing(),
431 procMeshes.boundaryProcAddressing()
434 reconstructor.reconstructAllFields(objects, selectedFields);
436 if (reconstructor.nReconstructed() == 0)
452 HashTable<IOobjectList> allCloudObjects;
456 fileName lagrangianDir
460 databases[proci].timePath()
467 if (!lagrangianDir.empty())
476 for (
const fileName& cloudDir : cloudDirs)
480 if (!allCloudObjects.found(cloudDir))
483 IOobjectList localObjs
485 procMeshes.meshes()[proci],
486 databases[proci].timeName(),
487 cloud::prefix/cloudDir
492 localObjs.found(
"coordinates")
493 || localObjs.found(
"positions")
496 allCloudObjects.insert(cloudDir, localObjs);
503 if (allCloudObjects.size())
505 lagrangianReconstructor reconstructor
509 procMeshes.faceProcAddressing(),
510 procMeshes.cellProcAddressing()
519 const IOobjectList& cloudObjs = iter.val();
521 Info<<
"Reconstructing lagrangian fields for cloud " 524 reconstructor.reconstructPositions(
cloudName);
526 reconstructor.reconstructAllFields
530 selectedLagrangianFields
556 Info <<
"Reconstructing FA fields" <<
nl <<
endl;
560 processorFaMeshes procFaMeshes(procMeshes.meshes());
562 faFieldReconstructor reconstructor
565 procFaMeshes.meshes(),
566 procFaMeshes.edgeProcAddressing(),
567 procFaMeshes.faceProcAddressing(),
568 procFaMeshes.boundaryProcAddressing()
571 reconstructor.reconstructAllFields(objects);
578 if (doReconstructSets)
581 HashTable<label> cSetNames;
582 HashTable<label> fSetNames;
583 HashTable<label> pSetNames;
585 forAll(procMeshes.meshes(), proci)
587 const fvMesh& procMesh = procMeshes.meshes()[proci];
597 polyMesh::meshSubDir/
"sets" 600 for (
const IOobject&
io : objects.csorted<cellSet>())
602 cSetNames.insert(
io.name(), cSetNames.size());
605 for (
const IOobject&
io : objects.csorted<faceSet>())
607 fSetNames.insert(
io.name(), fSetNames.size());
610 for (
const IOobject&
io : objects.csorted<pointSet>())
612 pSetNames.insert(
io.name(), pSetNames.size());
616 if (cSetNames.size() || fSetNames.size() || pSetNames.size())
619 PtrList<cellSet> cellSets(cSetNames.size());
620 PtrList<faceSet> faceSets(fSetNames.size());
621 PtrList<pointSet> pointSets(pSetNames.size());
623 Info<<
"Reconstructing sets:" <<
endl;
624 if (cSetNames.size())
627 << cSetNames.sortedToc() <<
endl;
629 if (fSetNames.size())
632 << fSetNames.sortedToc() <<
endl;
634 if (pSetNames.size())
637 << pSetNames.sortedToc() <<
endl;
641 forAll(procMeshes.meshes(), proci)
643 const fvMesh& procMesh = procMeshes.meshes()[proci];
649 polyMesh::meshSubDir/
"sets" 654 procMeshes.cellProcAddressing()[proci];
656 for (
const IOobject&
io : objects.csorted<cellSet>())
659 const cellSet procSet(
io);
660 const label seti = cSetNames[
io.name()];
661 if (!cellSets.set(seti))
674 cellSet& cSet = cellSets[seti];
675 cSet.instance() =
runTime.timeName();
677 for (
const label celli : procSet)
679 cSet.insert(cellMap[celli]);
685 procMeshes.faceProcAddressing()[proci];
687 for (
const IOobject&
io : objects.csorted<faceSet>())
690 const faceSet procSet(
io);
691 const label seti = fSetNames[
io.name()];
692 if (!faceSets.set(seti))
705 faceSet& fSet = faceSets[seti];
706 fSet.instance() =
runTime.timeName();
708 for (
const label facei : procSet)
715 procMeshes.pointProcAddressing()[proci];
717 for (
const IOobject&
io : objects.csorted<pointSet>())
720 const pointSet procSet(
io);
721 const label seti = pSetNames[
io.name()];
722 if (!pointSets.set(seti))
735 pointSet& pSet = pointSets[seti];
736 pSet.instance() =
runTime.timeName();
738 for (
const label pointi : procSet)
740 pSet.insert(pointMap[pointi]);
747 for (
const auto&
set : cellSets)
751 for (
const auto&
set : faceSets)
755 for (
const auto&
set : pointSets)
764 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
766 forAll(procMeshes.meshes(), procI)
768 const fvMesh& procMesh = procMeshes.meshes()[procI];
778 procMesh.time().timeName(),
779 polyMesh::meshSubDir,
781 IOobject::READ_IF_PRESENT,
783 IOobject::NO_REGISTER
791 const PtrList<labelIOList>& cellAddr =
792 procMeshes.cellProcAddressing();
794 UPtrList<const labelList> cellMaps(cellAddr.size());
797 cellMaps.set(i, &cellAddr[i]);
800 const PtrList<labelIOList>& pointAddr =
801 procMeshes.pointProcAddressing();
803 UPtrList<const labelList> pointMaps(pointAddr.size());
806 pointMaps.set(i, &pointAddr[i]);
809 UPtrList<const hexRef8Data> procRefs(procData.size());
812 procRefs.set(i, &procData[i]);
820 mesh.time().timeName(),
821 polyMesh::meshSubDir,
825 IOobject::NO_REGISTER
837 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
839 forAll(procMeshes.meshes(), procI)
841 const fvMesh& procMesh = procMeshes.meshes()[procI];
851 procMesh.time().timeName(),
852 polyMesh::meshSubDir,
854 IOobject::READ_IF_PRESENT,
856 IOobject::NO_REGISTER
864 const PtrList<labelIOList>& cellAddr =
865 procMeshes.cellProcAddressing();
867 UPtrList<const labelList> cellMaps(cellAddr.size());
870 cellMaps.set(i, &cellAddr[i]);
873 const PtrList<labelIOList>& pointAddr =
874 procMeshes.pointProcAddressing();
876 UPtrList<const labelList> pointMaps(pointAddr.size());
879 pointMaps.set(i, &pointAddr[i]);
882 UPtrList<const hexRef8Data> procRefs(procData.size());
885 procRefs.set(i, &procData[i]);
893 mesh.time().timeName(),
894 polyMesh::meshSubDir,
898 IOobject::NO_REGISTER
913 databases[0].timePath()/
regionDir/
"uniform" 917 if (!uniformDir0.empty() &&
fileHandler().isDir(uniformDir0))
931 databases[0].timePath()/
"uniform" 935 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