43 namespace functionObjects
55 const Enum<functionObjects::caseInfo::writeFormat>
56 Foam::functionObjects::caseInfo::writeFormatNames_
59 { writeFormat::json,
"json" },
62 const Enum<functionObjects::caseInfo::lookupMode>
63 Foam::functionObjects::caseInfo::lookupModeNames_
65 { lookupMode::none,
"none" },
66 { lookupMode::warn,
"warn" },
67 { lookupMode::error,
"error" },
74 void Foam::functionObjects::caseInfo::report(
const string& str)
const 96 void Foam::functionObjects::caseInfo::processDict
99 const dictionary& targetDict,
100 const entry* includePtr,
101 const entry* excludePtr
104 auto sanitise = [](
const wordRe& w){
106 str.replaceAll(
"/",
"_").replaceAll(
".",
"_");
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());
181 out.add(
"regions", time_.sortedNames<
fvMesh>());
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");
227 dictionaries.
remove(keyword);
237 dictionary& dictionaries
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());
266 if (!
io.typeHeaderOk<dictionary>(
false))
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)
352 if (!isA<processorFvPatch>(pf.patch()))
354 objDict.add(pf.patch().name(), pf.type());
361 template<
template<
typename>
class FieldType>
364 addPatchTypeDetails<FieldType<scalar>>(
mesh,
dict);
365 addPatchTypeDetails<FieldType<vector>>(
mesh,
dict);
366 addPatchTypeDetails<FieldType<sphericalTensor>>(
mesh,
dict);
367 addPatchTypeDetails<FieldType<symmTensor>>(
mesh,
dict);
368 addPatchTypeDetails<FieldType<tensor>>(
mesh,
dict);
381 const auto&
pbm =
mesh.boundaryMesh();
382 for (
const auto&
pp :
pbm)
384 if (!isA<processorPolyPatch>(
pp))
392 addPatchDetails<VolumeField>(
mesh,
fld);
393 addPatchDetails<SurfaceField>(
mesh,
fld);
409 writeFormat_(writeFormat::
dict),
410 lookupMode_(lookupMode::warn)
422 writeFormatNames_.readIfPresent(
"writeFormat",
dict, writeFormat_);
423 lookupModeNames_.readIfPresent(
"lookupMode",
dict, lookupMode_);
425 dictionaries_ =
dict.subOrEmptyDict(
"dictionaries");
427 functionObjectNames_ =
459 writeRegisteredDicts(time_, dataDicts, dicts);
462 writeFileDicts(dataDicts, dicts);
482 for (
const word& keyword : meshDicts.sortedToc())
488 +
"' : Unable to process dictionary entry '" 501 auto filePtr = newFileAtTime(
name(), time_.value());
507 switch (writeFormat_)
514 case writeFormat::json:
516 JSONformatter json(
os);
517 json.writeDict(data);
522 Info<<
"Written " << writeFormatNames_[writeFormat_]
523 <<
" file: " <<
os.name() <<
endl;
const polyBoundaryMesh & pbm
defineTypeNameAndDebug(ObukhovLength, 0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Ostream & endl(Ostream &os)
Add newline and flush stream.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
virtual bool read(const dictionary &dict)
Read the controls.
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual bool execute()
Execute, does nothing.
Macros for easy insertion into run-time selection tables.
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
bool read(const char *buf, int32_t &val)
Same as readInt32.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
bool remove(const word &keyword)
Remove an entry specified by keyword.
void writeMeshStats(const polyMesh &mesh, dictionary &dict) const
Write mesh statistics.
autoPtr< OFstream > filePtr
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
A cloud is a registry collection of lagrangian particles.
void writeMeta(dictionary &dict) const
Write case meta data.
caseInfo(const caseInfo &)=delete
No copy construct.
void writeRegisteredDicts(const objectRegistry &obr, dictionary &dict, dictionary &dictionaries) const
Write registered dictionaries.
static const word null
An empty word.
void addPatchDetails(const fvMesh &mesh, dictionary &dict)
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
virtual bool read(const dictionary &dict)
Read.
void writePatches(const fvMesh &mesh, dictionary &dict) const
Write mesh patches.
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text...
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
List< word > wordList
List of word.
void writeFileDicts(dictionary &dict, dictionary &dictionaries) const
Write file-based dictionaries.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void writeFunctionObjects(dictionary &dict) const
Write function object results.
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
Mesh data needed to do the Finite Volume discretisation.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
Base class for function objects, adding functionality to read/write state information (data required ...
messageStream Info
Information stream (stdout output on master, null elsewhere)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
Base class for writing single files from the function objects.
void addPatchTypeDetails(const fvMesh &mesh, dictionary &dict)
virtual bool write()
Write the caseInfo.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...