54 const HashSet<word>& masterTimeDirSet,
61 if (!masterTimeDirSet.found(timeDirs[timei].name()))
70 int main(
int argc,
char *argv[])
74 "Reconstruct fields of a parallel case" 79 timeSelector::addOptions(
true,
true);
80 argList::noParallel();
82 argList::addBoolOption
85 "operate on all regions in regionProperties" 91 "specify a list of fields to be reconstructed. Eg, '(U T p)' - " 92 "regular expressions not currently supported" 94 argList::addBoolOption
97 "skip reconstructing fields" 103 "specify a list of lagrangian fields to be reconstructed. Eg, '(U d)' -" 104 "regular expressions not currently supported, " 105 "positions always included." 107 argList::addBoolOption
110 "skip reconstructing lagrangian positions and fields" 112 argList::addBoolOption
115 "skip reconstructing cellSets, faceSets, pointSets" 117 argList::addBoolOption
120 "only reconstruct new times (i.e. that do not exist already)" 126 HashSet<word> selectedFields;
136 Info<<
"Skipping reconstructing fields" 144 Info<<
"Skipping reconstructing lagrangian positions and fields" 151 if (noReconstructSets)
153 Info<<
"Skipping reconstructing cellSets, faceSets and pointSets" 158 HashSet<word> selectedLagrangianFields;
164 <<
"Cannot specify noLagrangian and lagrangianFields " 165 <<
"options together." 181 Info<<
"Reconstructing for all regions in regionProperties" <<
nl 183 regionProperties
rp(runTime);
189 if (
findIndex(regionNames, regions[i]) == -1)
191 regionNames.append(regions[i]);
195 regionDirs = regionNames;
202 regionNames =
wordList(1, regionName);
203 regionDirs = regionNames;
207 regionNames =
wordList(1, fvMesh::defaultRegion);
208 regionDirs =
wordList(1, word::null);
218 <<
"No processor* directories found" 223 PtrList<Time> databases(nProcs);
232 Time::controlDictName,
243 databases[0].times(),
254 if (timeDirs.empty())
265 masterTimeDirs = runTime.times();
267 HashSet<word> masterTimeDirSet(2*masterTimeDirs.size());
270 masterTimeDirSet.insert(masterTimeDirs[i].
name());
277 databases[proci].setTime(runTime);
281 forAll(regionNames, regioni)
283 const word& regionName = regionNames[regioni];
284 const word& regionDir = regionDirs[regioni];
286 Info<<
"\n\nReconstructing fields for mesh " << regionName <<
nl 292 && regionNames.size() == 1
293 && regionDirs[0].empty()
294 && haveAllTimes(masterTimeDirSet, timeDirs)
297 Info<<
"Skipping region " << regionName
298 <<
" since already have all times" 317 processorMeshes procMeshes(databases, regionName);
327 if (newTimes && masterTimeDirSet.found(timeDirs[timei].name()))
329 Info<<
"Skipping time " << timeDirs[timei].name()
336 runTime.setTime(timeDirs[timei], timei);
338 Info<<
"Time = " << runTime.timeName() << endl <<
endl;
343 databases[proci].setTime(timeDirs[timei], timei);
347 fvMesh::readUpdateState meshStat = mesh.readUpdate();
349 fvMesh::readUpdateState procStat = procMeshes.readUpdate();
351 if (procStat == fvMesh::POINTS_MOVED)
355 procMeshes.reconstructPoints(mesh);
357 else if (meshStat != procStat)
360 <<
"readUpdate for the reconstructed mesh:" 362 <<
"readUpdate for the processor meshes :" 364 <<
"These should be equal or your addressing" 365 <<
" might be incorrect." 366 <<
" Please check your time directories for any " 367 <<
"mesh directories." <<
endl;
374 procMeshes.meshes()[0],
375 databases[0].timeName()
381 Info<<
"Reconstructing FV fields" <<
nl <<
endl;
383 fvFieldReconstructor fvReconstructor
387 procMeshes.faceProcAddressing(),
388 procMeshes.cellProcAddressing(),
389 procMeshes.boundaryProcAddressing()
392 fvReconstructor.reconstructFvVolumeInternalFields<scalar>
397 fvReconstructor.reconstructFvVolumeInternalFields<
vector>
402 fvReconstructor.reconstructFvVolumeInternalFields
408 fvReconstructor.reconstructFvVolumeInternalFields<
symmTensor>
413 fvReconstructor.reconstructFvVolumeInternalFields<
tensor>
419 fvReconstructor.reconstructFvVolumeFields<scalar>
424 fvReconstructor.reconstructFvVolumeFields<
vector>
434 fvReconstructor.reconstructFvVolumeFields<
symmTensor>
439 fvReconstructor.reconstructFvVolumeFields<
tensor>
445 fvReconstructor.reconstructFvSurfaceFields<scalar>
450 fvReconstructor.reconstructFvSurfaceFields<
vector>
460 fvReconstructor.reconstructFvSurfaceFields<
symmTensor>
465 fvReconstructor.reconstructFvSurfaceFields<
tensor>
471 if (fvReconstructor.nReconstructed() == 0)
479 Info<<
"Reconstructing point fields" <<
nl <<
endl;
482 PtrList<pointMesh> pMeshes(procMeshes.meshes().size());
489 new pointMesh(procMeshes.meshes()[proci])
493 pointFieldReconstructor pointReconstructor
497 procMeshes.pointProcAddressing(),
498 procMeshes.boundaryProcAddressing()
501 pointReconstructor.reconstructFields<scalar>
506 pointReconstructor.reconstructFields<
vector>
516 pointReconstructor.reconstructFields<
symmTensor>
521 pointReconstructor.reconstructFields<
tensor>
527 if (pointReconstructor.nReconstructed() == 0)
543 HashTable<IOobjectList> cloudObjects;
547 fileName lagrangianDir
551 databases[proci].timePath()
558 if (!lagrangianDir.empty())
571 HashTable<IOobjectList>::const_iterator iter =
572 cloudObjects.find(cloudDirs[i]);
574 if (iter == cloudObjects.end())
577 IOobjectList sprayObjs
579 procMeshes.meshes()[proci],
580 databases[proci].timeName(),
581 cloud::prefix/cloudDirs[i]
584 IOobject* positionsPtr =
585 sprayObjs.lookup(word(
"positions"));
589 cloudObjects.insert(cloudDirs[i], sprayObjs);
596 if (cloudObjects.size())
601 const word cloudName = string::validate<word>
607 const IOobjectList& sprayObjs = iter();
609 Info<<
"Reconstructing lagrangian fields for cloud " 610 << cloudName <<
nl <<
endl;
617 procMeshes.faceProcAddressing(),
618 procMeshes.cellProcAddressing()
620 reconstructLagrangianFields<label>
626 selectedLagrangianFields
628 reconstructLagrangianFieldFields<label>
634 selectedLagrangianFields
636 reconstructLagrangianFields<scalar>
642 selectedLagrangianFields
644 reconstructLagrangianFieldFields<scalar>
650 selectedLagrangianFields
652 reconstructLagrangianFields<vector>
658 selectedLagrangianFields
660 reconstructLagrangianFieldFields<vector>
666 selectedLagrangianFields
668 reconstructLagrangianFields<sphericalTensor>
674 selectedLagrangianFields
676 reconstructLagrangianFieldFields<sphericalTensor>
682 selectedLagrangianFields
684 reconstructLagrangianFields<symmTensor>
690 selectedLagrangianFields
692 reconstructLagrangianFieldFields<symmTensor>
698 selectedLagrangianFields
700 reconstructLagrangianFields<tensor>
706 selectedLagrangianFields
708 reconstructLagrangianFieldFields<tensor>
714 selectedLagrangianFields
725 if (!noReconstructSets)
728 HashTable<label> cSetNames;
729 HashTable<label> fSetNames;
730 HashTable<label> pSetNames;
732 forAll(procMeshes.meshes(), proci)
734 const fvMesh& procMesh = procMeshes.meshes()[proci];
744 polyMesh::meshSubDir/
"sets" 747 IOobjectList cSets(objects.lookupClass(cellSet::typeName));
750 cSetNames.insert(iter.key(), cSetNames.size());
753 IOobjectList fSets(objects.lookupClass(faceSet::typeName));
756 fSetNames.insert(iter.key(), fSetNames.size());
758 IOobjectList pSets(objects.lookupClass(pointSet::typeName));
761 pSetNames.insert(iter.key(), pSetNames.size());
765 if (cSetNames.size() || fSetNames.size() || pSetNames.size())
768 PtrList<cellSet> cellSets(cSetNames.size());
769 PtrList<faceSet> faceSets(fSetNames.size());
770 PtrList<pointSet> pointSets(pSetNames.size());
772 Info<<
"Reconstructing sets:" <<
endl;
773 if (cSetNames.size())
776 << cSetNames.sortedToc() <<
endl;
778 if (fSetNames.size())
781 << fSetNames.sortedToc() <<
endl;
783 if (pSetNames.size())
786 << pSetNames.sortedToc() <<
endl;
790 forAll(procMeshes.meshes(), proci)
792 const fvMesh& procMesh = procMeshes.meshes()[proci];
798 polyMesh::meshSubDir/
"sets" 803 procMeshes.cellProcAddressing()[proci];
807 objects.lookupClass(cellSet::typeName)
813 const cellSet procSet(*iter());
814 label setI = cSetNames[iter.key()];
815 if (!cellSets.set(setI))
828 cellSet& cSet = cellSets[setI];
829 cSet.instance() = runTime.timeName();
833 cSet.insert(cellMap[iter.key()]);
839 procMeshes.faceProcAddressing()[proci];
843 objects.lookupClass(faceSet::typeName)
849 const faceSet procSet(*iter());
850 label setI = fSetNames[iter.key()];
851 if (!faceSets.set(setI))
864 faceSet& fSet = faceSets[setI];
865 fSet.instance() = runTime.timeName();
869 fSet.insert(
mag(faceMap[iter.key()])-1);
874 procMeshes.pointProcAddressing()[proci];
878 objects.lookupClass(pointSet::typeName)
883 const pointSet propSet(*iter());
884 label setI = pSetNames[iter.key()];
885 if (!pointSets.set(setI))
898 pointSet& pSet = pointSets[setI];
899 pSet.instance() = runTime.timeName();
903 pSet.insert(pointMap[iter.key()]);
919 pointSets[i].write();
927 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
929 forAll(procMeshes.meshes(), procI)
931 const fvMesh& procMesh = procMeshes.meshes()[procI];
941 procMesh.time().timeName(),
942 polyMesh::meshSubDir,
944 IOobject::READ_IF_PRESENT,
954 const PtrList<labelIOList>& cellAddr =
955 procMeshes.cellProcAddressing();
957 UPtrList<const labelList> cellMaps(cellAddr.size());
960 cellMaps.set(i, &cellAddr[i]);
963 const PtrList<labelIOList>& pointAddr =
964 procMeshes.pointProcAddressing();
966 UPtrList<const labelList> pointMaps(pointAddr.size());
969 pointMaps.set(i, &pointAddr[i]);
972 UPtrList<const hexRef8Data> procRefs(procData.size());
975 procRefs.set(i, &procData[i]);
983 mesh.time().timeName(),
984 polyMesh::meshSubDir,
1003 databases[0].timePath()/regionDir/
"uniform" 1009 fileHandler().
cp(uniformDir0, runTime.timePath()/regionDir);
1015 if (regioni == 0 && regionDir != word::null)
1017 fileName uniformDir0
1021 databases[0].timePath()/
"uniform"
List< instant > instantList
List of instants.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fileName & rootPath() const
Return root path.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
Vector< scalar > vector
A scalar version of the templated Vector.
void reconstructLagrangianPositions(const polyMesh &mesh, const word &cloudName, const PtrList< fvMesh > &meshes, const PtrList< labelIOList > &faceProcAddressing, const PtrList< labelIOList > &cellProcAddressing)
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
regionProperties rp(runTime)
List< label > labelList
A List of labels.
const fileOperation & fileHandler()
Get current file handler.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const =0
Copy, recursively if necessary, the source to the destination.
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
fileName path() const
Return the path to the caseName.
List< word > wordList
A List of words.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual bool isDir(const fileName &, const bool followLink=true) const =0
Does the name exist as a DIRECTORY in the file system?
dimensioned< scalar > mag(const dimensioned< Type > &)
const word cloudName(propsDict.lookup("cloudName"))
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars.
Foam::argList args(argc, argv)
List< fileName > fileNameList
A List of fileNames.
Tensor< scalar > tensor
Tensor of scalars.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.