diff --git a/src/OpenFOAM/parallel/fieldsDistributor/fieldsDistributorTemplates.C b/src/OpenFOAM/parallel/fieldsDistributor/fieldsDistributorTemplates.C index 01c0195b81c37b4cd50de61dda8b50f71508904e..1bd35abd3b8e9a8b21aae134b320ce3c73e33620 100644 --- a/src/OpenFOAM/parallel/fieldsDistributor/fieldsDistributorTemplates.C +++ b/src/OpenFOAM/parallel/fieldsDistributor/fieldsDistributorTemplates.C @@ -167,16 +167,15 @@ void Foam::fieldsDistributor::readFieldsImpl if (deregister) { // Extra safety - remove all such types - const UPtrList<const GeoField> other + for ( - mesh.thisDb().objectRegistry::template cobjects<GeoField>() - ); - - for (const GeoField& field : other) + const GeoField& fld + : mesh.thisDb().objectRegistry::template csorted<GeoField>() + ) { - if (!field.ownedByRegistry()) + if (!fld.ownedByRegistry()) { - const_cast<GeoField&>(field).checkOut(); + const_cast<GeoField&>(fld).checkOut(); } } } @@ -348,18 +347,15 @@ void Foam::fieldsDistributor::readFieldsImpl /// Info<< nl; // Extra safety - remove all such types - HashTable<const GeoField*> other + for ( - mesh.thisDb().objectRegistry::template lookupClass<GeoField>() - ); - - forAllConstIters(other, iter) + const GeoField& fld + : mesh.thisDb().objectRegistry::template csorted<GeoField>() + ) { - GeoField& fld = const_cast<GeoField&>(*iter.val()); - if (!fld.ownedByRegistry()) { - fld.checkOut(); + const_cast<GeoField&>(fld).checkOut(); } } } diff --git a/src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C b/src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C index e7cd13a97419fc930df042f7da16560049f8c459..ff5dbc9b3725954759600751edbe3927c3ca2d05 100644 --- a/src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C +++ b/src/dynamicMesh/polyMeshFilter/polyMeshFilterTemplates.C @@ -40,6 +40,10 @@ void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map) // Update all sets in memory // + // Note: objectRegistry::lookupClass() instead of + // objectRegistry::csorted() since it is also used to check + // contains() in the next bit of code + const HashTable<const SetType*> sets ( map.mesh().objectRegistry::lookupClass<const SetType>() diff --git a/src/dynamicMesh/setUpdater/setUpdaterTemplates.C b/src/dynamicMesh/setUpdater/setUpdaterTemplates.C index d1f7ade2b2cbf11657b0814f5b38f7c85335a829..f01feda9ad297a0cbb09185038cff96733f06fd3 100644 --- a/src/dynamicMesh/setUpdater/setUpdaterTemplates.C +++ b/src/dynamicMesh/setUpdater/setUpdaterTemplates.C @@ -41,6 +41,10 @@ void Foam::setUpdater::updateSets(const mapPolyMesh& map) // Update all sets in memory // + // Note: objectRegistry::lookupClass() instead of + // objectRegistry::csorted() since it is also used to check + // contains() in the next bit of code + const HashTable<const SetType*> sets ( map.mesh().objectRegistry::lookupClass<const SetType>() diff --git a/src/functionObjects/utilities/caseInfo/caseInfo.C b/src/functionObjects/utilities/caseInfo/caseInfo.C index b64f328cee159a9b9ef496de6455f2d2e6248890..caec64d93553f16368cb894102a2bdd924ab2e3a 100644 --- a/src/functionObjects/utilities/caseInfo/caseInfo.C +++ b/src/functionObjects/utilities/caseInfo/caseInfo.C @@ -5,20 +5,24 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. + OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + \*---------------------------------------------------------------------------*/ #include "caseInfo.H" @@ -333,16 +337,15 @@ void Foam::functionObjects::caseInfo::writeMeshStats namespace Foam { - template<class Type> + template<class GeoFieldType> void addPatchTypeDetails(const fvMesh& mesh, dictionary& dict) { - auto objects = mesh.lookupClass<Type>(); - for (const auto* objPtr : objects) + for (const GeoFieldType& obj : mesh.csorted<GeoFieldType>()) { - if (objPtr->readOpt() == IOobject::MUST_READ) + if (obj.readOpt() == IOobject::MUST_READ) { - const auto& bf = objPtr->boundaryField(); - dictionary& objDict = dict.subDictOrAdd(objPtr->name()); + const auto& bf = obj.boundaryField(); + dictionary& objDict = dict.subDictOrAdd(obj.name()); for (const auto& pf : bf) { @@ -459,14 +462,12 @@ bool Foam::functionObjects::caseInfo::write() writeFileDicts(dataDicts, dicts); // Per-region information - const auto meshes = time_.lookupClass<fvMesh>(); dictionary& regionDict = data.subDictOrAdd("regions"); - for (const auto& iter : meshes.csorted()) + + for (const fvMesh& mesh : time_.csorted<fvMesh>()) { dictionary meshDicts(dicts); - const fvMesh& mesh = *iter.val(); - const word& name = mesh.name(); dictionary& out = regionDict.subDictOrAdd(name); @@ -526,4 +527,4 @@ bool Foam::functionObjects::caseInfo::write() } -// ************************************************************************* // \ No newline at end of file +// ************************************************************************* //