ENH: use objectRegistry/IOobjectList sorted instead of lookupClass

- in most cases a parallel-consistent order is required.
  Even when the order is not important, it will generally require
  fewer allocations to create a UPtrList of entries instead of a
  HashTable or even a wordList.
This commit is contained in:
Mark Olesen
2023-07-17 18:27:55 +02:00
parent d65e2d89b5
commit db16d80840
70 changed files with 1300 additions and 1758 deletions

View File

@ -68,7 +68,7 @@ void Foam::fieldsDistributor::readFields
const UPtrList<const IOobject> fieldObjects(objects.csorted<GeoField>());
// Construct the fields
fields.resize(fieldObjects.size());
fields.resize_null(fieldObjects.size());
forAll(fieldObjects, i)
{
@ -89,7 +89,7 @@ void Foam::fieldsDistributor::readFields
const UPtrList<const IOobject> fieldObjects(objects.csorted<GeoField>());
// Construct the fields
fields.resize(fieldObjects.size());
fields.resize_null(fieldObjects.size());
forAll(fieldObjects, i)
{
@ -167,18 +167,16 @@ void Foam::fieldsDistributor::readFieldsImpl
if (deregister)
{
// Extra safety - remove all such types
HashTable<const GeoField*> other
const UPtrList<const GeoField> other
(
mesh.thisDb().objectRegistry::template lookupClass<GeoField>()
mesh.thisDb().objectRegistry::template cobjects<GeoField>()
);
forAllConstIters(other, iter)
for (const GeoField& field : other)
{
GeoField& fld = const_cast<GeoField&>(*iter.val());
if (!fld.ownedByRegistry())
if (!field.ownedByRegistry())
{
fld.checkOut();
const_cast<GeoField&>(field).checkOut();
}
}
}