functionObjectList: Improved flexibility of field argument parsing

Additional flexibility for handling of field arguments has been extended
to dictionary lists of field settings, as well as word lists of field
names. This means that the following syntax is now supported:

    postProcess -func "fieldAverage(p, U { prime2Mean on; }, T)"

    postProcess -func "fieldAverage(fields=(p U { prime2Mean on; } T))"
This commit is contained in:
Will Bainbridge
2020-04-08 08:37:59 +01:00
parent b6f91de72c
commit 81188fefaa
5 changed files with 239 additions and 42 deletions

View File

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "wordAndDictionary.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::wordAndDictionary::wordAndDictionary(Istream& is)
:
Tuple2<word, dictionary>()
{
is >> *this;
is.check("wordAndDictionary::wordAndDictionary(Istream& is)");
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::wordAndDictionary::~wordAndDictionary()
{}
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, wordAndDictionary& wd)
{
wd.first() = word(is);
wd.second().clear();
token t(is);
is.putBack(t);
if (t.isPunctuation() && t.pToken() == token::BEGIN_BLOCK)
{
dictionary d(is);
wd.second().transfer(d);
}
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const wordAndDictionary& wd)
{
os << wd.first();
if (!wd.second().empty())
{
os << token::SPACE << wd.second();
}
return os;
}
// ************************************************************************* //