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" 153 return !str.empty() &&
161 (str.length() > 2 && str[1] ==
':')
196 <<
" called with directory: " <<
path <<
endl;
201 const auto first =
path.find(
'/');
202 const auto last =
path.rfind(
'/');
205 auto nameLen =
path.size();
207 if (first == std::string::npos)
218 || (first == 2 &&
path[1] ==
':')
227 const std::string ending =
path.substr(last+1);
228 nameLen = ending.size();
240 local =
path.substr(first+1, last-first-1);
243 const std::string ending =
path.substr(last+1);
244 nameLen = ending.size();
249 if (!nameLen || nameLen !=
name.size())
252 <<
"has invalid word for name: \"" <<
name 253 <<
"\"\nwhile processing path: " <<
path <<
endl;
265 const fileName& altFile,
276 fileName altPath = altFile;
309 const auto i =
name.rfind(
'.');
311 if (i == std::string::npos || i == 0)
316 return name.substr(i+1);
322 const auto i =
name.rfind(
'.');
324 if (i == std::string::npos || i == 0)
329 return name.substr(0, i);
335 Foam::IOobject::IOobject(
const objectRegistry& registry, IOobjectOption ioOpt)
337 IOobjectOption(ioOpt),
338 objState_(objectState::GOOD),
339 sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
340 sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
345 Foam::IOobject::IOobject
361 <<
"Constructing IOobject: " << name_ <<
endl;
366 Foam::IOobject::IOobject
369 const fileName& instance,
370 const fileName&
local,
371 const objectRegistry& registry,
375 IOobject(registry, ioOpt)
384 <<
"Constructing IOobject: " << name_ <<
endl;
389 Foam::IOobject::IOobject
391 const fileName&
path,
392 const objectRegistry& registry,
396 IOobject(registry, ioOpt)
401 <<
" invalid path specification" 408 <<
"Constructing IOobject: " << name_ <<
endl;
413 Foam::IOobject::IOobject
416 const objectRegistry& registry
419 IOobjectOption(static_cast<IOobjectOption>(
io)),
420 objState_(
io.objState_),
421 sizeofLabel_(
io.sizeofLabel_),
422 sizeofScalar_(
io.sizeofScalar_),
425 headerClassName_(
io.headerClassName_),
427 instance_(
io.instance_),
434 Foam::IOobject::IOobject
441 objState_(
io.objState_),
442 sizeofLabel_(
io.sizeofLabel_),
443 sizeofScalar_(
io.sizeofScalar_),
446 headerClassName_(
io.headerClassName_),
448 instance_(
io.instance_),
471 return time().rootPath();
477 return time().caseName();
483 return time().globalCaseName();
494 return rootPath()/caseName()/instance()/db_.dbDir()/
local();
505 return rootPath()/globalCaseName()/instance()/db_.dbDir()/
local();
511 const word& instance,
512 const fileName&
local 516 return rootPath()/caseName()/instance/db_.dbDir()/
local;
522 const word& instance,
527 return rootPath()/globalCaseName()/instance/db_.dbDir()/
local;
535 return instance()/
name();
538 return instance()/db_.dbDir()/
local()/
name();
544 const word& typeName,
555 const word& typeName,
577 if (objState_ != objectState::GOOD)
580 <<
"Recurrent failure for object " <<
s 587 <<
"Broken object " <<
s << info() <<
endl;
590 objState_ = objectState::BAD;
596 if (!newName.empty())
600 objState_ = objectState::GOOD;
601 sizeofLabel_ =
static_cast<unsigned char>(
sizeof(label));
602 sizeofScalar_ =
static_cast<unsigned char>(
sizeof(scalar));
603 headerClassName_.clear();
617 objState_ =
io.objState_;
618 sizeofLabel_ =
io.sizeofLabel_;
619 sizeofScalar_ =
io.sizeofScalar_;
622 headerClassName_ =
io.headerClassName_;
624 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)
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::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 for the object (with instance, local,...).
registerOptSwitch("fileModificationSkew", float, Foam::IOobject::fileModificationSkew)
const fileName & caseName() const noexcept
Return the Time::caseName()
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.
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.
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 bool file_isOutsideCase(const std::string &str)
fileName localFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching locally.
const fileName & globalCaseName() const noexcept
Return the Time::globalCaseName()
const Time & time() const noexcept
Return Time associated with the objectRegistry.
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 '_')
bool starts_with(char c) const
True if string starts with given character (cf. C++20)
const fileName & rootPath() const noexcept
Return the Time::rootPath()
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...
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 globalPath() const
The complete global path for the object (with instance, local,...)
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).
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
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))
void resetHeader(const word &newName=word::null)
Clear various bits (headerClassName, note, sizeof...) that would be obtained when reading from a file...
Defines the attributes of an object for which implicit objectRegistry management is supported...
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.