Go to the documentation of this file.
45 externalCoupledFunctionObject,
69 const word& regionGroupName,
77 /string::validate<fileName>(groupName)
87 return fileName(baseDir()/(lockName +
".lock"));
104 if (log_)
Info<<
type() <<
": creating lock file" <<
endl;
120 if (log_)
Info<<
type() <<
": removing lock file" <<
endl;
133 if (log_)
Info<<
type() <<
": removing all read files" <<
endl;
135 forAll(regionGroupNames_, regionI)
137 const word& compName = regionGroupNames_[regionI];
139 const labelList& groups = regionToGroups_[compName];
142 label groupI = groups[i];
143 const wordRe& groupName = groupNames_[groupI];
145 forAll(groupReadFields_[groupI], fieldI)
147 const word& fieldName = groupReadFields_[groupI][fieldI];
150 groupDir(commsDir_, compName, groupName)
166 if (log_)
Info<<
type() <<
": removing all write files" <<
endl;
168 forAll(regionGroupNames_, regionI)
170 const word& compName = regionGroupNames_[regionI];
172 const labelList& groups = regionToGroups_[compName];
175 label groupI = groups[i];
176 const wordRe& groupName = groupNames_[groupI];
178 forAll(groupReadFields_[groupI], fieldI)
180 const word& fieldName = groupReadFields_[groupI][fieldI];
183 groupDir(commsDir_, compName, groupName)
198 if (log_)
Info<<
type() <<
": beginning wait for lock file " << fName <<
nl;
204 if (totalTime > timeOut_)
207 <<
"Wait time exceeded time out time of " << timeOut_
224 sleep(waitInterval_);
225 totalTime += waitInterval_;
243 const label nColumns,
268 values[columnI].
setSize(procNRows);
271 for (
label rowI = 0; rowI < procNRows; rowI++)
276 if (!masterFilePtr().good())
279 <<
"Trying to read data for processor " << procI
281 <<
". Does your file have as many rows as there are"
282 <<
" patch faces (" << globalFaces.
size()
286 masterFilePtr().getLine(
line);
287 }
while (
line.empty() ||
line[0] ==
'#');
291 for (
label columnI = 0; columnI < nColumns; columnI++)
293 lineStr >> values[columnI][rowI];
335 for (
label rowI = 0; rowI < procNRows; rowI++)
340 if (!masterFilePtr().good())
343 <<
"Trying to read data for processor " << procI
345 <<
". Does your file have as many rows as there are"
346 <<
" patch faces (" << globalFaces.
size()
350 masterFilePtr().getLine(
line);
351 }
while (
line.empty() ||
line[0] ==
'#');
364 for (
label rowI = 0; rowI < nRows; rowI++)
367 lines <<
line.c_str() <<
nl;
382 regionNames[i] = meshes[i].dbDir();
386 checkOrder(regionNames);
388 fileName dir(groupDir(commsDir, compositeName(regionNames), groupName));
392 Info<< typeName <<
": writing geometry to " << dir <<
endl;
435 allFaceIDs.
append(
p.start()+pI);
476 forAll(collectedPoints, procI)
478 allMeshesPoints.
append(collectedPoints[procI]);
482 forAll(collectedFaces, procI)
484 const faceList& procFaces = collectedFaces[procI];
488 const face&
f = procFaces[faceI];
495 allMeshesFaces.
append(newFace);
505 <<
" writing " << allMeshesPoints.size() <<
" points to "
506 << osPointsPtr().name() <<
endl;
508 <<
" writing " << allMeshesFaces.size() <<
" faces to "
509 << osFacesPtr().name() <<
endl;
514 if (osPointsPtr.
valid())
516 osPointsPtr() << allMeshesPoints <<
endl;
520 if (osFacesPtr.
valid())
522 osFacesPtr() << allMeshesFaces <<
endl;
532 if (regionNames.
size() == 0)
538 else if (regionNames.
size() == 1)
548 return regionNames[0];
554 checkOrder(regionNames);
556 word composite(regionNames[0]);
557 for (
label i = 1; i < regionNames.
size(); i++)
559 composite +=
"_" + regionNames[i];
577 <<
"regionNames " << regionNames <<
" not in alphabetical order :"
585 forAll(regionGroupNames_, regionI)
587 const word& compName = regionGroupNames_[regionI];
588 const wordList& regionNames = regionGroupRegions_[regionI];
598 const labelList& groups = regionToGroups_[compName];
602 label groupI = groups[i];
603 const wordRe& groupName = groupNames_[groupI];
610 bool ok = readData<scalar>
616 ok = ok || readData<vector>
622 ok = ok || readData<sphericalTensor>
628 ok = ok || readData<symmTensor>
634 ok = ok || readData<tensor>
644 <<
"Field " << fieldName <<
" in regions " << compName
645 <<
" was not found." <<
endl;
655 forAll(regionGroupNames_, regionI)
657 const word& compName = regionGroupNames_[regionI];
658 const wordList& regionNames = regionGroupRegions_[regionI];
668 const labelList& groups = regionToGroups_[compName];
672 label groupI = groups[i];
673 const wordRe& groupName = groupNames_[groupI];
680 bool ok = writeData<scalar>
686 ok = ok || writeData<vector>
692 ok = ok || writeData<sphericalTensor>
698 ok = ok || writeData<symmTensor>
704 ok = ok || writeData<tensor>
714 <<
"Field " << fieldName <<
" in regions " << compName
715 <<
" was not found." <<
endl;
731 forAll(regionGroupRegions_, i)
733 const word& compName = regionGroupNames_[i];
734 const wordList& regionNames = regionGroupRegions_[i];
744 const labelList& groups = regionToGroups_[compName];
748 label groupI = groups[i];
749 const wordRe& groupName = groupNames_[groupI];
754 fileName dir(groupDir(commsDir_, compName, groupName));
758 ||
isFile(dir/
"patchFaces");
763 writeGeometry(meshes, commsDir_, groupName);
802 if (!initByExternal_)
840 && (!initialised_ || time_.timeIndex() % calcFrequency_ == 0)
928 if (!iter().isDict())
931 <<
"Regions must be specified in dictionary format"
935 const wordRe regionGroupName(iter().keyword());
940 const wordList regionNames(allRegionNames, regionIDs);
942 regionGroupNames_.append(compositeName(regionNames));
943 regionGroupRegions_.append(regionNames);
948 if (!regionIter().isDict())
951 <<
"Regions must be specified in dictionary format"
954 const wordRe groupName(regionIter().keyword());
955 const dictionary& groupDict = regionIter().dict();
957 label nGroups = groupNames_.size();
963 regionGroupNames_.last()
965 if (fnd != regionToGroups_.end())
967 fnd().append(nGroups);
971 regionToGroups_.insert
973 regionGroupNames_.last(),
977 groupNames_.append(groupName);
979 groupWriteFields_.append(writeFields);
987 Info<<
type() <<
": Communicating with regions:" <<
endl;
988 forAll(regionGroupNames_, rgI)
991 const word& compName = regionGroupNames_[rgI];
994 const labelList& groups = regionToGroups_[compName];
997 label groupI = groups[i];
998 const wordRe& groupName = groupNames_[groupI];
1000 Info<<
indent <<
"patchGroup: " << groupName <<
"\t"
1003 <<
indent <<
"Reading fields: "
1004 << groupReadFields_[groupI]
1006 <<
indent <<
"Writing fields: "
1007 << groupWriteFields_[groupI]
1021 forAll(regionGroupNames_, rgI)
1023 const word& compName = regionGroupNames_[rgI];
1025 const labelList& groups = regionToGroups_[compName];
1028 label groupI = groups[i];
1029 const wordRe& groupName = groupNames_[groupI];
1031 fileName dir(groupDir(commsDir_, compName, groupName));
1036 Info<<
type() <<
": creating communications directory "
vectorField pointField
pointField is a vectorField.
void writeData() const
Write data for all regions, all fields.
virtual const pointField & points() const
Return raw points.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from string.
Output inter-processor communications stream operating on external buffer.
A class for handling file names.
bool exists(const fileName &, const bool checkGzip=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An STL-conforming iterator.
void createLockFile() const
Create lock file.
static word defaultRegion
Return the default region name.
#define forAll(list, i)
Loop across all elements in list.
virtual bool timeSet()
Called when time was set at the end of the Time::operator++.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
void readLines(const label nRows, autoPtr< IFstream > &masterFilePtr, OStringStream &data) const
Read (and distribute) lines from stream. Every processor.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
void readColumns(const label nRows, const label nColumns, autoPtr< IFstream > &masterFilePtr, List< scalarField > &data) const
Read (and distribute) scalar columns from stream. Every processor.
fileName baseDir() const
Return the file path to the base communications directory.
bool read(const char *, int32_t &)
static label nProcs(const label communicator=0)
Number of processes in parallel run.
void removeWriteFiles() const
Remove files written by OpenFOAM.
fileName commsDir_
Path to communications directory.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
static word lockName
Name of lock file.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
label localSize() const
My local size.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual bool execute(const bool forceWrite)
Called at each ++ or += of the time-loop.
A class for handling character strings derived from std::string.
virtual bool start()
Called at the start of the time-loop.
This function object reads fields from the time directories and adds them to the mesh database for fu...
virtual bool read(const dictionary &)
Read and set the function object if its data have changed.
labelList patchFaces(const polyBoundaryMesh &patches, const wordList &names)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
unsigned int sleep(const unsigned int)
Sleep for the specified number of seconds.
A wordRe is a word, but can also have a regular expression for matching words.
Mesh consisting of general polyhedral cells.
Abstract base-class for Time/database function objects.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
void removeReadFiles() const
Remove files written by external code.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
void wait() const
Wait for response from external source.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static string patchKey
Name of patch key, e.g. '# Patch:' when looking for start of patch data.
A patch is a list of labels that address the faces in the global face list.
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
DynamicField< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
A List with indirect addressing.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
static int masterNo()
Process index of the master.
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
const bool writeData(readBool(pdfDictionary.lookup("writeData")))
A list of keyword definitions, which are a keyword followed by any number of values (e....
Macros for easy insertion into run-time selection tables.
Mesh data needed to do the Finite Volume discretisation.
Input from memory buffer stream.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
errorManip< error > abort(error &err)
static fileName groupDir(const fileName &commsDir, const word ®ionsName, const wordRe &groupName)
Return the file path to the communications directory for the region.
bool isDir(const fileName &)
Does the name exist as a DIRECTORY in the file system?
bool isFile(const fileName &, const bool checkGzip=true)
Does the name exist as a FILE in the file system?
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Ostream & indent(Ostream &os)
Indent stream.
List< Key > sortedToc() const
Return the table of contents as a sorted list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
static bool master(const label communicator=0)
Am I the master process.
static void writeGeometry(const UPtrList< const fvMesh > &meshes, const fileName &commsDir, const wordRe &groupName)
Write geometry for the group/patch.
static void checkOrder(const wordList &)
externalCoupledFunctionObject(const externalCoupledFunctionObject &)
Disallow default bitwise copy construc.
virtual ~externalCoupledFunctionObject()
Destructor.
void setSize(const label)
Reset size of List.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
label size() const
Global sum of localSizes.
fileName lockFile() const
Return the file path to the lock file.
wordList fieldNames(const IOobjectList &objects, const bool syncPar)
Get sorted names of fields of type. If syncPar and running in parallel.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Output to memory buffer stream.
bool set(const label) const
Is element set.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
label size() const
Return the number of elements in the PtrList.
static const word null
An empty word.
static word compositeName(const wordList &)
Create single name by appending words (in sorted order),.
virtual bool end()
Called when Time::run() determines that the time-loop exits.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
void reset(T *=0)
If object pointer already set, delete object and set to given.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
A face is a list of labels corresponding to mesh vertices.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
bool clean()
Cleanup file name.
void size(const label)
Override size to be inconsistent with allocated storage.
Input inter-processor communications stream operating on external buffer.
virtual void on()
Switch the function object on.
const globalMeshData & globalData() const
Return parallel info.
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
bool good() const
Return true if next operation might succeed.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch IDs corresponding to the given names.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
void removeLockFile() const
Remove lock file.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
Database for solution data, solver performance and other reduced data.
void readFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh > > &fields, const bool readOldTime)
word name(const complex &)
Return a string representation of a complex.
virtual void flush()
Flush stream.
void readData()
Read data for all regions, all fields.
const word & name() const
Return reference to name.
A list of faces which address into the list of points.
label size() const
Return the number of elements in the UPtrList.
virtual void off()
Switch the function object off.