41 bool Foam::IOobject::bannerEnabled_(
true);
59 { fileCheckTypes::timeStamp,
"timeStamp" },
60 { fileCheckTypes::timeStampMaster,
"timeStampMaster" },
61 { fileCheckTypes::inotify,
"inotify" },
62 { fileCheckTypes::inotifyMaster,
"inotifyMaster" },
68 fileCheckTypesNames.get
70 "fileModificationChecking",
82 "fileModificationSkew",
93 "maxFileModificationPolls",
103 class addfileModificationCheckingToOpt
109 addfileModificationCheckingToOpt
110 (
const addfileModificationCheckingToOpt&) =
delete;
113 (
const addfileModificationCheckingToOpt&) =
delete;
115 explicit addfileModificationCheckingToOpt(
const char*
name)
120 virtual ~addfileModificationCheckingToOpt() =
default;
135 addfileModificationCheckingToOpt addfileModificationCheckingToOpt_
137 "fileModificationChecking" 171 <<
" called with directory: " <<
path <<
endl;
176 const auto first =
path.find(
'/');
177 const auto last =
path.rfind(
'/');
180 auto nameLen =
path.size();
182 if (first == std::string::npos)
193 || (first == 2 &&
path[1] ==
':')
202 const std::string ending =
path.substr(last+1);
203 nameLen = ending.size();
215 local =
path.substr(first+1, last-first-1);
218 const std::string ending =
path.substr(last+1);
219 nameLen = ending.size();
224 if (!nameLen || nameLen !=
name.size())
227 <<
"has invalid word for name: \"" <<
name 228 <<
"\"\nwhile processing path: " <<
path <<
endl;
240 const fileName& altFile,
251 fileName altPath = altFile;
284 const auto i =
name.rfind(
'.');
286 if (i == std::string::npos || i == 0)
291 return name.substr(i+1);
297 const auto i =
name.rfind(
'.');
299 if (i == std::string::npos || i == 0)
319 objState_(objectState::GOOD),
320 sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
321 sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
334 <<
"Constructing IOobject: " << name_ <<
endl;
342 const fileName& instance,
343 const fileName&
local,
344 const objectRegistry& registry,
348 IOobjectOption(ioOpt),
349 objState_(objectState::GOOD),
350 sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
351 sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
364 <<
"Constructing IOobject: " << name_ <<
endl;
371 const fileName&
path,
372 const objectRegistry& registry,
376 IOobjectOption(ioOpt),
377 objState_(objectState::GOOD),
378 sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
379 sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
392 <<
" invalid path specification" 399 <<
"Constructing IOobject: " << name_ <<
endl;
407 const objectRegistry& registry
410 IOobjectOption(static_cast<IOobjectOption>(
io)),
411 objState_(
io.objState_),
412 sizeofLabel_(
io.sizeofLabel_),
413 sizeofScalar_(
io.sizeofScalar_),
416 headerClassName_(
io.headerClassName_),
418 instance_(
io.instance_),
432 objState_(
io.objState_),
433 sizeofLabel_(
io.sizeofLabel_),
434 sizeofScalar_(
io.sizeofScalar_),
437 headerClassName_(
io.headerClassName_),
439 instance_(
io.instance_),
462 return time().rootPath();
468 return time().caseName();
477 const auto first = instance().find(
'/');
483 || (first == 2 && instance()[1] ==
':')
491 return rootPath()/caseName()/instance()/db_.dbDir()/
local();
497 const word& instance,
498 const fileName&
local 502 return rootPath()/caseName()/instance/db_.dbDir()/
local;
511 const auto first = instance().find(
'/');
517 || (first == 2 && instance()[1] ==
':')
522 return instance()/
name();
525 return instance()/db_.dbDir()/
local()/
name();
531 const word& typeName,
542 const word& typeName,
553 if (objState_ != objectState::GOOD)
556 <<
"Recurrent failure for object " <<
s 563 <<
"Broken object " <<
s << info() <<
endl;
566 objState_ = objectState::BAD;
579 objState_ =
io.objState_;
580 sizeofLabel_ =
io.sizeofLabel_;
581 sizeofScalar_ =
io.sizeofScalar_;
584 headerClassName_ =
io.headerClassName_;
586 instance_ =
io.instance_;
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Abstract base class for registered object with I/O. Used in debug symbol registration.
EnumType read(Istream &is) const
Read a word from Istream and return the corresponding enumeration.
static bool fileNameComponents(const fileName &path, fileName &instance, fileName &local, word &name)
Split path into instance, local, name components.
A class for handling file names.
readOption readOpt() const noexcept
Get the read option.
errorManipArg< error, int > exit(error &err, const int errNo=1)
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
static float fileModificationSkew
Time skew (seconds) for file modification checks.
static void writeData(Ostream &os, const Type &val)
void operator=(const IOobject &io)
Copy assignment, copies all values (except the registry)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word & name() const noexcept
Return the object name.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Ostream & endl(Ostream &os)
Add newline and flush stream.
word member() const
Return member (name without the extension)
autoPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler.
void setBad(const string &s)
Set the object state to bad.
word group() const
Return group (extension part of name)
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
fileName path() const
The complete path.
registerOptSwitch("fileModificationSkew", float, Foam::IOobject::fileModificationSkew)
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
bool globalObject() const noexcept
True if object is treated the same for all processors.
writeOption writeOpt() const noexcept
Get the write option.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
const Time & time() const noexcept
Return time registry.
fileCheckTypes
Enumeration defining the file checking options.
static int maxFileModificationPolls
Max number of times to poll for file modification changes.
const objectRegistry & db() const noexcept
Return the local objectRegistry.
static const word null
An empty word.
fileName localFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching locally.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
int debug
Static debugging option.
static const Enum< fileCheckTypes > fileCheckTypesNames
Names for the fileCheckTypes.
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
defineTypeNameAndDebug(combustionModel, 0)
static bool clean(std::string &str)
Cleanup filename string, possibly applies other transformations such as changing the path separator e...
static fileCheckTypes fileModificationChecking
Type of file modification checking.
const fileName & instance() const noexcept
Read access to instance path component.
static char scopeSeparator
Character for scoping object names (':' or '_')
const fileName & rootPath() const
Return the Time::rootPath()
bool starts_with(char c) const
True if string starts with given character (cf. C++20)
float floatOptimisationSwitch(const char *name, const float deflt=0)
Lookup optimisation switch or add default value.
#define WarningInFunction
Report a warning using Foam::Warning.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
string & expand(const bool allowEmpty=false)
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::e...
const Time & time() const
Return Time associated with the objectRegistry.
IOobject(const IOobject &)=default
Copy construct.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
fileName cwd()
The physical or logical current working directory path name.
fileName objectRelPath() const
The object path relative to the root.
bool registerObject() const noexcept
Should objects created with this IOobject be registered?
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict(s).
Registry of regIOobjects.
void addOptimisationObject(const char *name, simpleRegIOobject *obj)
Register optimisation switch read/write object.
const fileName & local() const noexcept
Read access to local path component.
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;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Defines the attributes of an object for which implicit objectRegistry management is supported...
const fileName & caseName() const
Return the Time::caseName()
static int level
The output level (verbosity) of messages.
static IOobject selectIO(const IOobject &io, const fileName &altFile, const word &ioName="")
Return the IOobject, but also consider an alternative file name.
#define InfoInFunction
Report an information message using Foam::Info.