diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.C b/src/OpenFOAM/db/objectRegistry/objectRegistry.C index 76b7bad5cb..b16e388629 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2019 OpenFOAM Foundation - Copyright (C) 2015-2023 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -151,6 +151,44 @@ Foam::HashTable Foam::objectRegistry::classes() const } +Foam::IOobject Foam::objectRegistry::newIOobject +( + const word& name, + IOobjectOption::readOption rOpt, + IOobjectOption::writeOption wOpt, + IOobjectOption::registerOption regOpt +) const +{ + return IOobject + ( + name, + time().timeName(), // instance + *this, + IOobjectOption(rOpt, wOpt, regOpt) + ); +} + + +// FUTURE? +// +// Foam::IOobject Foam::objectRegistry::newIOobject_constant +// ( +// const word& name, +// IOobjectOption::readOption rOpt, +// IOobjectOption::writeOption wOpt, +// IOobjectOption::registerOption regOpt +// ) const +// { +// return IOobject +// ( +// name, +// time().constant(), // instance +// *this, +// IOobjectOption(rOpt, wOpt, regOpt) +// ); +// } + + Foam::label Foam::objectRegistry::count(const char* clsName) const { // No nullptr check - only called with string literals diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.H b/src/OpenFOAM/db/objectRegistry/objectRegistry.H index 6110ab36ad..175d11a618 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.H +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2019 OpenFOAM Foundation - Copyright (C) 2016-2023 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -239,6 +239,23 @@ public: } + // Helper Functions + + //- Create an IOobject at the current time instance (timeName). + // By default the object is NO_READ/NO_WRITE/NO_REGISTER + IOobject newIOobject + ( + //! The object name + const word& name, + //! The read option (default: NO_READ) + IOobjectOption::readOption rOpt = IOobjectOption::NO_READ, + //! The write option (default: NO_WRITE) + IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE, + //! The register option (default: NO_REGISTER) + IOobjectOption::registerOption regOpt = IOobjectOption::NO_REGISTER + ) const; + + // Summary of classes //- A summary hash of classes used and their associated object names. diff --git a/src/functionObjects/field/streamLine/streamLineParticle.C b/src/functionObjects/field/streamLine/streamLineParticle.C index c18415d524..9b43342a44 100644 --- a/src/functionObjects/field/streamLine/streamLineParticle.C +++ b/src/functionObjects/field/streamLine/streamLineParticle.C @@ -394,14 +394,14 @@ void Foam::streamLineParticle::readFields(Cloud& c) IOField