mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use DynamicList for handling stored objects (ReadFields)
- DynamicList can be used as a LIFO with fewer allocations than a linked-list would have. - support generic name matcher for readFields()
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,16 +49,6 @@ using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define ReadFields(GeoFieldType) \
|
||||
readFields<GeoFieldType>(mesh, objects, selectedFields, storedObjects);
|
||||
|
||||
#define ReadPointFields(GeoFieldType) \
|
||||
readFields<GeoFieldType>(pMesh, objects, selectedFields, storedObjects);
|
||||
|
||||
#define ReadUniformFields(FieldType) \
|
||||
readUniformFields<FieldType> \
|
||||
(constantObjects, selectedFields, storedObjects);
|
||||
|
||||
void executeFunctionObjects
|
||||
(
|
||||
const argList& args,
|
||||
@ -71,13 +61,24 @@ void executeFunctionObjects
|
||||
{
|
||||
Info<< nl << "Reading fields:" << endl;
|
||||
|
||||
// Maintain a stack of the stored objects to clear after executing
|
||||
// the functionObjects
|
||||
LIFOStack<regIOobject*> storedObjects;
|
||||
// Read objects in constant directory
|
||||
IOobjectList constObjects(mesh, runTime.constant());
|
||||
|
||||
// Read objects in time directory
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
// List of stored objects to clear after executing functionObjects
|
||||
DynamicList<regIOobject*> storedObjects
|
||||
(
|
||||
objects.size() + constObjects.size()
|
||||
);
|
||||
|
||||
// Read GeometricFields
|
||||
|
||||
#undef ReadFields
|
||||
#define ReadFields(FieldType) \
|
||||
readFields<FieldType>(mesh, objects, selectedFields, storedObjects);
|
||||
|
||||
// Read volFields
|
||||
ReadFields(volScalarField);
|
||||
ReadFields(volVectorField);
|
||||
@ -99,8 +100,12 @@ void executeFunctionObjects
|
||||
ReadFields(surfaceSymmTensorField);
|
||||
ReadFields(surfaceTensorField);
|
||||
|
||||
|
||||
// Read point fields.
|
||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||
#undef ReadPointFields
|
||||
#define ReadPointFields(FieldType) \
|
||||
readFields<FieldType>(pMesh, objects, selectedFields, storedObjects);
|
||||
|
||||
ReadPointFields(pointScalarField)
|
||||
ReadPointFields(pointVectorField);
|
||||
@ -108,8 +113,12 @@ void executeFunctionObjects
|
||||
ReadPointFields(pointSymmTensorField);
|
||||
ReadPointFields(pointTensorField);
|
||||
|
||||
|
||||
// Read uniform dimensioned fields
|
||||
IOobjectList constantObjects(mesh, runTime.constant());
|
||||
|
||||
#undef ReadUniformFields
|
||||
#define ReadUniformFields(FieldType) \
|
||||
readUniformFields<FieldType>(constObjects, selectedFields, storedObjects);
|
||||
|
||||
ReadUniformFields(uniformDimensionedScalarField);
|
||||
ReadUniformFields(uniformDimensionedVectorField);
|
||||
@ -130,7 +139,8 @@ void executeFunctionObjects
|
||||
|
||||
while (!storedObjects.empty())
|
||||
{
|
||||
storedObjects.pop()->checkOut();
|
||||
storedObjects.back()->checkOut();
|
||||
storedObjects.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user