functionObjects: Added fields() function to provide list of required fields to postProcess

With this change each functionObject provides the list of fields required so
that the postProcess utility can pre-load them before executing the list of
functionObjects.  This provides a more convenient interface than using the
-field or -fields command-line options to postProcess which are now redundant.
This commit is contained in:
Henry Weller
2021-10-21 09:23:34 +01:00
parent 777e5aeece
commit c01118589f
110 changed files with 809 additions and 746 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,6 +74,12 @@ bool Foam::functionObjects::writeVTK::read(const dictionary& dict)
}
Foam::wordList Foam::functionObjects::writeVTK::fields() const
{
return objectNames_;
}
bool Foam::functionObjects::writeVTK::execute()
{
return true;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -64,7 +64,6 @@ SourceFiles
#define functionObjects_writeVTK_H
#include "fvMeshFunctionObject.H"
#include "wordReList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -84,7 +83,7 @@ class writeVTK
// Private Data
//- Names of objects
wordReList objectNames_;
wordList objectNames_;
// Private Member Functions
@ -122,6 +121,9 @@ public:
//- Read the writeVTK data
virtual bool read(const dictionary&);
//- Return the list of fields required
virtual wordList fields() const;
//- Execute, currently does nothing
virtual bool execute();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,22 +33,11 @@ template<class GeoField>
Foam::UPtrList<const GeoField>
Foam::functionObjects::writeVTK::lookupFields() const
{
DynamicList<word> allNames(obr_.toc().size());
UPtrList<const GeoField> fields(objectNames_.size());
forAll(objectNames_, i)
{
wordList names(obr_.names<GeoField>(objectNames_[i]));
if (names.size())
{
allNames.append(names);
}
}
UPtrList<const GeoField> fields(allNames.size());
forAll(allNames, i)
{
const GeoField& field = obr_.lookupObject<GeoField>(allNames[i]);
const GeoField& field = obr_.lookupObject<GeoField>(objectNames_[i]);
Info<< " Writing " << GeoField::typeName
<< " field " << field.name() << endl;
fields.set(i, &field);