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

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -28,9 +28,9 @@ forAll(meshes, regioni)
IOobjectList objects(0);
if (doConvertFields)
if (doConvertFields && !timeDirs.empty())
{
objects = IOobjectList(mesh, timeDirs.last().name());
objects = IOobjectList(mesh, timeDirs.back().name());
if (fieldSelector && !fieldSelector().empty())
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,18 +35,30 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef readFields_H
#define readFields_H
#ifndef ensight_readFields_H
#define ensight_readFields_H
#include "instantList.H"
#include "IOobjectList.H"
#include "zeroGradientFvPatchFields.H"
#include "fvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//- Get the field or FatalError
template<class GeoField>
tmp<GeoField> getField
(
const IOobject& io,
const typename GeoField::Mesh& mesh
)
{
return tmp<GeoField>::New(io, mesh);
}
//- Get the field or return nullptr
template<class GeoField>
tmp<GeoField> getField

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -72,7 +72,7 @@ label writeAreaFields
label count = 0;
for (const word& fieldName : objects.sortedNames<FieldType>())
for (const IOobject& io : objects.csorted<FieldType>())
{
if
(
@ -80,11 +80,11 @@ label writeAreaFields
(
ensCase,
ensMesh,
getField<FieldType>(objects.findObject(fieldName), mesh)
getField<FieldType>(io, mesh)
)
)
{
Info<< ' ' << fieldName;
Info<< ' ' << io.name();
++count;
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -69,7 +69,7 @@ label writeDimFields
label count = 0;
for (const word& fieldName : objects.sortedNames<FieldType>())
for (const IOobject& io : objects.csorted<FieldType>())
{
if
(
@ -77,11 +77,11 @@ label writeDimFields
(
ensCase,
ensMesh,
getField<FieldType>(objects.findObject(fieldName), mesh)
getField<FieldType>(io, mesh)
)
)
{
Info<< ' ' << fieldName;
Info<< ' ' << io.name();
++count;
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2022 OpenCFD Ltd.
Copyright (C) 2020-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -70,11 +70,11 @@ label writePointFields
{
typedef PointField<Type> FieldType;
const pointMesh& ptMesh = pointMesh::New(ensMesh.mesh());
const pointMesh& pMesh = pointMesh::New(ensMesh.mesh());
label count = 0;
for (const word& fieldName : objects.sortedNames<FieldType>())
for (const IOobject& io : objects.csorted<FieldType>())
{
if
(
@ -82,11 +82,11 @@ label writePointFields
(
ensCase,
ensMesh,
getField<FieldType>(ptMesh, objects, fieldName)
getField<FieldType>(io, pMesh)
)
)
{
Info<< ' ' << fieldName;
Info<< ' ' << io.name();
++count;
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -92,7 +92,7 @@ label writeVolFields
label count = 0;
for (const word& fieldName : objects.sortedNames<FieldType>())
for (const IOobject& io : objects.csorted<FieldType>())
{
if
(
@ -100,12 +100,12 @@ label writeVolFields
(
ensCase,
ensMesh,
getField<FieldType>(objects.findObject(fieldName), mesh),
getField<FieldType>(io, mesh),
nearCellValue
)
)
{
Info<< ' ' << fieldName;
Info<< ' ' << io.name();
++count;
}
}