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)
304 return name.substr(0, i);
310 Foam::IOobject::IOobject(
const objectRegistry& registry, IOobjectOption ioOpt)
312 IOobjectOption(ioOpt),
313 objState_(objectState::GOOD),
314 sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
315 sizeofScalar_(static_cast<unsigned char>(sizeof(scalar))),
320 Foam::IOobject::IOobject
336 <<
"Constructing IOobject: " << name_ <<
endl;
341 Foam::IOobject::IOobject
344 const fileName& instance,
345 const fileName&
local,
346 const objectRegistry& registry,
350 IOobject(registry, ioOpt)
359 <<
"Constructing IOobject: " << name_ <<
endl;
364 Foam::IOobject::IOobject
366 const fileName&
path,
367 const objectRegistry& registry,
371 IOobject(registry, ioOpt)
376 <<
" invalid path specification" 383 <<
"Constructing IOobject: " << name_ <<
endl;
388 Foam::IOobject::IOobject
391 const objectRegistry& registry
394 IOobjectOption(static_cast<IOobjectOption>(
io)),
395 objState_(
io.objState_),
396 sizeofLabel_(
io.sizeofLabel_),
397 sizeofScalar_(
io.sizeofScalar_),
400 headerClassName_(
io.headerClassName_),
402 instance_(
io.instance_),
409 Foam::IOobject::IOobject
416 objState_(
io.objState_),
417 sizeofLabel_(
io.sizeofLabel_),
418 sizeofScalar_(
io.sizeofScalar_),
421 headerClassName_(
io.headerClassName_),
423 instance_(
io.instance_),
446 return time().rootPath();
452 return time().caseName();
461 const auto first = instance().find(
'/');
467 || (first == 2 && instance()[1] ==
':')
475 return rootPath()/caseName()/instance()/db_.dbDir()/
local();
481 const word& instance,
482 const fileName&
local 486 return rootPath()/caseName()/instance/db_.dbDir()/
local;
495 const auto first = instance().find(
'/');
501 || (first == 2 && instance()[1] ==
':')
506 return instance()/
name();
509 return instance()/db_.dbDir()/
local()/
name();
515 const word& typeName,
526 const word& typeName,
537 if (objState_ != objectState::GOOD)
540 <<
"Recurrent failure for object " <<
s 547 <<
"Broken object " <<
s << info() <<
endl;
550 objState_ = objectState::BAD;
556 if (!newName.empty())
560 objState_ = objectState::GOOD;
561 sizeofLabel_ =
static_cast<unsigned char>(
sizeof(label));
562 sizeofScalar_ =
static_cast<unsigned char>(
sizeof(scalar));
563 headerClassName_.clear();
577 objState_ =
io.objState_;
578 sizeofLabel_ =
io.sizeofLabel_;
579 sizeofScalar_ =
io.sizeofScalar_;
582 headerClassName_ =
io.headerClassName_;
584 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.
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for 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.
fileName localFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching locally.
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 '_')
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...
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).
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...
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.