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

@ -756,7 +756,10 @@ void Foam::functionObjects::forces::calcForcesMoments()
const volScalarField rho(this->rho());
const volScalarField mu(this->mu());
const auto models = obr_.lookupClass<porosityModel>();
const UPtrList<const porosityModel> models
(
obr_.csorted<porosityModel>()
);
if (models.empty())
{
@ -766,10 +769,10 @@ void Foam::functionObjects::forces::calcForcesMoments()
<< endl;
}
forAllConstIters(models, iter)
for (const porosityModel& mdl : models)
{
// Non-const access required if mesh is changing
auto& pm = const_cast<porosityModel&>(*iter());
auto& pm = const_cast<porosityModel&>(mdl);
const vectorField fPTot(pm.force(U, rho, mu));

View File

@ -220,7 +220,7 @@ const Foam::volVectorField& Foam::functionObjects::propellerInfo::U() const
FatalErrorInFunction
<< "Unable to find velocity field " << UName_
<< " . Available vector fields are: "
<< mesh_.names<volVectorField>()
<< flatOutput(mesh_.sortedNames<volVectorField>())
<< exit(FatalError);
}