94 #include "readFields.H" 100 using namespace Foam;
107 void decomposeUniform
109 const bool copyUniform,
110 const bool distributeUniform,
112 const Time& procRunTime,
116 const fileName uniformDir(regionDir/
"uniform");
120 Info<<
"Detected additional non-decomposed files in " 127 if (copyUniform || distributeUniform)
141 string parentPath =
string(
"..")/
"..";
145 parentPath = parentPath/
"..";
155 parentPath/runTime.
timeName()/uniformDir,
185 cellDecomposition.write();
187 Info<<
nl <<
"Wrote decomposition to " 188 << cellDecomposition.relativeObjectPath()
189 <<
" for use in manual decomposition." <<
endl;
209 Info<<
nl <<
"Wrote decomposition as volScalarField to " 210 << cellDist.name() <<
" for use in postprocessing." 220 int main(
int argc,
char *argv[])
224 "decompose a mesh and fields of a case for parallel execution" 234 "write cell distribution as a labelList - for use with 'manual' " 235 "decomposition method or as a volScalarField for post-processing." 240 "Copy \a 0 directory to processor* rather than decompose the fields" 245 "copy any uniform/ directories too" 250 "use existing geometry decomposition and convert fields only" 255 "opposite of -fields; only decompose geometry" 260 "skip decomposing cellSets, faceSets, pointSets" 265 "remove existing processor*/ subdirs before decomposing the geometry" 282 if (decomposeGeomOnly)
284 Info<<
"Skipping decomposing fields" 287 if (decomposeFieldsOnly || copyZero)
290 <<
"Cannot combine geometry-only decomposition (-noFields)" 291 <<
" with field decomposition (-fields or -copyZero)" 317 <<
"Cannot force the decomposition of a single region" 321 Info<<
"Removing " << nProcs
322 <<
" existing processor directories" <<
endl;
329 runTimes.completeTime().path(),
338 if (d.find(
"processors") == 0)
347 if (d.find(
"processor") == 0)
362 else if (nProcs && !region && !decomposeFieldsOnly)
365 <<
"Case is already decomposed with " << nProcs
366 <<
" domains, use the -force option or manually" <<
nl 367 <<
"remove processor directories before decomposing. e.g.," 369 <<
" rm -rf " << runTimes.completeTime().path().c_str()
381 forAll(regionNames, regioni)
383 const word& regionName = regionNames[regioni];
386 Info<<
"\n\nDecomposing mesh " << regionName <<
nl <<
endl;
393 const label nDomains =
394 decomposeParDict.
lookup<
label>(
"numberOfSubdomains");
400 if (decomposeFieldsOnly && nProcs != nDomains)
403 <<
"Specified -fields, but the case was decomposed with " 404 << nProcs <<
" domains" <<
nl <<
"instead of " << nDomains
405 <<
" domains as specified in decomposeParDict" <<
nl 410 const label distributeUniform =
419 if (decomposeFieldsOnly)
432 if (writeCellDist) writeDecomposition(meshes);
454 runTimes.setTime(times[timeI], timeI);
456 Info<<
"Time = " << runTimes.completeTime().userTimeName() <<
endl;
460 if (!decomposeFieldsOnly || !copyZero)
466 if (decomposeFieldsOnly)
481 if (writeCellDist) writeDecomposition(meshes);
488 for (
label proci = 0; proci < meshes.
nProcs(); proci++)
490 fieldDecomposerList.set(proci,
nullptr);
491 dimFieldDecomposerList.set(proci,
nullptr);
492 pointFieldDecomposerList.set(proci,
nullptr);
497 if (decomposeGeomOnly)
506 runTimes.completeTime().timePath();
509 for (
label proci = 0; proci < meshes.
nProcs(); proci++)
511 const Time& procRunTime =
530 if (procTimePath != prevProcTimePath)
532 Info<<
"Processor " << proci
533 <<
": copying " << completeTimePath <<
nl 534 <<
" to " << procTimePath <<
endl;
536 prevProcTimePath = procTimePath;
549 runTimes.completeTime().timeName()
562 volSphericalTensorFields
575 dimSphericalTensorFields;
580 dimSphericalTensorFields
594 surfaceSphericalTensorFields;
599 surfaceSphericalTensorFields
606 surfaceSymmTensorFields
634 lagrangianPositions(cloudDirs.size());
636 cellParticles(cloudDirs.size());
638 lagrangianLabelFields(cloudDirs.size());
640 lagrangianLabelFieldFields(cloudDirs.size());
642 lagrangianScalarFields(cloudDirs.size());
644 lagrangianScalarFieldFields(cloudDirs.size());
646 lagrangianVectorFields(cloudDirs.size());
648 lagrangianVectorFieldFields(cloudDirs.size());
650 lagrangianSphericalTensorFields(cloudDirs.size());
652 lagrangianSphericalTensorFieldFields(cloudDirs.size());
654 lagrangianSymmTensorFields(cloudDirs.size());
656 lagrangianSymmTensorFieldFields(cloudDirs.size());
658 lagrangianTensorFields(cloudDirs.size());
660 lagrangianTensorFieldFields(cloudDirs.size());
669 runTimes.completeTime().timeName(),
676 IOobject* positionsPtr = sprayObjs.lookup
684 Info<<
"Identified lagrangian data set: " 685 << cloudDirs[i] <<
endl;
686 lagrangianPositions.set
713 lagrangianPositions[cloudI],
717 iter().index() = index ++;
719 label celli = iter().cell();
729 <<
"Illegal cell number " << celli
730 <<
" for particle with index " 733 << iter().position() <<
nl 734 <<
"Cell number should be between 0 and " 736 <<
"On this mesh the particle should" 743 if (!cellParticles[cloudI][celli])
745 cellParticles[cloudI][celli] =
749 cellParticles[cloudI][celli]->
append(&iter());
756 runTimes.completeTime().timeName(),
766 lagrangianLabelFields
772 lagrangianLabelFieldFields
778 lagrangianScalarFields
784 lagrangianScalarFieldFields
790 lagrangianVectorFields
796 lagrangianVectorFieldFields
802 lagrangianSphericalTensorFields
808 lagrangianSphericalTensorFieldFields
814 lagrangianSymmTensorFields
820 lagrangianSymmTensorFieldFields
826 lagrangianTensorFields
832 lagrangianTensorFieldFields
839 lagrangianPositions.setSize(cloudI);
840 cellParticles.setSize(cloudI);
841 lagrangianLabelFields.setSize(cloudI);
842 lagrangianLabelFieldFields.setSize(cloudI);
843 lagrangianScalarFields.setSize(cloudI);
844 lagrangianScalarFieldFields.setSize(cloudI);
845 lagrangianVectorFields.setSize(cloudI);
846 lagrangianVectorFieldFields.setSize(cloudI);
847 lagrangianSphericalTensorFields.setSize(cloudI);
848 lagrangianSphericalTensorFieldFields.setSize(cloudI);
849 lagrangianSymmTensorFields.setSize(cloudI);
850 lagrangianSymmTensorFieldFields.setSize(cloudI);
851 lagrangianTensorFields.setSize(cloudI);
852 lagrangianTensorFieldFields.setSize(cloudI);
857 for (
label proci = 0; proci < meshes.
nProcs(); proci++)
859 Info<<
"Processor " << proci <<
": field transfer" <<
endl;
863 if (!fieldDecomposerList.set(proci))
865 fieldDecomposerList.set
879 fieldDecomposerList[proci];
885 volSphericalTensorFields
894 surfaceSphericalTensorFields
898 surfaceSymmTensorFields
902 if (times.
size() == 1)
905 fieldDecomposerList.set(proci,
nullptr);
911 if (!dimFieldDecomposerList.set(proci))
913 dimFieldDecomposerList.set
926 dimFieldDecomposerList[proci];
934 if (times.
size() == 1)
936 dimFieldDecomposerList.set(proci,
nullptr);
943 pointScalarFields.size()
944 || pointVectorFields.
size()
945 || pointSphericalTensorFields.
size()
946 || pointSymmTensorFields.
size()
947 || pointTensorFields.
size()
953 if (!pointFieldDecomposerList.set(proci))
955 pointFieldDecomposerList.set
967 pointFieldDecomposerList[proci];
973 pointSphericalTensorFields
978 if (times.
size() == 1)
980 pointFieldDecomposerList.set(proci,
nullptr);
985 forAll(lagrangianPositions, cloudI)
987 if (lagrangianPositions[cloudI].size())
996 lagrangianPositions[cloudI],
997 cellParticles[cloudI]
1005 lagrangianLabelFields[cloudI]
1007 fieldDecomposer.decomposeFieldFields
1010 lagrangianLabelFieldFields[cloudI]
1015 lagrangianScalarFields[cloudI]
1017 fieldDecomposer.decomposeFieldFields
1020 lagrangianScalarFieldFields[cloudI]
1025 lagrangianVectorFields[cloudI]
1027 fieldDecomposer.decomposeFieldFields
1030 lagrangianVectorFieldFields[cloudI]
1035 lagrangianSphericalTensorFields[cloudI]
1037 fieldDecomposer.decomposeFieldFields
1040 lagrangianSphericalTensorFieldFields[cloudI]
1045 lagrangianSymmTensorFields[cloudI]
1047 fieldDecomposer.decomposeFieldFields
1050 lagrangianSymmTensorFieldFields[cloudI]
1055 lagrangianTensorFields[cloudI]
1057 fieldDecomposer.decomposeFieldFields
1060 lagrangianTensorFieldFields[cloudI]
1072 runTimes.completeTime(),
1080 if (regionNames.
size() > 1 && regioni == 0)
1086 runTimes.completeTime(),
void writeProcs(const bool doSets) const
Write the decomposed meshes and associated data.
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.
A class for handling file names.
List of IOobjects with searching and retrieving facilities.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
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.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
fileName timePath() const
Return current time path.
labelList cellToProc() const
Return the distribution as an FV field for writing.
Template class for non-intrusive linked lists.
Dimensioned field decomposer.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
void size(const label)
Override size to be inconsistent with allocated storage.
const labelListList & procFaceAddressing() const
Access the labels of faces for each processor (see notes above)
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.
const dimensionSet dimless
const Time & time() const
Return the top-level database.
Automatic domain decomposition class for finite-volume meshes.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Mesh representing a set of points created from polyMesh.
static void readFieldFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< CompactIOField< Field< Type >, Type >> > &lagrangianFields)
void decompose()
Decompose the complete mesh to create the processor meshes and.
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.
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
A class for handling words, derived from string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const labelListList & procCellAddressing() const
Access the labels of cells for each processor.
virtual fileName filePath(const bool globalFile, const IOobject &, const word &typeName) const =0
Search for an object. globalFile : also check undecomposed case.
fvMesh::readUpdateState readUpdate()
...
List< scalar > scalarList
A List of scalars.
static const word null
An empty word.
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.
const PtrList< surfaceLabelField::Boundary > & procFaceAddressingBf() const
Access the labels of faces for each processor (see notes above)
static word controlDictName
The default control dictionary name (normally "controlDict")
static dictionary decomposeParDict(const Time &time)
Read and return the decomposeParDict.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const =0
Copy, recursively if necessary, the source to the destination.
Finite Volume volume and surface field decomposer.
static const word prefix
The prefix to local: lagrangian.
static pointMesh & New(polyMesh &mesh)
void append(const T &a)
Add at tail of list.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
label size() const
Return the number of elements in the UPtrList.
void decomposeFields(const PtrList< GeoField > &fields) const
Decompose llist of fields.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
fileName cwd()
Return current working directory path name.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
const labelListList & procPointAddressing() const
Access the labels of points for each processor.
const PtrList< fvMesh > & procMeshes() const
Access the processor meshes.
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.
readUpdateState
Enumeration defining the state of the mesh after a read update.
virtual bool write(const bool write=true) const
Write using setting from DB.
static void readFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< IOField< Type >>> &lagrangianFields)
void decomposeFields(const PtrList< GeoField > &fields) const
Decompose a list of fields.
Foam::argList args(argc, argv)
const fvMesh & completeMesh() const
Access the global mesh.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
A class for handling character strings derived from std::string.
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.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Lagrangian field decomposer.
label nProcs() const
Return the number of processors in the decomposition.
void decomposeFields(const PtrList< GeoField > &fields) const
Decompose a list of fields.