mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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())
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user