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." 187 <<
"No processor* directories found" 192 PtrList<Time> databases(nProcs);
201 Time::controlDictName,
212 databases[0].times(),
223 if (timeDirs.empty())
226 <<
"No times selected" 235 masterTimeDirs = runTime.times();
237 HashSet<word> masterTimeDirSet(2*masterTimeDirs.size());
240 masterTimeDirSet.insert(masterTimeDirs[i].
name());
247 databases[proci].setTime(runTime);
255 Info<<
"Reconstructing for all regions in regionProperties" <<
nl 257 regionProperties
rp(runTime);
263 if (
findIndex(regionNames, regions[i]) == -1)
265 regionNames.append(regions[i]);
269 regionDirs = regionNames;
276 regionNames =
wordList(1, regionName);
277 regionDirs = regionNames;
281 regionNames =
wordList(1, fvMesh::defaultRegion);
282 regionDirs =
wordList(1, word::null);
287 forAll(regionNames, regioni)
289 const word& regionName = regionNames[regioni];
290 const word& regionDir = regionDirs[regioni];
292 Info<<
"\n\nReconstructing fields for mesh " << regionName <<
nl 298 && regionNames.size() == 1
299 && regionDirs[0].empty()
300 && haveAllTimes(masterTimeDirSet, timeDirs)
303 Info<<
"Skipping region " << regionName
304 <<
" since already have all times" 323 processorMeshes procMeshes(databases, regionName);
333 if (newTimes && masterTimeDirSet.found(timeDirs[timei].name()))
335 Info<<
"Skipping time " << timeDirs[timei].name()
342 runTime.setTime(timeDirs[timei], timei);
344 Info<<
"Time = " << runTime.timeName() << endl <<
endl;
349 databases[proci].setTime(timeDirs[timei], timei);
353 fvMesh::readUpdateState meshStat = mesh.readUpdate();
355 fvMesh::readUpdateState procStat = procMeshes.readUpdate();
357 if (procStat == fvMesh::POINTS_MOVED)
361 procMeshes.reconstructPoints(mesh);
363 else if (meshStat != procStat)
366 <<
"readUpdate for the reconstructed mesh:" 368 <<
"readUpdate for the processor meshes :" 370 <<
"These should be equal or your addressing" 371 <<
" might be incorrect." 372 <<
" Please check your time directories for any " 373 <<
"mesh directories." <<
endl;
380 procMeshes.meshes()[0],
381 databases[0].timeName()
387 Info<<
"Reconstructing FV fields" <<
nl <<
endl;
389 fvFieldReconstructor fvReconstructor
393 procMeshes.faceProcAddressing(),
394 procMeshes.cellProcAddressing(),
395 procMeshes.boundaryProcAddressing()
398 fvReconstructor.reconstructFvVolumeInternalFields<scalar>
403 fvReconstructor.reconstructFvVolumeInternalFields<
vector>
408 fvReconstructor.reconstructFvVolumeInternalFields
414 fvReconstructor.reconstructFvVolumeInternalFields<
symmTensor>
419 fvReconstructor.reconstructFvVolumeInternalFields<
tensor>
425 fvReconstructor.reconstructFvVolumeFields<scalar>
430 fvReconstructor.reconstructFvVolumeFields<
vector>
440 fvReconstructor.reconstructFvVolumeFields<
symmTensor>
445 fvReconstructor.reconstructFvVolumeFields<
tensor>
451 fvReconstructor.reconstructFvSurfaceFields<scalar>
456 fvReconstructor.reconstructFvSurfaceFields<
vector>
466 fvReconstructor.reconstructFvSurfaceFields<
symmTensor>
471 fvReconstructor.reconstructFvSurfaceFields<
tensor>
477 if (fvReconstructor.nReconstructed() == 0)
485 Info<<
"Reconstructing point fields" <<
nl <<
endl;
488 PtrList<pointMesh> pMeshes(procMeshes.meshes().size());
495 new pointMesh(procMeshes.meshes()[proci])
499 pointFieldReconstructor pointReconstructor
503 procMeshes.pointProcAddressing(),
504 procMeshes.boundaryProcAddressing()
507 pointReconstructor.reconstructFields<scalar>
512 pointReconstructor.reconstructFields<
vector>
522 pointReconstructor.reconstructFields<
symmTensor>
527 pointReconstructor.reconstructFields<
tensor>
533 if (pointReconstructor.nReconstructed() == 0)
549 HashTable<IOobjectList> cloudObjects;
557 databases[proci].timePath()
568 HashTable<IOobjectList>::const_iterator iter =
569 cloudObjects.find(cloudDirs[i]);
571 if (iter == cloudObjects.end())
574 IOobjectList sprayObjs
576 procMeshes.meshes()[proci],
577 databases[proci].timeName(),
578 cloud::prefix/cloudDirs[i]
581 IOobject* positionsPtr =
582 sprayObjs.lookup(word(
"positions"));
586 cloudObjects.insert(cloudDirs[i], sprayObjs);
593 if (cloudObjects.size())
598 const word cloudName = string::validate<word>
604 const IOobjectList& sprayObjs = iter();
606 Info<<
"Reconstructing lagrangian fields for cloud " 607 << cloudName <<
nl <<
endl;
614 procMeshes.faceProcAddressing(),
615 procMeshes.cellProcAddressing()
617 reconstructLagrangianFields<label>
623 selectedLagrangianFields
625 reconstructLagrangianFieldFields<label>
631 selectedLagrangianFields
633 reconstructLagrangianFields<scalar>
639 selectedLagrangianFields
641 reconstructLagrangianFieldFields<scalar>
647 selectedLagrangianFields
649 reconstructLagrangianFields<vector>
655 selectedLagrangianFields
657 reconstructLagrangianFieldFields<vector>
663 selectedLagrangianFields
665 reconstructLagrangianFields<sphericalTensor>
671 selectedLagrangianFields
673 reconstructLagrangianFieldFields<sphericalTensor>
679 selectedLagrangianFields
681 reconstructLagrangianFields<symmTensor>
687 selectedLagrangianFields
689 reconstructLagrangianFieldFields<symmTensor>
695 selectedLagrangianFields
697 reconstructLagrangianFields<tensor>
703 selectedLagrangianFields
705 reconstructLagrangianFieldFields<tensor>
711 selectedLagrangianFields
722 if (!noReconstructSets)
725 HashTable<label> cSetNames;
726 HashTable<label> fSetNames;
727 HashTable<label> pSetNames;
729 forAll(procMeshes.meshes(), proci)
731 const fvMesh& procMesh = procMeshes.meshes()[proci];
741 polyMesh::meshSubDir/
"sets" 744 IOobjectList cSets(objects.lookupClass(cellSet::typeName));
747 cSetNames.insert(iter.key(), cSetNames.size());
750 IOobjectList fSets(objects.lookupClass(faceSet::typeName));
753 fSetNames.insert(iter.key(), fSetNames.size());
755 IOobjectList pSets(objects.lookupClass(pointSet::typeName));
758 pSetNames.insert(iter.key(), pSetNames.size());
762 if (cSetNames.size() || fSetNames.size() || pSetNames.size())
765 PtrList<cellSet> cellSets(cSetNames.size());
766 PtrList<faceSet> faceSets(fSetNames.size());
767 PtrList<pointSet> pointSets(pSetNames.size());
769 Info<<
"Reconstructing sets:" <<
endl;
770 if (cSetNames.size())
773 << cSetNames.sortedToc() <<
endl;
775 if (fSetNames.size())
778 << fSetNames.sortedToc() <<
endl;
780 if (pSetNames.size())
783 << pSetNames.sortedToc() <<
endl;
787 forAll(procMeshes.meshes(), proci)
789 const fvMesh& procMesh = procMeshes.meshes()[proci];
795 polyMesh::meshSubDir/
"sets" 800 procMeshes.cellProcAddressing()[proci];
804 objects.lookupClass(cellSet::typeName)
810 const cellSet procSet(*iter());
811 label setI = cSetNames[iter.key()];
812 if (!cellSets.set(setI))
825 cellSet& cSet = cellSets[setI];
826 cSet.instance() = runTime.timeName();
830 cSet.insert(cellMap[iter.key()]);
836 procMeshes.faceProcAddressing()[proci];
840 objects.lookupClass(faceSet::typeName)
846 const faceSet procSet(*iter());
847 label setI = fSetNames[iter.key()];
848 if (!faceSets.set(setI))
861 faceSet& fSet = faceSets[setI];
862 fSet.instance() = runTime.timeName();
866 fSet.insert(
mag(faceMap[iter.key()])-1);
871 procMeshes.pointProcAddressing()[proci];
875 objects.lookupClass(pointSet::typeName)
880 const pointSet propSet(*iter());
881 label setI = pSetNames[iter.key()];
882 if (!pointSets.set(setI))
895 pointSet& pSet = pointSets[setI];
896 pSet.instance() = runTime.timeName();
900 pSet.insert(pointMap[iter.key()]);
916 pointSets[i].write();
924 PtrList<hexRef8Data> procData(procMeshes.meshes().size());
926 forAll(procMeshes.meshes(), procI)
928 const fvMesh& procMesh = procMeshes.meshes()[procI];
938 procMesh.time().timeName(),
939 polyMesh::meshSubDir,
941 IOobject::READ_IF_PRESENT,
951 const PtrList<labelIOList>& cellAddr =
952 procMeshes.cellProcAddressing();
954 UPtrList<const labelList> cellMaps(cellAddr.size());
957 cellMaps.set(i, &cellAddr[i]);
960 const PtrList<labelIOList>& pointAddr =
961 procMeshes.pointProcAddressing();
963 UPtrList<const labelList> pointMaps(pointAddr.size());
966 pointMaps.set(i, &pointAddr[i]);
969 UPtrList<const hexRef8Data> procRefs(procData.size());
972 procRefs.set(i, &procData[i]);
980 mesh.time().timeName(),
981 polyMesh::meshSubDir,
998 databases[0].timePath()/regionDir/
"uniform" 1001 if (
isDir(uniformDir0))
1003 cp(uniformDir0, runTime.timePath()/regionDir);
1009 if (regioni == 0 && regionDir != word::null)
1011 fileName uniformDir0
1013 databases[0].timePath()/
"uniform" 1016 if (
isDir(uniformDir0))
1018 cp(uniformDir0, runTime.timePath());
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)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const word cloudName(propsDict.lookup("cloudName"))
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
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)
const fileName & rootPath() const
Return root path.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
fileName path() const
Return the path to the caseName.
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
bool optionFound(const word &opt) const
Return true if the named option is found.
SymmTensor< scalar > symmTensor
SymmTensor of scalars.
regionProperties rp(runTime)
List< label > labelList
A List of labels.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
const volScalarField & cp
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.
List< word > wordList
A List of words.
#define WarningInFunction
Report a warning using Foam::Warning.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.
dimensioned< scalar > mag(const dimensioned< Type > &)
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars.
Foam::argList args(argc, argv)
List< fileName > fileNameList
A List of fileNames.
fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true)
Read a directory and return the entries as a string list.
Tensor< scalar > tensor
Tensor of scalars.