diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.H b/src/OpenFOAM/db/IOobjectList/IOobjectList.H index 2c993f1fb0..d5e14a637d 100644 --- a/src/OpenFOAM/db/IOobjectList/IOobjectList.H +++ b/src/OpenFOAM/db/IOobjectList/IOobjectList.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2023 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -228,6 +228,9 @@ public: // Basic methods + //- Move insert IOobject into the list + inline bool add(std::unique_ptr&& objectPtr); + //- Move insert IOobject into the list inline bool add(autoPtr& objectPtr); diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectListI.H b/src/OpenFOAM/db/IOobjectList/IOobjectListI.H index 9408e7b53a..24044638ec 100644 --- a/src/OpenFOAM/db/IOobjectList/IOobjectListI.H +++ b/src/OpenFOAM/db/IOobjectList/IOobjectListI.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022-2023 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -109,6 +109,17 @@ inline Foam::IOobjectList::IOobjectList // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +inline bool Foam::IOobjectList::add(std::unique_ptr&& objectPtr) +{ + if (objectPtr) + { + return insert(objectPtr->name(), std::move(objectPtr)); + } + + return false; +} + + inline bool Foam::IOobjectList::add(autoPtr& objectPtr) { if (objectPtr) diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index 9cce9137e7..6dad7249ca 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.H +++ b/src/OpenFOAM/db/regIOobject/regIOobject.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -195,6 +195,12 @@ public: template inline static Type& store(Type* p); + //- Transfer pointer ownership to its registry. + // Resets (clears) the parameter. + // \return reference to the stored object + template + inline static Type& store(std::unique_ptr&& ptr); + //- Transfer pointer ownership to its registry. // Resets (clears) the parameter. // \return reference to the stored object diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectI.H b/src/OpenFOAM/db/regIOobject/regIOobjectI.H index 1b4c632e87..1f04bd68f0 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectI.H +++ b/src/OpenFOAM/db/regIOobject/regIOobjectI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -80,6 +80,14 @@ inline Type& Foam::regIOobject::store(Type* p) } +template +inline Type& Foam::regIOobject::store(std::unique_ptr&& ptr) +{ + // Pass management to objectRegistry + return store(ptr.release()); +} + + template inline Type& Foam::regIOobject::store(autoPtr& ptr) { @@ -182,6 +190,7 @@ inline Type& Foam::regIOobject::store(tmp&& ptr) inline void Foam::regIOobject::release(const bool unregister) noexcept { + // Note: could also return the old ownedByRegistry_ value ownedByRegistry_ = false; if (unregister) { diff --git a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C index 8addedf1d5..54f6ea8203 100644 --- a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C +++ b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C @@ -1413,7 +1413,7 @@ Foam::fileName Foam::fileOperation::processorsCasePath const word& procsDir ) const { - return io.rootPath()/io.time().globalCaseName()/procsDir; + return io.rootPath()/io.globalCaseName()/procsDir; } diff --git a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C index 0b8c5aba87..89c6674f9f 100644 --- a/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/masterUncollatedFileOperation/masterUncollatedFileOperation.C @@ -198,8 +198,10 @@ Foam::fileOperations::masterUncollatedFileOperation::filePathInfo ) { fileName parentPath = - io.rootPath()/io.time().globalCaseName() - /io.instance()/io.db().dbDir()/io.local()/io.name(); + ( + io.rootPath()/io.globalCaseName() + /io.instance()/io.db().dbDir()/io.local()/io.name() + ); if (isFileOrDir(isFile, parentPath)) { @@ -356,7 +358,7 @@ Foam::fileOperations::masterUncollatedFileOperation::localObjectPath case fileOperation::PARENTOBJECT: { return - io.rootPath()/io.time().globalCaseName() + io.rootPath()/io.globalCaseName() /io.instance()/io.db().dbDir()/io.local()/io.name(); } break; diff --git a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C index d2b6a3656f..6278d08702 100644 --- a/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C +++ b/src/OpenFOAM/global/fileOperations/uncollatedFileOperation/uncollatedFileOperation.C @@ -108,13 +108,15 @@ Foam::fileName Foam::fileOperations::uncollatedFileOperation::filePathInfo { // Constant & system can come from global case - fileName parentObjectPath = - io.rootPath()/io.time().globalCaseName() - /io.instance()/io.db().dbDir()/io.local()/io.name(); + fileName parentPath = + ( + io.rootPath()/io.globalCaseName() + /io.instance()/io.db().dbDir()/io.local()/io.name() + ); - if (isFileOrDir(isFile, parentObjectPath)) + if (isFileOrDir(isFile, parentPath)) { - return parentObjectPath; + return parentPath; } } diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 8591ee1d3d..13828bfa9a 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -250,8 +250,10 @@ Foam::word Foam::distributedTriSurfaceMesh::findLocalInstance // Search in parent directory fileName parentDir = - io.rootPath()/io.time().globalCaseName() - /io.instance()/io.db().dbDir()/io.local()/io.name(); + ( + io.rootPath()/io.globalCaseName() + /io.instance()/io.db().dbDir()/io.local()/io.name() + ); if (fileHandler().isDir(parentDir)) { @@ -280,9 +282,11 @@ Foam::word Foam::distributedTriSurfaceMesh::findLocalInstance continue; } - fileName parentDir = - io.rootPath()/io.time().globalCaseName() - /ts[instanceI].name()/io.db().dbDir()/io.local()/io.name(); + parentDir = + ( + io.rootPath()/io.globalCaseName() + /ts[instanceI].name()/io.db().dbDir()/io.local()/io.name() + ); if (fileHandler().isDir(parentDir)) { @@ -301,9 +305,11 @@ Foam::word Foam::distributedTriSurfaceMesh::findLocalInstance // constant function of the time, because the latter points to // the case constant directory in parallel cases - fileName parentDir = - io.rootPath()/io.time().globalCaseName() - /io.time().constant()/io.db().dbDir()/io.local()/io.name(); + parentDir = + ( + io.rootPath()/io.globalCaseName() + /io.time().constant()/io.db().dbDir()/io.local()/io.name() + ); if (fileHandler().isDir(parentDir)) {