ENH: change wordRes to be a List of wordRe instead of a wrapper (issue #259)

- this permits direct storage of a list with additional matcher
  capabilities

- provide wordRes::matcher class for similar behaviour as previously
This commit is contained in:
Mark Olesen
2018-02-21 10:05:30 +01:00
parent 03b287ed24
commit c126464d1c
113 changed files with 572 additions and 801 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -70,10 +70,8 @@ bool Foam::functionObjects::zeroGradient::checkFormatName(const word& str)
return false;
}
else
{
return true;
}
return true;
}
@ -108,22 +106,15 @@ Foam::functionObjects::zeroGradient::zeroGradient
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::zeroGradient::~zeroGradient()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::zeroGradient::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
selectFields_ = wordRes::uniq
(
wordReList(dict.lookup("fields"))
);
dict.lookup("fields") >> selectFields_;
selectFields_.uniq();
Info<< type() << " fields: " << selectFields_ << nl;
resultName_ = dict.lookupOrDefault<word>("result", type() + "(@@)");
@ -139,10 +130,9 @@ bool Foam::functionObjects::zeroGradient::execute()
DynamicList<word> missing(selectFields_.size());
DynamicList<word> ignored(selectFields_.size());
// check exact matches first
forAll(selectFields_, i)
// Check exact matches first
for (const wordRe& select : selectFields_)
{
const wordRe& select = selectFields_[i];
if (!select.isPattern())
{
const word& fieldName = static_cast<const word&>(select);
@ -158,9 +148,9 @@ bool Foam::functionObjects::zeroGradient::execute()
}
}
forAllConstIter(wordHashSet, candidates, iter)
for (const word& fieldName : candidates)
{
process(iter.key());
process(fieldName);
}
if (missing.size())
@ -187,10 +177,8 @@ bool Foam::functionObjects::zeroGradient::write()
// Consistent output order
const wordList outputList = results_.sortedToc();
forAll(outputList, i)
for (const word& fieldName : outputList)
{
const word& fieldName = outputList[i];
if (foundObject<regIOobject>(fieldName))
{
const regIOobject& io = lookupObject<regIOobject>(fieldName);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,7 +76,7 @@ SourceFiles
#include "fvMeshFunctionObject.H"
#include "volFieldsFwd.H"
#include "OFstream.H"
#include "wordReList.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -96,7 +96,7 @@ class zeroGradient
// Private data
//- Name of fields to process
wordReList selectFields_;
wordRes selectFields_;
//- Formatting for the result fields.
word resultName_;
@ -108,7 +108,7 @@ class zeroGradient
// Private Member Functions
//- Check that the word contains the appropriate substitution token(s).
static bool checkFormatName(const word&);
static bool checkFormatName(const word& str);
//- Accept unless field only has constraint patches
@ -151,7 +151,7 @@ public:
//- Destructor
virtual ~zeroGradient();
virtual ~zeroGradient() = default;
// Member Functions