diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index a1650b7ee3..7b9f07486b 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -95,6 +95,7 @@ $(strings)/fileName/fileNameIO.C
$(strings)/keyType/keyType.C
$(strings)/wordRe/wordRe.C
$(strings)/lists/hashedWordList.C
+$(strings)/lists/wordReListMatcher.C
$(strings)/stringOps/stringOps.C
ops = primitives/ops
diff --git a/src/OpenFOAM/primitives/strings/lists/wordReListMatcher.C b/src/OpenFOAM/primitives/strings/lists/wordReListMatcher.C
new file mode 100644
index 0000000000..1a24dcbbb1
--- /dev/null
+++ b/src/OpenFOAM/primitives/strings/lists/wordReListMatcher.C
@@ -0,0 +1,56 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
+ \\/ 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 .
+
+\*---------------------------------------------------------------------------*/
+
+#include "wordReListMatcher.H"
+#include "HashSet.H"
+
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+Foam::wordReList Foam::wordReListMatcher::uniq(const UList& input)
+{
+ wordReList retain(input.size());
+ wordHashSet uniqWord;
+
+ label nUniq = 0;
+ forAll(input, i)
+ {
+ const wordRe& select = input[i];
+
+ if
+ (
+ select.isPattern()
+ || uniqWord.insert(static_cast(select))
+ )
+ {
+ retain[nUniq++] = select;
+ }
+ }
+
+ retain.setSize(nUniq);
+ return retain;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/strings/lists/wordReListMatcher.H b/src/OpenFOAM/primitives/strings/lists/wordReListMatcher.H
index ebdd948119..2bba686964 100644
--- a/src/OpenFOAM/primitives/strings/lists/wordReListMatcher.H
+++ b/src/OpenFOAM/primitives/strings/lists/wordReListMatcher.H
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
- \\/ M anipulation |
+ \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -77,13 +77,20 @@ public:
inline const UList& operator()() const;
- // Searching
+ // Searching
//- Return true if string matches any of the regular expressions
// Smart match as regular expression or as a string.
// Optionally specify a literal match only.
inline bool match(const string&, bool literalMatch=false) const;
+
+ // Helpers
+
+ //- Return a wordReList with duplicate words filtered out.
+ // No filtering is done on regular expressions.
+ static wordReList uniq(const UList& input);
+
};
diff --git a/src/functionObjects/field/ddt2/ddt2.C b/src/functionObjects/field/ddt2/ddt2.C
index 12d6d2b67a..a387671658 100644
--- a/src/functionObjects/field/ddt2/ddt2.C
+++ b/src/functionObjects/field/ddt2/ddt2.C
@@ -27,6 +27,7 @@ License
#include "volFields.H"
#include "dictionary.H"
+#include "wordReListMatcher.H"
#include "steadyStateDdtScheme.H"
#include "addToRunTimeSelectionTable.H"
@@ -77,25 +78,6 @@ bool Foam::functionObjects::ddt2::checkFormatName(const word& str)
}
-void Foam::functionObjects::ddt2::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(select))
- );
- }
-
- inplaceSubset(retain, lst);
-}
-
-
bool Foam::functionObjects::ddt2::accept(const word& fieldName) const
{
// check input vs possible result names
@@ -160,10 +142,11 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict)
return false;
}
- fvMeshFunctionObject::read(dict);
-
- dict.lookup("fields") >> selectFields_;
- uniqWords(selectFields_);
+ selectFields_ = wordReListMatcher::uniq
+ (
+ wordReList(dict.lookup("fields"))
+ );
+ Info<< type() << " fields: " << selectFields_ << nl;
resultName_ = dict.lookupOrDefault
(
diff --git a/src/functionObjects/field/ddt2/ddt2.H b/src/functionObjects/field/ddt2/ddt2.H
index 4cf62c3add..21607ce2a3 100644
--- a/src/functionObjects/field/ddt2/ddt2.H
+++ b/src/functionObjects/field/ddt2/ddt2.H
@@ -124,9 +124,6 @@ class ddt2
//- 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 name appears to have already been processed
bool accept(const word& fieldName) const;
diff --git a/src/functionObjects/field/zeroGradient/zeroGradient.C b/src/functionObjects/field/zeroGradient/zeroGradient.C
index 9f7a2c257e..ff07607652 100644
--- a/src/functionObjects/field/zeroGradient/zeroGradient.C
+++ b/src/functionObjects/field/zeroGradient/zeroGradient.C
@@ -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(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("result", type() + "(@@)");
return checkFormatName(resultName_);
diff --git a/src/functionObjects/field/zeroGradient/zeroGradient.H b/src/functionObjects/field/zeroGradient/zeroGradient.H
index 2651761a57..8424360824 100644
--- a/src/functionObjects/field/zeroGradient/zeroGradient.H
+++ b/src/functionObjects/field/zeroGradient/zeroGradient.H
@@ -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).