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:
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user