mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: provide static uniq method in wordReListMatcher (issue #259)
- this functionality will be more frequently used in the future, thus place in a commonly available location.
This commit is contained in:
@ -27,6 +27,7 @@ License
|
||||
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "wordReListMatcher.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -76,25 +77,6 @@ bool Foam::functionObjects::zeroGradient::checkFormatName(const word& str)
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::zeroGradient::uniqWords(wordReList& lst)
|
||||
{
|
||||
boolList retain(lst.size());
|
||||
wordHashSet uniq;
|
||||
forAll(lst, i)
|
||||
{
|
||||
const wordRe& select = lst[i];
|
||||
|
||||
retain[i] =
|
||||
(
|
||||
select.isPattern()
|
||||
|| uniq.insert(static_cast<const word&>(select))
|
||||
);
|
||||
}
|
||||
|
||||
inplaceSubset(retain, lst);
|
||||
}
|
||||
|
||||
|
||||
int Foam::functionObjects::zeroGradient::process(const word& fieldName)
|
||||
{
|
||||
int state = 0;
|
||||
@ -138,8 +120,11 @@ bool Foam::functionObjects::zeroGradient::read(const dictionary& dict)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> selectFields_;
|
||||
uniqWords(selectFields_);
|
||||
selectFields_ = wordReListMatcher::uniq
|
||||
(
|
||||
wordReList(dict.lookup("fields"))
|
||||
);
|
||||
Info<< type() << " fields: " << selectFields_ << nl;
|
||||
|
||||
resultName_ = dict.lookupOrDefault<word>("result", type() + "(@@)");
|
||||
return checkFormatName(resultName_);
|
||||
|
||||
@ -110,9 +110,6 @@ class zeroGradient
|
||||
//- Check that the word contains the appropriate substitution token(s).
|
||||
static bool checkFormatName(const word&);
|
||||
|
||||
//- Eliminate duplicate 'word' entries
|
||||
static void uniqWords(wordReList&);
|
||||
|
||||
|
||||
//- Accept unless field only has constraint patches
|
||||
// (ie, empty/zero-gradient/processor).
|
||||
|
||||
Reference in New Issue
Block a user