65 const wordHashSet& masterTimeDirSet,
66 const instantList& timeDirs
70 for (
const instant& t : timeDirs)
72 if (!masterTimeDirSet.found(t.name()))
81int main(
int argc,
char *argv[])
85 "Reconstruct fields of a parallel case"
90 timeSelector::addOptions(
true,
true);
91 argList::noParallel();
95 argList::addVerboseOption(
"Additional verbosity");
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()).setNProcs(nProcs);
236 PtrList<Time> databases(nProcs);
245 Time::controlDictName,
256 databases[0].times(),
267 if (timeDirs.empty())
278 masterTimeDirs =
runTime.times();
280 wordHashSet masterTimeDirSet(2*masterTimeDirs.size());
281 for (
const instant& t : masterTimeDirs)
283 masterTimeDirSet.insert(t.name());
290 databases[proci].setTime(
runTime);
299 Info<<
"\n\nReconstructing fields" <<
nl
307 && haveAllTimes(masterTimeDirSet, timeDirs)
311 <<
" since already have all times"
330 processorMeshes procMeshes(databases,
regionName);
335 if (newTimes && masterTimeDirSet.found(timeDirs[timei].name()))
337 Info<<
"Skipping time " << timeDirs[timei].name()
344 runTime.setTime(timeDirs[timei], timei);
351 databases[proci].setTime(timeDirs[timei], timei);
355 polyMesh::readUpdateState meshStat =
mesh.readUpdate();
357 polyMesh::readUpdateState procStat = procMeshes.readUpdate();
359 if (procStat == polyMesh::POINTS_MOVED)
363 procMeshes.reconstructPoints(
mesh);
365 else if (meshStat != procStat)
368 <<
"readUpdate for the reconstructed mesh:"
370 <<
"readUpdate for the processor meshes :"
372 <<
"These should be equal or your addressing"
373 <<
" might be incorrect."
374 <<
" Please check your time directories for any "
375 <<
"mesh directories." <<
endl;
382 procMeshes.meshes()[0],
383 databases[0].timeName()
389 Info<<
"Reconstructing FV fields" <<
nl <<
endl;
391 fvFieldReconstructor reconstructor
395 procMeshes.faceProcAddressing(),
396 procMeshes.cellProcAddressing(),
397 procMeshes.boundaryProcAddressing()
400 reconstructor.reconstructAllFields(objects, selectedFields);
402 if (reconstructor.nReconstructed() == 0)
410 Info<<
"Reconstructing point fields" <<
nl <<
endl;
412 const pointMesh& pMesh = pointMesh::New(
mesh);
413 PtrList<pointMesh> pMeshes(procMeshes.meshes().size());
420 new pointMesh(procMeshes.meshes()[proci])
424 pointFieldReconstructor reconstructor
428 procMeshes.pointProcAddressing(),
429 procMeshes.boundaryProcAddressing()
432 reconstructor.reconstructAllFields(objects, selectedFields);
434 if (reconstructor.nReconstructed() == 0)
450 HashTable<IOobjectList> allCloudObjects;
454 fileName lagrangianDir
458 databases[proci].timePath()
465 if (!lagrangianDir.empty())
474 for (
const fileName& cloudDir : cloudDirs)
478 if (!allCloudObjects.found(cloudDir))
481 IOobjectList localObjs
483 procMeshes.meshes()[proci],
484 databases[proci].timeName(),
485 cloud::prefix/cloudDir
490 localObjs.found(
"coordinates")
491 || localObjs.found(
"positions")
494 allCloudObjects.insert(cloudDir, localObjs);
501 if (allCloudObjects.size())
503 lagrangianReconstructor reconstructor
507 procMeshes.faceProcAddressing(),
508 procMeshes.cellProcAddressing()
514 const word
cloudName = word::validate(iter.key());
517 const IOobjectList& cloudObjs = iter.val();
519 Info<<
"Reconstructing lagrangian fields for cloud "
522 reconstructor.reconstructPositions(
cloudName);
524 reconstructor.reconstructAllFields
528 selectedLagrangianFields
546 objects.count<areaScalarField>()
547 || objects.count<areaVectorField>()
548 || objects.count<areaSphericalTensorField>()
549 || objects.count<areaSymmTensorField>()
550 || objects.count<areaTensorField>()
551 || objects.count<edgeScalarField>()
554 Info <<
"Reconstructing FA fields" <<
nl <<
endl;
558 processorFaMeshes procFaMeshes(procMeshes.meshes());
560 faFieldReconstructor reconstructor
563 procFaMeshes.meshes(),
564 procFaMeshes.edgeProcAddressing(),
565 procFaMeshes.faceProcAddressing(),
566 procFaMeshes.boundaryProcAddressing()
569 reconstructor.reconstructAllFields(objects);
576 if (doReconstructSets)
579 HashTable<label> cSetNames;
580 HashTable<label> fSetNames;
581 HashTable<label> pSetNames;
583 forAll(procMeshes.meshes(), proci)
585 const fvMesh& procMesh = procMeshes.meshes()[proci];
595 polyMesh::meshSubDir/
"sets"
598 for (
const word& setName : objects.sortedNames<cellSet>())
600 cSetNames.insert(setName, cSetNames.size());
603 for (
const word& setName : objects.sortedNames<faceSet>())
605 fSetNames.insert(setName, fSetNames.size());
608 for (
const word& setName : objects.sortedNames<pointSet>())
610 pSetNames.insert(setName, pSetNames.size());
614 if (cSetNames.size() || fSetNames.size() || pSetNames.size())
617 PtrList<cellSet> cellSets(cSetNames.size());
618 PtrList<faceSet> faceSets(fSetNames.size());
619 PtrList<pointSet> pointSets(pSetNames.size());
621 Info<<
"Reconstructing sets:" <<
endl;
622 if (cSetNames.size())
625 << cSetNames.sortedToc() <<
endl;
627 if (fSetNames.size())
630 << fSetNames.sortedToc() <<
endl;
632 if (pSetNames.size())
635 << pSetNames.sortedToc() <<
endl;
639 forAll(procMeshes.meshes(), proci)
641 const fvMesh& procMesh = procMeshes.meshes()[proci];
647 polyMesh::meshSubDir/
"sets"
652 procMeshes.cellProcAddressing()[proci];
654 for (
const IOobject&
io : objects.sorted<cellSet>())
657 const cellSet procSet(
io);
658 const label seti = cSetNames[
io.name()];
659 if (!cellSets.set(seti))
672 cellSet& cSet = cellSets[seti];
673 cSet.instance() =
runTime.timeName();
675 for (
const label celli : procSet)
677 cSet.insert(cellMap[celli]);
683 procMeshes.faceProcAddressing()[proci];
685 for (
const IOobject&
io : objects.sorted<faceSet>())
688 const faceSet procSet(
io);
689 const label seti = fSetNames[
io.name()];
690 if (!faceSets.set(seti))
703 faceSet& fSet = faceSets[seti];
704 fSet.instance() =
runTime.timeName();
706 for (
const label facei : procSet)
708 fSet.insert(
mag(faceMap[facei])-1);
713 procMeshes.pointProcAddressing()[proci];
715 for (
const IOobject&
io : objects.sorted<pointSet>())
718 const pointSet procSet(
io);
719 const label seti = pSetNames[
io.name()];
720 if (!pointSets.set(seti))
733 pointSet& pSet = pointSets[seti];
734 pSet.instance() =
runTime.timeName();
736 for (
const label pointi : procSet)
738 pSet.insert(pointMap[pointi]);
745 for (
const auto& set : cellSets)
749 for (
const auto& set : faceSets)
753 for (
const auto& set : pointSets)
762 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
764 forAll(procMeshes.meshes(), procI)
766 const fvMesh& procMesh = procMeshes.meshes()[procI];
776 procMesh.time().timeName(),
777 polyMesh::meshSubDir,
779 IOobject::READ_IF_PRESENT,
789 const PtrList<labelIOList>& cellAddr =
790 procMeshes.cellProcAddressing();
792 UPtrList<const labelList> cellMaps(cellAddr.size());
795 cellMaps.set(i, &cellAddr[i]);
798 const PtrList<labelIOList>& pointAddr =
799 procMeshes.pointProcAddressing();
801 UPtrList<const labelList> pointMaps(pointAddr.size());
804 pointMaps.set(i, &pointAddr[i]);
807 UPtrList<const hexRef8Data> procRefs(procData.size());
810 procRefs.set(i, &procData[i]);
818 mesh.time().timeName(),
819 polyMesh::meshSubDir,
835 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
837 forAll(procMeshes.meshes(), procI)
839 const fvMesh& procMesh = procMeshes.meshes()[procI];
849 procMesh.time().timeName(),
850 polyMesh::meshSubDir,
852 IOobject::READ_IF_PRESENT,
862 const PtrList<labelIOList>& cellAddr =
863 procMeshes.cellProcAddressing();
865 UPtrList<const labelList> cellMaps(cellAddr.size());
868 cellMaps.set(i, &cellAddr[i]);
871 const PtrList<labelIOList>& pointAddr =
872 procMeshes.pointProcAddressing();
874 UPtrList<const labelList> pointMaps(pointAddr.size());
877 pointMaps.set(i, &pointAddr[i]);
880 UPtrList<const hexRef8Data> procRefs(procData.size());
883 procRefs.set(i, &procData[i]);
891 mesh.time().timeName(),
892 polyMesh::meshSubDir,
911 databases[0].timePath()/
regionDir/
"uniform"
929 databases[0].timePath()/
"uniform"
const fileName & rootPath() const noexcept
Return root path.
bool readListIfPresent(const word &optName, List< T > &list) const
bool found(const word &optName) const
Return true if the named option is found.
fileName path() const
Return the full path to the (processor local) case.
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const =0
Copy, recursively if necessary, the source to the destination.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
virtual fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const =0
Read a directory and return the entries as a string list.
Foam::word regionName(Foam::polyMesh::defaultRegion)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define WarningInFunction
Report a warning using Foam::Warning.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
const fileOperation & fileHandler()
Get current file handler.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< fileName > fileNameList
A List of fileNames.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< instant > instantList
List of instants.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
const word cloudName(propsDict.get< word >("cloud"))