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

@ -28,10 +28,12 @@ InClass
\*---------------------------------------------------------------------------*/
#ifndef writeFluentFields_H
#define writeFluentFields_H
#ifndef Foam_writeFluentFields_H
#define Foam_writeFluentFields_H
#include "volFields.H"
#include "dictionary.H"
#include "IOobjectList.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -43,16 +45,48 @@ void writeFluentField
(
const volScalarField& phi,
const label fluentFieldIdentifier,
Ostream& stream
Ostream& os
);
void writeFluentField
(
const volVectorField& phi,
const label fluentFieldIdentifier,
Ostream& stream
Ostream& os
);
template<class GeoField>
void readFieldsAndWriteFluent
(
const dictionary& dict,
const IOobjectList& objects,
const fvMesh& mesh,
Ostream& os
)
{
for (const IOobject& io : objects.csorted<GeoField>())
{
// Lookup field from dictionary and convert field
const word& fieldName = io.name();
label unitNumber;
if
(
dict.readIfPresent(fieldName, unitNumber)
&& unitNumber > 0
)
{
// Read field
GeoField field(io, mesh);
Info<< " Converting field " << fieldName << nl;
writeFluentField(field, unitNumber, os);
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam