diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.H b/src/OpenFOAM/db/IOobjectList/IOobjectList.H index 2c993f1fb0d9dd5dbc92b3dc7f1e76d983d90e77..d5e14a637d4b9d5c6ad54b72e9c4e9086de076b5 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<IOobject>&& objectPtr); + //- Move insert IOobject into the list inline bool add(autoPtr<IOobject>& objectPtr); diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectListI.H b/src/OpenFOAM/db/IOobjectList/IOobjectListI.H index 9408e7b53a3a290e94e1ee17c19d28597044971d..24044638ecd30480e4e3da80f1d51a67e1e54487 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<IOobject>&& objectPtr) +{ + if (objectPtr) + { + return insert(objectPtr->name(), std::move(objectPtr)); + } + + return false; +} + + inline bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr) { if (objectPtr) diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index 9cce9137e7d714619578bc8fb73221d4c90ef8b9..6dad7249ca71f7be7efbf3a4cbebe604594b2ba2 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<class Type> inline static Type& store(Type* p); + //- Transfer pointer ownership to its registry. + // Resets (clears) the parameter. + // \return reference to the stored object + template<class Type> + inline static Type& store(std::unique_ptr<Type>&& 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 1b4c632e87304d7426e7d70a4aa035e62ce11490..1f04bd68f0ce54fac79de743f114d4de8eb8cf85 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<class Type> +inline Type& Foam::regIOobject::store(std::unique_ptr<Type>&& ptr) +{ + // Pass management to objectRegistry + return store(ptr.release()); +} + + template<class Type> inline Type& Foam::regIOobject::store(autoPtr<Type>& ptr) { @@ -182,6 +190,7 @@ inline Type& Foam::regIOobject::store(tmp<Type>&& 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 8addedf1d5b5700dc945b3ea539a5f0e07b95f0b..54f6ea8203484b103a50629cbf160d3cf1454258 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 0b8c5aba87205ee49193dac8732c86b9f9d3cc4d..89c6674f9ff68e4926f0cd2d106d903a4b1cc344 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 d2b6a3656f696b462d556d3df5ec125e255e1afc..6278d0870290d60d050ab94496a894ad28cc8616 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 8591ee1d3d72f4242bb8bee9c2569dde95d608d3..13828bfa9aa2e48771e5b723023321fe6051d4a0 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)) {