101 #include "readFields.H" 115 const PtrList<fvMesh>& procMeshList,
118 PtrList<labelIOList>& procAddressingList
121 const fvMesh& procMesh = procMeshList[proci];
123 if (!procAddressingList.set(proci))
125 procAddressingList.set
133 procMesh.facesInstance(),
143 return procAddressingList[proci];
147 void decomposeUniform
149 const bool copyUniform,
150 const domainDecomposition& mesh,
151 const Time& processorDb,
155 const Time& runTime = mesh.
time();
158 const fileName uniformDir(regionDir/
"uniform");
162 Info<<
"Detected additional non-decomposed files in " 163 << runTime.timePath()/uniformDir
166 const fileName timePath =
169 if (copyUniform || mesh.distributed())
175 runTime.timePath()/uniformDir,
183 string parentPath = string(
"..")/
"..";
187 parentPath = parentPath/
"..";
190 fileName currentDir(
cwd());
197 parentPath/runTime.timeName()/uniformDir,
211 int main(
int argc,
char *argv[])
215 "decompose a mesh and fields of a case for parallel execution" 224 "write cell distribution as a labelList - for use with 'manual' " 225 "decomposition method or as a volScalarField for post-processing." 230 "Copy \a 0 directory to processor* rather than decompose the fields" 235 "copy any uniform/ directories too" 240 "use existing geometry decomposition and convert fields only" 245 "opposite of -fields; only decompose geometry" 250 "skip decomposing cellSets, faceSets, pointSets" 255 "remove existing processor*/ subdirs before decomposing the geometry" 260 "only decompose geometry if the number of domains has changed" 266 "dictionary file name",
267 "specify alternative decomposition dictionary" 285 const word
dictName(
"decomposeParDict");
288 if (decomposeGeomOnly)
290 Info<<
"Skipping decomposing fields" 293 if (decomposeFieldsOnly || copyZero)
296 <<
"Cannot combine geometry-only decomposition (-noFields)" 297 <<
" with field decomposition (-noFields or -copyZero)" 310 dictPath =
args[
"dict"];
320 <<
"Specified -dict " <<
args[
"dict"] <<
" but neither " 340 <<
"Cannot force the decomposition of a single region" 344 Info<<
"Removing " << nProcs
345 <<
" existing processor directories" <<
endl;
358 const fileName& d = dirs[diri];
361 if (d.find(
"processors") == 0)
370 if (d.find(
"processor") == 0)
373 fileName num(d.substr(9));
385 else if (nProcs && !region && !decomposeFieldsOnly)
388 <<
"Case is already decomposed with " << nProcs
389 <<
" domains, use the -force option or manually" <<
nl 390 <<
"remove processor directories before decomposing. e.g.," 392 <<
" rm -rf " << runTime.path().c_str() <<
"/processor*" 399 forAll(regionNames, regioni)
401 const word& regionName = regionNames[regioni];
404 Info<<
"\n\nDecomposing mesh " << regionName <<
nl <<
endl;
416 runTime.time().system(),
427 IOobject::MUST_READ_IF_MODIFIED,
434 const label nDomains =
435 IOdictionary(
dictIO).lookup<
label>(
"numberOfSubdomains");
438 const_cast<fileOperation&
>(
fileHandler()).setNProcs(nDomains);
440 if (decomposeFieldsOnly)
443 if (nProcs != nDomains)
446 <<
"Specified -fields, but the case was decomposed with " 447 << nProcs <<
" domains" 449 <<
"instead of " << nDomains
450 <<
" domains as specified in " <<
dictName 457 if (ifRequiredDecomposition && nProcs == nDomains)
460 decomposeFieldsOnly =
true;
461 Info<<
"Using existing processor directories" <<
nl;
466 domainDecomposition
mesh 481 if (!decomposeFieldsOnly)
485 mesh.writeDecomposition(decomposeSets);
489 const labelList& procIds = mesh.cellToProc();
498 mesh.facesInstance(),
506 cellDecomposition.write();
508 Info<<
nl <<
"Wrote decomposition to " 509 << cellDecomposition.localObjectPath()
510 <<
" for use in manual decomposition." <<
endl;
529 cellDist[celli] = procIds[celli];
534 Info<<
nl <<
"Wrote decomposition as volScalarField to " 535 << cellDist.name() <<
" for use in postprocessing." 546 fileName prevTimePath;
547 for (
label proci = 0; proci < mesh.nProcs(); proci++)
555 processorDb.setTime(runTime);
560 const fileName timePath
567 processorDb.timeName(),
574 if (timePath != prevTimePath)
576 Info<<
"Processor " << proci
577 <<
": copying " << runTime.timePath() <<
nl 578 <<
" to " << timePath <<
endl;
581 prevTimePath = timePath;
586 else if (!decomposeGeomOnly)
592 PtrList<Time> processorDbList(mesh.nProcs());
593 PtrList<fvMesh> procMeshList(mesh.nProcs());
594 PtrList<labelIOList> faceProcAddressingList(mesh.nProcs());
595 PtrList<labelIOList> cellProcAddressingList(mesh.nProcs());
596 PtrList<labelIOList> boundaryProcAddressingList(mesh.nProcs());
597 PtrList<fvFieldDecomposer> fieldDecomposerList(mesh.nProcs());
598 PtrList<dimFieldDecomposer> dimFieldDecomposerList(mesh.nProcs());
599 PtrList<labelIOList> pointProcAddressingList(mesh.nProcs());
600 PtrList<pointFieldDecomposer> pointFieldDecomposerList
609 runTime.setTime(times[timeI], timeI);
611 Info<<
"Time = " << runTime.timeName() <<
endl;
614 IOobjectList
objects(mesh, runTime.timeName());
619 PtrList<volScalarField> volScalarFields;
621 PtrList<volVectorField> volVectorFields;
623 PtrList<volSphericalTensorField> volSphericalTensorFields;
625 PtrList<volSymmTensorField> volSymmTensorFields;
627 PtrList<volTensorField> volTensorFields;
633 PtrList<DimensionedField<scalar, volMesh>> dimScalarFields;
635 PtrList<DimensionedField<vector, volMesh>> dimVectorFields;
637 PtrList<DimensionedField<sphericalTensor, volMesh>>
638 dimSphericalTensorFields;
640 PtrList<DimensionedField<symmTensor, volMesh>>
643 PtrList<DimensionedField<tensor, volMesh>> dimTensorFields;
649 PtrList<surfaceScalarField> surfaceScalarFields;
651 PtrList<surfaceVectorField> surfaceVectorFields;
653 PtrList<surfaceSphericalTensorField>
654 surfaceSphericalTensorFields;
656 PtrList<surfaceSymmTensorField> surfaceSymmTensorFields;
658 PtrList<surfaceTensorField> surfaceTensorFields;
666 PtrList<pointScalarField> pointScalarFields;
668 PtrList<pointVectorField> pointVectorFields;
670 PtrList<pointSphericalTensorField> pointSphericalTensorFields;
672 PtrList<pointSymmTensorField> pointSymmTensorFields;
674 PtrList<pointTensorField> pointTensorFields;
691 PtrList<Cloud<indexedParticle>> lagrangianPositions
696 PtrList<List<SLList<indexedParticle*>*>> cellParticles
701 PtrList<PtrList<labelIOField>> lagrangianLabelFields
705 PtrList<PtrList<labelFieldCompactIOField>>
706 lagrangianLabelFieldFields
710 PtrList<PtrList<scalarIOField>> lagrangianScalarFields
714 PtrList<PtrList<scalarFieldCompactIOField>>
715 lagrangianScalarFieldFields
719 PtrList<PtrList<vectorIOField>> lagrangianVectorFields
723 PtrList<PtrList<vectorFieldCompactIOField>>
724 lagrangianVectorFieldFields
728 PtrList<PtrList<sphericalTensorIOField>>
729 lagrangianSphericalTensorFields
733 PtrList<PtrList<sphericalTensorFieldCompactIOField>>
734 lagrangianSphericalTensorFieldFields(cloudDirs.size());
735 PtrList<PtrList<symmTensorIOField>> lagrangianSymmTensorFields
739 PtrList<PtrList<symmTensorFieldCompactIOField>>
740 lagrangianSymmTensorFieldFields
744 PtrList<PtrList<tensorIOField>> lagrangianTensorFields
748 PtrList<PtrList<tensorFieldCompactIOField>>
749 lagrangianTensorFieldFields
758 IOobjectList sprayObjs
768 IOobject* positionsPtr = sprayObjs.lookup
778 Info<<
"Identified lagrangian data set: " 779 << cloudDirs[i] <<
endl;
781 lagrangianPositions.set
784 new Cloud<indexedParticle>
799 new List<SLList<indexedParticle*>*>
802 static_cast<SLList<indexedParticle*>*
>(
nullptr)
810 Cloud<indexedParticle>,
811 lagrangianPositions[cloudI],
815 iter().index() = i++;
817 label celli = iter().cell();
820 if (celli < 0 || celli >= mesh.nCells())
823 <<
"Illegal cell number " << celli
824 <<
" for particle with index " 827 << iter().position() <<
nl 828 <<
"Cell number should be between 0 and " 829 << mesh.nCells()-1 <<
nl 830 <<
"On this mesh the particle should" 832 << mesh.findCell(iter().position())
836 if (!cellParticles[cloudI][celli])
838 cellParticles[cloudI][celli] =
839 new SLList<indexedParticle*>();
842 cellParticles[cloudI][celli]->append(&iter());
848 IOobjectList lagrangianObjects
862 lagrangianLabelFields
869 lagrangianLabelFieldFields
876 lagrangianScalarFields
883 lagrangianScalarFieldFields
890 lagrangianVectorFields
897 lagrangianVectorFieldFields
904 lagrangianSphericalTensorFields
911 lagrangianSphericalTensorFieldFields
918 lagrangianSymmTensorFields
925 lagrangianSymmTensorFieldFields
932 lagrangianTensorFields
939 lagrangianTensorFieldFields
946 lagrangianPositions.setSize(cloudI);
947 cellParticles.setSize(cloudI);
948 lagrangianLabelFields.setSize(cloudI);
949 lagrangianLabelFieldFields.setSize(cloudI);
950 lagrangianScalarFields.setSize(cloudI);
951 lagrangianScalarFieldFields.setSize(cloudI);
952 lagrangianVectorFields.setSize(cloudI);
953 lagrangianVectorFieldFields.setSize(cloudI);
954 lagrangianSphericalTensorFields.setSize(cloudI);
955 lagrangianSphericalTensorFieldFields.setSize(cloudI);
956 lagrangianSymmTensorFields.setSize(cloudI);
957 lagrangianSymmTensorFieldFields.setSize(cloudI);
958 lagrangianTensorFields.setSize(cloudI);
959 lagrangianTensorFieldFields.setSize(cloudI);
964 for (
label proci = 0; proci < mesh.nProcs(); proci++)
966 Info<<
"Processor " << proci <<
": field transfer" <<
endl;
970 if (!processorDbList.set(proci))
980 /fileName(word(
"processor") +
name(proci))
984 Time& processorDb = processorDbList[proci];
987 processorDb.setTime(runTime);
990 if (!procMeshList.set(proci))
1000 processorDb.timeName(),
1006 const fvMesh& procMesh = procMeshList[proci];
1008 const labelIOList& faceProcAddressing = procAddressing
1012 "faceProcAddressing",
1013 faceProcAddressingList
1016 const labelIOList& cellProcAddressing = procAddressing
1020 "cellProcAddressing",
1021 cellProcAddressingList
1024 const labelIOList& boundaryProcAddressing = procAddressing
1028 "boundaryProcAddressing",
1029 boundaryProcAddressingList
1035 if (!fieldDecomposerList.set(proci))
1037 fieldDecomposerList.set
1040 new fvFieldDecomposer
1046 boundaryProcAddressing
1050 const fvFieldDecomposer& fieldDecomposer =
1051 fieldDecomposerList[proci];
1053 fieldDecomposer.decomposeFields(volScalarFields);
1054 fieldDecomposer.decomposeFields(volVectorFields);
1055 fieldDecomposer.decomposeFields
1057 volSphericalTensorFields
1059 fieldDecomposer.decomposeFields(volSymmTensorFields);
1060 fieldDecomposer.decomposeFields(volTensorFields);
1062 fieldDecomposer.decomposeFields(surfaceScalarFields);
1063 fieldDecomposer.decomposeFields(surfaceVectorFields);
1064 fieldDecomposer.decomposeFields
1066 surfaceSphericalTensorFields
1068 fieldDecomposer.decomposeFields
1070 surfaceSymmTensorFields
1072 fieldDecomposer.decomposeFields(surfaceTensorFields);
1074 if (times.size() == 1)
1077 fieldDecomposerList.set(proci,
nullptr);
1083 if (!dimFieldDecomposerList.set(proci))
1085 dimFieldDecomposerList.set
1088 new dimFieldDecomposer
1097 const dimFieldDecomposer& dimDecomposer =
1098 dimFieldDecomposerList[proci];
1100 dimDecomposer.decomposeFields(dimScalarFields);
1101 dimDecomposer.decomposeFields(dimVectorFields);
1102 dimDecomposer.decomposeFields(dimSphericalTensorFields);
1103 dimDecomposer.decomposeFields(dimSymmTensorFields);
1104 dimDecomposer.decomposeFields(dimTensorFields);
1106 if (times.size() == 1)
1108 dimFieldDecomposerList.set(proci,
nullptr);
1116 pointScalarFields.size()
1117 || pointVectorFields.size()
1118 || pointSphericalTensorFields.size()
1119 || pointSymmTensorFields.size()
1120 || pointTensorFields.size()
1123 const labelIOList& pointProcAddressing = procAddressing
1127 "pointProcAddressing",
1128 pointProcAddressingList
1133 if (!pointFieldDecomposerList.set(proci))
1135 pointFieldDecomposerList.set
1138 new pointFieldDecomposer
1142 pointProcAddressing,
1143 boundaryProcAddressing
1147 const pointFieldDecomposer& pointDecomposer =
1148 pointFieldDecomposerList[proci];
1150 pointDecomposer.decomposeFields(pointScalarFields);
1151 pointDecomposer.decomposeFields(pointVectorFields);
1152 pointDecomposer.decomposeFields
1154 pointSphericalTensorFields
1156 pointDecomposer.decomposeFields(pointSymmTensorFields);
1157 pointDecomposer.decomposeFields(pointTensorFields);
1160 if (times.size() == 1)
1162 pointProcAddressingList.set(proci,
nullptr);
1163 pointFieldDecomposerList.set(proci,
nullptr);
1169 forAll(lagrangianPositions, cloudI)
1171 if (lagrangianPositions[cloudI].size())
1173 lagrangianFieldDecomposer fieldDecomposer
1180 lagrangianPositions[cloudI],
1181 cellParticles[cloudI]
1186 fieldDecomposer.decomposeFields
1189 lagrangianLabelFields[cloudI]
1191 fieldDecomposer.decomposeFieldFields
1194 lagrangianLabelFieldFields[cloudI]
1196 fieldDecomposer.decomposeFields
1199 lagrangianScalarFields[cloudI]
1201 fieldDecomposer.decomposeFieldFields
1204 lagrangianScalarFieldFields[cloudI]
1206 fieldDecomposer.decomposeFields
1209 lagrangianVectorFields[cloudI]
1211 fieldDecomposer.decomposeFieldFields
1214 lagrangianVectorFieldFields[cloudI]
1216 fieldDecomposer.decomposeFields
1219 lagrangianSphericalTensorFields[cloudI]
1221 fieldDecomposer.decomposeFieldFields
1224 lagrangianSphericalTensorFieldFields[cloudI]
1226 fieldDecomposer.decomposeFields
1229 lagrangianSymmTensorFields[cloudI]
1231 fieldDecomposer.decomposeFieldFields
1234 lagrangianSymmTensorFieldFields[cloudI]
1236 fieldDecomposer.decomposeFields
1239 lagrangianTensorFields[cloudI]
1241 fieldDecomposer.decomposeFieldFields
1244 lagrangianTensorFieldFields[cloudI]
1252 decomposeUniform(copyUniform, mesh, processorDb, regionDir);
1256 if (regionNames.size() > 1 && regioni == 0)
1258 decomposeUniform(copyUniform, mesh, processorDb);
1264 if (times.size() == 1)
1266 boundaryProcAddressingList.set(proci,
nullptr);
1267 cellProcAddressingList.set(proci,
nullptr);
1268 faceProcAddressingList.set(proci,
nullptr);
1269 procMeshList.set(proci,
nullptr);
1270 processorDbList.set(proci,
nullptr);
List< instant > instantList
List of instants.
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
#define forAll(list, i)
Loop across all elements in list.
virtual bool rmDir(const fileName &) const =0
Remove a directory and its contents.
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)
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the specified type.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fileName & rootPath() const
Return root path.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
static const fileName null
An empty fileName.
bool exists(IOobject &io) const
Does ioobject exist. Is either a directory (empty name()) or.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
bool chDir(const fileName &dir)
Change the current directory to the one given and return true,.
static void noParallel()
Remove the parallel options.
static const pointMesh & New(const polyMesh &mesh)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
static void readFieldFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< CompactIOField< Field< Type >, Type >> > &lagrangianFields)
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
const word & regionDir(const word ®ionName)
bool read(const char *, int32_t &)
virtual bool ln(const fileName &src, const fileName &dst) const =0
Create a softlink. dst should not exist. Returns true if.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
static const word null
An empty word.
List< label > labelList
A List of labels.
const word dictName("particleTrackDict")
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
virtual fileName filePath(const bool checkGlobal, const IOobject &, const word &typeName) const =0
Search for an object. checkGlobal : also check undecomposed case.
const fileOperation & fileHandler()
Get current file handler.
fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true)
Read a directory and return the entries as a string list.
static word controlDictName
The default control dictionary name (normally "controlDict")
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)
static const word prefix
The prefix to local: lagrangian.
word name(const complex &)
Return a string representation of a complex.
IOobject dictIO(dictName, runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE)
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
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.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const Time & time() const
Return time.
fileName cwd()
Return current working directory path name.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
static void addNote(const string &)
Add extra notes for the usage information.
static void readFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< IOField< Type >>> &lagrangianFields)
Foam::argList args(argc, argv)
List< fileName > fileNameList
A List of fileNames.
fileName objectPath() const
Return complete path + object name.
wordList selectRegionNames(const argList &args, const Time &runTime)
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
IOList< label > labelIOList
Label container classes.