90 #include "readFields.H"
103 void decomposeUniform
105 const bool copyUniform,
106 const bool distributeUniform,
108 const Time& procRunTime,
112 const fileName uniformDir(regionDir/
"uniform");
116 Info<<
"Detected additional non-decomposed files in "
123 if (copyUniform || distributeUniform)
137 string parentPath =
string(
"..")/
"..";
141 parentPath = parentPath/
"..";
151 parentPath/runTime.
name()/uniformDir,
181 Info<<
"Wrote decomposition as volScalarField::Internal to "
182 << cellProc.name() <<
" for use in postprocessing."
192 int main(
int argc,
char *argv[])
196 "decompose a mesh and fields of a case for parallel execution"
205 "write cell processor indices as a volScalarField::Internal for "
211 "Copy \a 0 directory to processor* rather than decompose the fields"
216 "copy any uniform/ directories too"
221 "use existing geometry decomposition and convert fields only"
226 "opposite of -fields; only decompose geometry"
231 "skip decomposing cellSets, faceSets, pointSets"
236 "remove existing processor*/ subdirs before decomposing the geometry"
253 if (decomposeGeomOnly)
255 Info<<
"Skipping decomposing fields" <<
nl <<
endl;
257 if (decomposeFieldsOnly || copyZero)
260 <<
"Cannot combine geometry-only decomposition (-noFields)"
261 <<
" with field decomposition (-fields or -copyZero)"
273 const Time& runTime = runTimes.completeTime();
283 <<
"Cannot force the decomposition of a single region"
287 const label nProcs0 =
290 Info<<
"Removing " << nProcs0
291 <<
" existing processor directories" <<
endl;
298 runTimes.completeTime().path(),
307 if (d.find(
"processors") == 0)
316 if (d.find(
"processor") == 0)
338 const label nProcs0 =
341 if (nProcs0 && nProcs0 != runTimes.nProcs())
344 <<
"Case is already decomposed with " << nProcs0
345 <<
" domains, use the -force option or manually" <<
nl
346 <<
"remove processor directories before decomposing. e.g.,"
348 <<
" rm -rf " << runTimes.completeTime().path().c_str()
364 const word& regionDir =
376 const label nDomains =
377 decomposeParDict.
lookup<
label>(
"numberOfSubdomains");
383 if (decomposeFieldsOnly && nProcs != nDomains)
386 <<
"Specified -fields, but the case was decomposed with "
387 << nProcs <<
" domains" <<
nl <<
"instead of " << nDomains
388 <<
" domains as specified in decomposeParDict" <<
nl
393 const label distributeUniform =
399 if (!decomposeFieldsOnly || !copyZero)
403 writeDecomposition(meshes);
426 runTimes.setTime(times[timei], timei);
428 Info<<
"Time = " << runTimes.completeTime().userTimeName() <<
endl;
432 if (!decomposeFieldsOnly || !copyZero)
438 if (decomposeFieldsOnly)
452 == runTimes.completeTime().
name()
455 writeDecomposition(meshes);
462 for (
label proci = 0; proci < meshes.
nProcs(); proci++)
464 fieldDecomposerList.set(proci,
nullptr);
465 dimFieldDecomposerList.set(proci,
nullptr);
466 pointFieldDecomposerList.set(proci,
nullptr);
471 if (decomposeGeomOnly)
480 runTimes.completeTime().timePath();
483 for (
label proci = 0; proci < runTimes.nProcs(); proci++)
485 const Time& procRunTime = runTimes.procTimes()[proci];
503 if (procTimePath != prevProcTimePath)
505 Info<<
"Processor " << proci
506 <<
": copying " << completeTimePath <<
nl
507 <<
" to " << procTimePath <<
endl;
509 prevProcTimePath = procTimePath;
522 runTimes.completeTime().
name()
535 volSphericalTensorFields
548 dimSphericalTensorFields;
553 dimSphericalTensorFields
567 surfaceSphericalTensorFields;
572 surfaceSphericalTensorFields
579 surfaceSymmTensorFields
607 lagrangianPositions(cloudDirs.size());
609 cellParticles(cloudDirs.size());
611 lagrangianLabelFields(cloudDirs.size());
613 lagrangianLabelFieldFields(cloudDirs.size());
615 lagrangianScalarFields(cloudDirs.size());
617 lagrangianScalarFieldFields(cloudDirs.size());
619 lagrangianVectorFields(cloudDirs.size());
621 lagrangianVectorFieldFields(cloudDirs.size());
623 lagrangianSphericalTensorFields(cloudDirs.size());
625 lagrangianSphericalTensorFieldFields(cloudDirs.size());
627 lagrangianSymmTensorFields(cloudDirs.size());
629 lagrangianSymmTensorFieldFields(cloudDirs.size());
631 lagrangianTensorFields(cloudDirs.size());
633 lagrangianTensorFieldFields(cloudDirs.size());
642 runTimes.completeTime().
name(),
649 IOobject* positionsPtr = sprayObjs.lookup
657 Info<<
"Identified lagrangian data set: "
658 << cloudDirs[i] <<
endl;
659 lagrangianPositions.set
686 lagrangianPositions[cloudI],
690 iter().index() = index ++;
692 label celli = iter().cell();
702 <<
"Illegal cell number " << celli
703 <<
" for particle with index "
708 <<
"Cell number should be between 0 and "
710 <<
"On this mesh the particle should"
722 if (!cellParticles[cloudI][celli])
724 cellParticles[cloudI][celli] =
728 cellParticles[cloudI][celli]->append(&iter());
735 runTimes.completeTime().
name(),
745 lagrangianLabelFields
751 lagrangianLabelFieldFields
757 lagrangianScalarFields
763 lagrangianScalarFieldFields
769 lagrangianVectorFields
775 lagrangianVectorFieldFields
781 lagrangianSphericalTensorFields
787 lagrangianSphericalTensorFieldFields
793 lagrangianSymmTensorFields
799 lagrangianSymmTensorFieldFields
805 lagrangianTensorFields
811 lagrangianTensorFieldFields
818 lagrangianPositions.setSize(cloudI);
819 cellParticles.setSize(cloudI);
820 lagrangianLabelFields.setSize(cloudI);
821 lagrangianLabelFieldFields.setSize(cloudI);
822 lagrangianScalarFields.setSize(cloudI);
823 lagrangianScalarFieldFields.setSize(cloudI);
824 lagrangianVectorFields.setSize(cloudI);
825 lagrangianVectorFieldFields.setSize(cloudI);
826 lagrangianSphericalTensorFields.setSize(cloudI);
827 lagrangianSphericalTensorFieldFields.setSize(cloudI);
828 lagrangianSymmTensorFields.setSize(cloudI);
829 lagrangianSymmTensorFieldFields.setSize(cloudI);
830 lagrangianTensorFields.setSize(cloudI);
831 lagrangianTensorFieldFields.setSize(cloudI);
836 for (
label proci = 0; proci < meshes.
nProcs(); proci++)
838 Info<<
"Processor " << proci <<
": field transfer" <<
endl;
842 if (!fieldDecomposerList.set(proci))
844 fieldDecomposerList.set
858 fieldDecomposerList[proci];
864 volSphericalTensorFields
873 surfaceSphericalTensorFields
877 surfaceSymmTensorFields
881 if (times.
size() == 1)
884 fieldDecomposerList.set(proci,
nullptr);
890 if (!dimFieldDecomposerList.set(proci))
892 dimFieldDecomposerList.set
905 dimFieldDecomposerList[proci];
913 if (times.
size() == 1)
915 dimFieldDecomposerList.set(proci,
nullptr);
922 pointScalarFields.
size()
923 || pointVectorFields.
size()
924 || pointSphericalTensorFields.
size()
925 || pointSymmTensorFields.
size()
926 || pointTensorFields.
size()
932 if (!pointFieldDecomposerList.set(proci))
934 pointFieldDecomposerList.set
946 pointFieldDecomposerList[proci];
952 pointSphericalTensorFields
957 if (times.
size() == 1)
959 pointFieldDecomposerList.set(proci,
nullptr);
964 forAll(lagrangianPositions, cloudI)
966 if (lagrangianPositions[cloudI].size())
975 lagrangianPositions[cloudI],
976 cellParticles[cloudI]
984 lagrangianLabelFields[cloudI]
986 fieldDecomposer.decomposeFieldFields
989 lagrangianLabelFieldFields[cloudI]
994 lagrangianScalarFields[cloudI]
996 fieldDecomposer.decomposeFieldFields
999 lagrangianScalarFieldFields[cloudI]
1004 lagrangianVectorFields[cloudI]
1006 fieldDecomposer.decomposeFieldFields
1009 lagrangianVectorFieldFields[cloudI]
1014 lagrangianSphericalTensorFields[cloudI]
1016 fieldDecomposer.decomposeFieldFields
1019 lagrangianSphericalTensorFieldFields[cloudI]
1024 lagrangianSymmTensorFields[cloudI]
1026 fieldDecomposer.decomposeFieldFields
1029 lagrangianSymmTensorFieldFields[cloudI]
1034 lagrangianTensorFields[cloudI]
1036 fieldDecomposer.decomposeFieldFields
1039 lagrangianTensorFieldFields[cloudI]
1051 runTimes.completeTime(),
1065 runTimes.completeTime(),
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
static pointMesh & New(const polyMesh &mesh)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
List of IOobjects with searching and retrieving facilities.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Template class for non-intrusive linked lists.
void size(const label)
Override size to be inconsistent with allocated storage.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static word controlDictName
The default control dictionary name (normally "controlDict")
fileName timePath() const
Return current time path.
label size() const
Return the number of elements in the UPtrList.
static void addNote(const string &)
Add extra notes for the usage information.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
static void noParallel()
Remove the parallel options.
static const word prefix
The prefix to local: lagrangian.
static dictionary decomposeParDict(const Time &time)
Read and return the decomposeParDict.
A list of keyword definitions, which are a keyword followed by any number of values (e....
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Dimensioned field decomposer.
void decomposeFields(const PtrList< GeoField > &fields) const
Decompose llist of fields.
const word & name() const
Return const reference to name.
Automatic domain decomposition class for finite-volume meshes.
const labelListList & procPointAddressing() const
Access the labels of points for each processor.
label nProcs() const
Return the number of processors in the decomposition.
void writeProcs(const bool doSets) const
Write the decomposed meshes and associated data.
bool readDecompose(const bool doSets)
Read in the complete mesh. Read the processor meshes if they are.
const PtrList< fvMesh > & procMeshes() const
Access the processor meshes.
const labelListList & procFaceAddressing() const
Access the labels of faces for each processor (see notes above)
const PtrList< surfaceLabelField::Boundary > & procFaceAddressingBf() const
Access the labels of faces for each processor (see notes above)
const labelList & cellProc() const
Return the distribution as an FV field for writing.
const labelListList & procCellAddressing() const
Access the labels of cells for each processor.
const fvMesh & completeMesh() const
Access the global mesh.
fvMesh::readUpdateState readUpdateDecompose()
Read-update for decomposition.
A class for handling file names.
word name() const
Return file name (part beyond last /)
virtual bool rmDir(const fileName &) const =0
Remove a directory and its contents.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
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 bool ln(const fileName &src, const fileName &dst) const =0
Create a softlink. dst should not exist. Returns true if.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
virtual fileName filePath(const bool globalFile, const IOobject &, const word &typeName) const =0
Search for an object. globalFile : also check undecomposed case.
Finite Volume volume and surface field decomposer.
void decomposeFields(const PtrList< GeoField > &fields) const
Decompose a list of fields.
const Time & time() const
Return the top-level database.
const word & name() const
Return reference to name.
Lagrangian field decomposer.
static void readFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< IOField< Type >>> &lagrangianFields)
static void readFieldFields(const label cloudI, const IOobjectList &lagrangianObjects, PtrList< PtrList< CompactIOField< Field< Type >>>> &lagrangianFields)
void decomposeFields(const PtrList< GeoField > &fields) const
Decompose a list of fields.
Mesh representing a set of points created from polyMesh.
const fileName & facesInstance() const
Return the current instance directory for faces.
static word defaultRegion
Return the default region name.
readUpdateState
Enumeration defining the state of the mesh after a read update.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
A class for handling character strings derived from std::string.
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
A class for handling words, derived from string.
static const word null
An empty word.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
const fileOperation & fileHandler()
Get current file handler.
errorManipArg< error, int > exit(error &err, const int errNo=1)
fileName cwd()
Return current working directory path name.
bool read(const char *, int32_t &)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
const dimensionSet dimless
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
List< scalar > scalarList
A List of scalars.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
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.
bool chDir(const fileName &dir)
Change the current directory to the one given and return true,.
const Foam::wordList regionNames(args.optionFound("allRegions") ? runTime .controlDict().subDict("regionSolvers").toc() :wordList(1, args.optionFound("region") ? args.optionRead< word >("region") :polyMesh::defaultRegion))
Foam::argList args(argc, argv)