ENH: prefer objectRegistry sorted to lookupClass
- lower memory overhead, consistent access pattern
This commit is contained in:
parent
a803516b16
commit
31aadc5c4d
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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>()
|
||||
|
@ -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>()
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user