mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: avoid unneeded IOobjectList scan in sampledSurfaces
STYLE: replace findStrings with ListOps::found
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,6 +32,7 @@ License
|
||||
#include "mapPolyMesh.H"
|
||||
#include "areaFields.H"
|
||||
#include "HashOps.H"
|
||||
#include "ListOps.H"
|
||||
#include "Time.H"
|
||||
#include "UIndirectList.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
@ -273,7 +274,7 @@ bool Foam::areaWrite::write()
|
||||
// Detect missing fields
|
||||
forAll(fieldSelection_, i)
|
||||
{
|
||||
if (findStrings(fieldSelection_[i], allFields).empty())
|
||||
if (!ListOps::found(allFields, fieldSelection_[i]))
|
||||
{
|
||||
missed.append(i);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -95,15 +95,17 @@ bool Foam::sampledSurfaces::removeRegistrySurface
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::countFields()
|
||||
Foam::IOobjectList Foam::sampledSurfaces::preCheckFields()
|
||||
{
|
||||
wordList allFields; // Just needed for warnings
|
||||
HashTable<wordHashSet> selected;
|
||||
|
||||
IOobjectList objects(0);
|
||||
|
||||
if (loadFromFiles_)
|
||||
{
|
||||
// Check files for a particular time
|
||||
IOobjectList objects(obr_, obr_.time().timeName());
|
||||
objects = IOobjectList(obr_, obr_.time().timeName());
|
||||
|
||||
allFields = objects.names();
|
||||
selected = objects.classes(fieldSelection_);
|
||||
@ -127,7 +129,7 @@ void Foam::sampledSurfaces::countFields()
|
||||
// Detect missing fields
|
||||
forAll(fieldSelection_, i)
|
||||
{
|
||||
if (findStrings(fieldSelection_[i], allFields).empty())
|
||||
if (!ListOps::found(allFields, fieldSelection_[i]))
|
||||
{
|
||||
missed.append(i);
|
||||
}
|
||||
@ -183,6 +185,8 @@ void Foam::sampledSurfaces::countFields()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
|
||||
@ -543,10 +547,11 @@ bool Foam::sampledSurfaces::performAction(unsigned request)
|
||||
}
|
||||
|
||||
|
||||
// Determine the per-surface number of fields, including Ids etc.
|
||||
// Only seems to be needed for VTK legacy
|
||||
countFields();
|
||||
// Determine availability of fields.
|
||||
// Count per-surface number of fields, including Ids etc
|
||||
// which only seems to be needed for VTK legacy
|
||||
|
||||
IOobjectList objects = preCheckFields();
|
||||
|
||||
// Update writers
|
||||
|
||||
@ -596,8 +601,6 @@ bool Foam::sampledSurfaces::performAction(unsigned request)
|
||||
|
||||
// Sample fields
|
||||
|
||||
const IOobjectList objects(obr_, obr_.time().timeName());
|
||||
|
||||
performAction<volScalarField>(objects, request);
|
||||
performAction<volVectorField>(objects, request);
|
||||
performAction<volSphericalTensorField>(objects, request);
|
||||
|
||||
@ -233,7 +233,8 @@ class sampledSurfaces
|
||||
bool performAction(unsigned request);
|
||||
|
||||
//- Count selected/sampled fields per surface
|
||||
void countFields();
|
||||
// Returns empty IOobjectList if loadFromFiles_ is not active
|
||||
IOobjectList preCheckFields();
|
||||
|
||||
//- Write sampled fieldName on surface and on outputDir path
|
||||
template<class Type>
|
||||
@ -261,6 +262,7 @@ class sampledSurfaces
|
||||
);
|
||||
|
||||
//- Sample and write all applicable sampled fields
|
||||
// Only uses IOobjectList when loadFromFiles_ is active
|
||||
template<class GeoField>
|
||||
void performAction
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user