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();
96 argList::addVerboseOption();
101 "Specify single or multiple fields to reconstruct (all by default)." 102 " Eg, 'T' or '(p T U \"alpha.*\")'" 104 argList::addBoolOption
107 "Skip reconstructing fields" 109 argList::addOptionCompat(
"no-fields", {
"noFields", 2106});
114 "Specify single or multiple lagrangian fields to reconstruct" 117 " - Positions are always included." 119 argList::addBoolOption
122 "Skip reconstructing lagrangian positions and fields" 124 argList::addOptionCompat(
"no-lagrangian", {
"noLagrangian", 2106});
126 argList::addBoolOption
129 "Skip reconstructing cellSets, faceSets, pointSets" 131 argList::addOptionCompat(
"no-sets", {
"noSets", 2106});
133 argList::addBoolOption
136 "Only reconstruct new times (i.e. that do not exist already)" 148 const bool doFields = !
args.
found(
"no-fields");
149 wordRes selectedFields;
157 Info<<
"Skipping reconstructing fields";
160 Info<<
". Ignore -fields option";
166 const bool doFiniteArea = !
args.
found(
"no-finite-area");
169 Info<<
"Skipping reconstructing finiteArea mesh/fields" 174 const bool doLagrangian = !
args.
found(
"no-lagrangian");
175 wordRes selectedLagrangianFields;
181 "lagrangianFields", selectedLagrangianFields
186 Info<<
"Skipping reconstructing lagrangian positions/fields";
189 Info<<
". Ignore -lagrangianFields option";
195 const bool doReconstructSets = !
args.
found(
"no-sets");
197 if (!doReconstructSets)
199 Info<<
"Skipping reconstructing cellSets, faceSets and pointSets" 203 const bool newTimes =
args.
found(
"newTimes");
222 <<
"No regions specified or detected." 225 else if (
regionNames[0] == polyMesh::defaultRegion)
242 <<
"No processor* directories found" 250 PtrList<Time> databases(nProcs);
259 Time::controlDictName,
272 databases[0].times(),
283 if (timeDirs.empty())
294 masterTimeDirs =
runTime.times();
296 wordHashSet masterTimeDirSet(2*masterTimeDirs.size());
297 for (
const instant& t : masterTimeDirs)
299 masterTimeDirSet.
insert(t.name());
306 databases[proci].setTime(
runTime);
315 Info<<
"\n\nReconstructing fields" <<
nl 323 && haveAllTimes(masterTimeDirSet, timeDirs)
327 <<
" since already have all times" 346 processorMeshes procMeshes(databases,
regionName);
351 if (newTimes && masterTimeDirSet.found(timeDirs[timei].name()))
353 Info<<
"Skipping time " << timeDirs[timei].name()
360 runTime.setTime(timeDirs[timei], timei);
367 databases[proci].setTime(timeDirs[timei], timei);
371 polyMesh::readUpdateState meshStat =
mesh.readUpdate();
373 polyMesh::readUpdateState procStat = procMeshes.readUpdate();
375 if (procStat == polyMesh::POINTS_MOVED)
379 procMeshes.reconstructPoints(
mesh);
381 else if (meshStat != procStat)
384 <<
"readUpdate for the reconstructed mesh:" 386 <<
"readUpdate for the processor meshes :" 388 <<
"These should be equal or your addressing" 389 <<
" might be incorrect." 390 <<
" Please check your time directories for any " 391 <<
"mesh directories." <<
endl;
398 procMeshes.meshes()[0],
399 databases[0].timeName(),
400 IOobjectOption::NO_REGISTER
404 HashTable<IOobjectList> faObjects;
406 if (doFiniteArea && doFields)
416 procMeshes.meshes()[0],
417 databases[0].timeName(),
418 faMesh::dbDir(areaName),
419 IOobjectOption::NO_REGISTER
424 faObjects.emplace_set(areaName, std::move(objs));
432 Info<<
"Reconstructing FV fields" <<
nl <<
endl;
434 fvFieldReconstructor reconstructor
438 procMeshes.faceProcAddressing(),
439 procMeshes.cellProcAddressing(),
440 procMeshes.boundaryProcAddressing()
443 reconstructor.reconstructAllFields(objects, selectedFields);
445 if (reconstructor.nReconstructed() == 0)
453 Info<<
"Reconstructing point fields" <<
nl <<
endl;
458 IOobject::READ_IF_PRESENT
461 pointFieldReconstructor reconstructor
464 procMeshes.pointMeshes(),
465 procMeshes.pointProcAddressing(),
466 procMeshes.pointMeshBoundaryProcAddressing()
469 reconstructor.reconstructAllFields(objects, selectedFields);
471 if (reconstructor.nReconstructed() == 0)
487 HashTable<IOobjectList> allCloudObjects;
491 fileName lagrangianDir
495 databases[proci].timePath()
502 if (!lagrangianDir.empty())
511 for (
const fileName& cloudDir : cloudDirs)
515 if (!allCloudObjects.found(cloudDir))
518 IOobjectList localObjs
520 procMeshes.meshes()[proci],
521 databases[proci].timeName(),
522 cloud::prefix/cloudDir
527 localObjs.found(
"coordinates")
528 || localObjs.found(
"positions")
531 allCloudObjects.insert(cloudDir, localObjs);
538 if (allCloudObjects.size())
540 lagrangianReconstructor reconstructor
544 procMeshes.faceProcAddressing(),
545 procMeshes.cellProcAddressing()
554 const IOobjectList& cloudObjs = iter.val();
556 Info<<
"Reconstructing lagrangian fields for cloud " 559 reconstructor.reconstructPositions(
cloudName);
561 reconstructor.reconstructAllFields
565 selectedLagrangianFields
579 bool hadFaFields =
false;
582 const auto objs = faObjects.cfind(areaName);
587 const auto& faObjs = objs.val();
600 Info<<
"Reconstructing finite-area fields [" 604 const faMesh aMesh(areaName,
mesh);
606 processorFaMeshes procFaMeshes
612 faFieldReconstructor reconstructor
615 procFaMeshes.meshes(),
616 procFaMeshes.edgeProcAddressing(),
617 procFaMeshes.faceProcAddressing(),
618 procFaMeshes.boundaryProcAddressing()
621 reconstructor.reconstructAllFields(faObjs);
626 Info <<
"No finite-area fields" <<
nl <<
endl;
631 if (doReconstructSets)
634 HashTable<label> cSetNames;
635 HashTable<label> fSetNames;
636 HashTable<label> pSetNames;
638 forAll(procMeshes.meshes(), proci)
640 const fvMesh& procMesh = procMeshes.meshes()[proci];
650 polyMesh::meshSubDir/
"sets" 653 for (
const IOobject&
io : objects.csorted<cellSet>())
655 cSetNames.insert(
io.name(), cSetNames.size());
658 for (
const IOobject&
io : objects.csorted<faceSet>())
660 fSetNames.insert(
io.name(), fSetNames.size());
663 for (
const IOobject&
io : objects.csorted<pointSet>())
665 pSetNames.insert(
io.name(), pSetNames.size());
669 if (cSetNames.size() || fSetNames.size() || pSetNames.size())
672 PtrList<cellSet> cellSets(cSetNames.size());
673 PtrList<faceSet> faceSets(fSetNames.size());
674 PtrList<pointSet> pointSets(pSetNames.size());
676 Info<<
"Reconstructing sets:" <<
endl;
677 if (cSetNames.size())
680 << cSetNames.sortedToc() <<
endl;
682 if (fSetNames.size())
685 << fSetNames.sortedToc() <<
endl;
687 if (pSetNames.size())
690 << pSetNames.sortedToc() <<
endl;
694 forAll(procMeshes.meshes(), proci)
696 const fvMesh& procMesh = procMeshes.meshes()[proci];
702 polyMesh::meshSubDir/
"sets" 707 procMeshes.cellProcAddressing()[proci];
709 for (
const IOobject&
io : objects.csorted<cellSet>())
712 const cellSet procSet(
io);
713 const label seti = cSetNames[
io.name()];
714 if (!cellSets.set(seti))
727 cellSet& cSet = cellSets[seti];
728 cSet.instance() =
runTime.timeName();
730 for (
const label celli : procSet)
732 cSet.insert(cellMap[celli]);
738 procMeshes.faceProcAddressing()[proci];
740 for (
const IOobject&
io : objects.csorted<faceSet>())
743 const faceSet procSet(
io);
744 const label seti = fSetNames[
io.name()];
745 if (!faceSets.set(seti))
758 faceSet& fSet = faceSets[seti];
759 fSet.instance() =
runTime.timeName();
761 for (
const label facei : procSet)
768 procMeshes.pointProcAddressing()[proci];
770 for (
const IOobject&
io : objects.csorted<pointSet>())
773 const pointSet procSet(
io);
774 const label seti = pSetNames[
io.name()];
775 if (!pointSets.set(seti))
788 pointSet& pSet = pointSets[seti];
789 pSet.instance() =
runTime.timeName();
791 for (
const label pointi : procSet)
793 pSet.insert(pointMap[pointi]);
800 for (
const auto&
set : cellSets)
804 for (
const auto&
set : faceSets)
808 for (
const auto&
set : pointSets)
817 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
819 forAll(procMeshes.meshes(), procI)
821 const fvMesh& procMesh = procMeshes.meshes()[procI];
831 procMesh.time().timeName(),
832 polyMesh::meshSubDir,
834 IOobject::READ_IF_PRESENT,
836 IOobject::NO_REGISTER
844 const PtrList<labelIOList>& cellAddr =
845 procMeshes.cellProcAddressing();
847 UPtrList<const labelList> cellMaps(cellAddr.size());
850 cellMaps.set(i, &cellAddr[i]);
853 const PtrList<labelIOList>& pointAddr =
854 procMeshes.pointProcAddressing();
856 UPtrList<const labelList> pointMaps(pointAddr.size());
859 pointMaps.set(i, &pointAddr[i]);
862 UPtrList<const hexRef8Data> procRefs(procData.size());
865 procRefs.set(i, &procData[i]);
873 mesh.time().timeName(),
874 polyMesh::meshSubDir,
878 IOobject::NO_REGISTER
890 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
892 forAll(procMeshes.meshes(), procI)
894 const fvMesh& procMesh = procMeshes.meshes()[procI];
904 procMesh.time().timeName(),
905 polyMesh::meshSubDir,
907 IOobject::READ_IF_PRESENT,
909 IOobject::NO_REGISTER
917 const PtrList<labelIOList>& cellAddr =
918 procMeshes.cellProcAddressing();
920 UPtrList<const labelList> cellMaps(cellAddr.size());
923 cellMaps.set(i, &cellAddr[i]);
926 const PtrList<labelIOList>& pointAddr =
927 procMeshes.pointProcAddressing();
929 UPtrList<const labelList> pointMaps(pointAddr.size());
932 pointMaps.set(i, &pointAddr[i]);
935 UPtrList<const hexRef8Data> procRefs(procData.size());
938 procRefs.set(i, &procData[i]);
946 mesh.time().timeName(),
947 polyMesh::meshSubDir,
951 IOobject::NO_REGISTER
966 databases[0].timePath()/
regionDir/
"uniform" 970 if (!uniformDir0.empty() &&
fileHandler().isDir(uniformDir0))
984 databases[0].timePath()/
"uniform" 988 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.
bool allowFaModels() noexcept
The enable/disable state for regionFaModel (default: true)
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()
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
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
bool is_area(const word &clsName)
Test if the class name appears to be an area field.
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.
List< instant > instantList
List of instants.
List< fileName > fileNameList
List of fileName.
Foam::argList args(argc, argv)
bool found(const word &optName) const
Return true if the named option is found.
forAllConstIters(mixture.phases(), phase)