56Foam::functionObjects::caseInfo::writeFormatNames_
58 { writeFormat::dict,
"dictionary" },
59 { writeFormat::json,
"json" },
63Foam::functionObjects::caseInfo::lookupModeNames_
65 { lookupMode::none,
"none" },
66 { lookupMode::warn,
"warn" },
67 { lookupMode::error,
"error" },
74void Foam::functionObjects::caseInfo::report(
const string& str)
const
96void Foam::functionObjects::caseInfo::processDict
100 const entry* includePtr,
101 const entry* excludePtr
104 auto sanitise = [](
const wordRe& w){
109 while (str.starts_with(
'_'))
118 const wordRes includeEntryNames(includePtr->stream());
119 for (
const auto& nameRegex : includeEntryNames)
124 if (nameRegex.contains(
'/') || nameRegex.contains(
'.'))
126 auto copyPtr =
e->clone();
127 copyPtr->keyword() = sanitise(nameRegex);
128 dict.add(copyPtr.ptr());
139 "Unable to find entry "
153 const wordRes excludeEntryNames(excludePtr->stream());
155 for (
const auto& nameRegex : excludeEntryNames)
160 allData.remove(
e->keyword());
179 out.add(
"case", time_.globalCaseName());
180 out.add(
"path",
time_.globalPath());
182 out.add(
"nTimes",
time_.times().size());
194 for (
const auto&
e : dictionaries)
196 const auto& keyword =
e.keyword();
201 <<
"Entries must be specified in dictionary format. Please "
202 <<
"correct entry " << keyword
208 auto* includePtr = inputDict.
findEntry(
"include");
209 auto* excludePtr = inputDict.
findEntry(
"exclude");
211 const auto* ePtr = inputDict.
findEntry(
"name");
240 for (
auto&
e : dictionaries)
242 const auto& keyword =
e.keyword();
247 <<
"Entries must be specified in dictionary format. Please "
248 <<
"correct entry " << keyword
254 auto* includePtr = inputDict.findEntry(
"include");
255 auto* excludePtr = inputDict.findEntry(
"exclude");
257 const auto* ePtr = inputDict.findEntry(
"path");
261 fileName
path(ePtr->stream());
271 const word oldTypeName = IOdictionary::typeName;
272 const_cast<word&
>(IOdictionary::typeName) =
word::null;
276 out.subDictOrAdd(keyword),
282 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
284 dictionaries.remove(keyword);
295 for (
const auto& fo : functionObjectNames_)
298 if (getObjectResultDict(fo,
dict))
304 report(
"No result entries found for function object " + fo);
312 const polyMesh&
mesh,
316 dict.add(
"nGeometricD",
mesh.nGeometricD());
317 dict.add(
"nSolutionD",
mesh.nSolutionD());
319 const auto& globalData =
mesh.globalData();
321 dict.add(
"nPoints", globalData.nTotalPoints());
322 dict.add(
"nFaces", globalData.nTotalFaces());
323 dict.add(
"nCells", globalData.nTotalCells());
325 dict.add(
"nPatches",
mesh.boundaryMesh().nNonProcessor());
327 dict.add(
"pointZones",
mesh.pointZones().names());
328 dict.add(
"faceZones",
mesh.faceZones().names());
329 dict.add(
"cellZones",
mesh.cellZones().names());
331 dict.add(
"boundsMin",
mesh.bounds().min());
332 dict.add(
"boundsMax",
mesh.bounds().max());
340 template<
class GeoFieldType>
343 for (
const GeoFieldType& obj :
mesh.csorted<GeoFieldType>())
347 const auto& bf = obj.boundaryField();
350 for (
const auto& pf : bf)
354 objDict.add(pf.patch().name(), pf.type());
361 template<
template<
typename>
class FieldType>
381 const auto&
pbm =
mesh.boundaryMesh();
382 for (
const auto&
pp :
pbm)
392 addPatchDetails<VolumeField>(
mesh,
fld);
420 writeFormat_(writeFormat::
dict),
421 lookupMode_(lookupMode::warn)
433 writeFormatNames_.readIfPresent(
"writeFormat",
dict, writeFormat_);
436 lookupModeNames_.readIfPresent(
"lookupMode",
dict, lookupMode_);
438 dictionaries_ =
dict.subOrEmptyDict(
"dictionaries");
440 dict.readIfPresent(
"functionObjects", functionObjectNames_);
472 writeRegisteredDicts(time_, dataDicts, dicts);
475 writeFileDicts(dataDicts, dicts);
495 for (
const word& keyword : meshDicts.sortedToc())
501 +
"' : Unable to process dictionary entry '"
512 if (Pstream::master())
514 auto filePtr = newFileAtTime(functionObject::name(), time_.value());
520 switch (writeFormat_)
522 case writeFormat::dict:
524 IOdictionary::writeData(
os);
527 case writeFormat::json:
529 JSONformatter json(
os);
530 json.writeDict(data);
535 Info<<
"Written " << writeFormatNames_[writeFormat_]
536 <<
" file: " <<
os.name() <<
endl;
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
fileName path() const
The complete path for the object (with instance, local,...).
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
virtual bool writeData(Ostream &) const
The writeData function required by regIOobject write operation.
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
A cloud is a registry collection of lagrangian particles.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
dictionary()
Default construct, a top-level empty dictionary.
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
bool remove(const word &keyword)
Remove an entry specified by keyword.
wordList sortedToc() const
Return the sorted table of contents.
void clear()
Clear the dictionary.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
A class for handling file names.
Abstract base-class for Time/database function objects.
const word & name() const noexcept
Return the name of this functionObject.
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
Collects and writes case information to file.
void writeRegisteredDicts(const objectRegistry &obr, dictionary &dict, dictionary &dictionaries) const
Write registered dictionaries.
writeFormat
Write format enumeration.
lookupMode
Lookup mode enumeration.
void writeMeshStats(const polyMesh &mesh, dictionary &dict) const
Write mesh statistics.
void writeMeta(dictionary &dict) const
Write case meta data.
caseInfo(const caseInfo &)=delete
No copy construct.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
void writeFunctionObjects(dictionary &dict) const
Write function object results.
void writePatches(const fvMesh &mesh, dictionary &dict) const
Write mesh patches.
virtual bool execute()
Execute the function-object operations (no-op).
virtual bool write()
Write the function-object results.
void writeFileDicts(dictionary &dict, dictionary &dictionaries) const
Write file-based dictionaries.
virtual bool read()
Read object.
Base class for function objects, adding functionality to read/write state information (data required ...
stateFunctionObject(const stateFunctionObject &)=delete
No copy construct.
bool getObjectResultDict(const word &objectName, dictionary &dict) const
const Time & time_
Reference to the time database.
Base class for writing single files from the function objects.
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
virtual bool read(const dictionary &dict)
Read.
virtual autoPtr< OFstream > newFileAtTime(const word &name, scalar timeValue) const
Return autoPtr to a new file for a given time.
virtual const string & setExt(const string &ext)
Set extension.
Mesh data needed to do the Finite Volume discretisation.
@ REGEX
Regular expression.
Registry of regIOobjects.
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
Mesh consisting of general polyhedral cells.
string & replaceAll(const std::string &s1, const std::string &s2, size_type pos=0)
Replace all occurrences of sub-string s1 with s2, beginning at pos in the string.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
messageStream Info
Information stream (stdout output on master, null elsewhere).
void addPatchTypeDetails(const fvMesh &mesh, dictionary &dict)
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
void addPatchDetails(const fvMesh &mesh, dictionary &dict)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
autoPtr< OFstream > filePtr