mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: relocate inplaceUniq (wordReList) into wordRes
This commit is contained in:
@ -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-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,15 +36,12 @@ Foam::wordReList Foam::wordRes::uniq(const UList<wordRe>& input)
|
||||
label count = 0;
|
||||
forAll(input, i)
|
||||
{
|
||||
const wordRe& select = input[i];
|
||||
const auto& select = input[i];
|
||||
|
||||
if
|
||||
(
|
||||
select.isPattern()
|
||||
|| uniqWord.insert(static_cast<const word&>(select))
|
||||
)
|
||||
if (select.isPattern() || uniqWord.insert(select))
|
||||
{
|
||||
retain[count++] = select;
|
||||
retain[count] = select;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,4 +50,27 @@ Foam::wordReList Foam::wordRes::uniq(const UList<wordRe>& input)
|
||||
}
|
||||
|
||||
|
||||
void Foam::wordRes::inplaceUniq(wordReList& input)
|
||||
{
|
||||
wordHashSet uniqWord;
|
||||
|
||||
label count = 0;
|
||||
forAll(input, i)
|
||||
{
|
||||
const auto& select = input[i];
|
||||
|
||||
if (select.isPattern() || uniqWord.insert(select))
|
||||
{
|
||||
if (count != i)
|
||||
{
|
||||
input[count] = input[i];
|
||||
}
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
input.setSize(count);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -78,6 +78,10 @@ public:
|
||||
// No filtering is done on regular expressions.
|
||||
static wordReList uniq(const UList<wordRe>& input);
|
||||
|
||||
//- Inplace subset of wordReList with duplicate words filtered out.
|
||||
// No filtering is done on regular expressions.
|
||||
static void inplaceUniq(wordReList& input);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
|
||||
@ -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-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "ensightWrite.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "wordRes.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -47,25 +48,6 @@ namespace functionObjects
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::ensightWrite::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::ensightWrite::process(const word& fieldName)
|
||||
{
|
||||
int state = 0;
|
||||
@ -140,7 +122,7 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
|
||||
if (dict.found("patches"))
|
||||
{
|
||||
wordReList lst(dict.lookup("patches"));
|
||||
uniqWords(lst);
|
||||
wordRes::inplaceUniq(lst);
|
||||
|
||||
writeOpts_.patchSelection(lst);
|
||||
}
|
||||
@ -148,7 +130,7 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
|
||||
if (dict.found("faceZones"))
|
||||
{
|
||||
wordReList lst(dict.lookup("faceZones"));
|
||||
uniqWords(lst);
|
||||
wordRes::inplaceUniq(lst);
|
||||
|
||||
writeOpts_.faceZoneSelection(lst);
|
||||
}
|
||||
@ -174,7 +156,7 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
|
||||
// output fields
|
||||
//
|
||||
dict.lookup("fields") >> selectFields_;
|
||||
uniqWords(selectFields_);
|
||||
wordRes::inplaceUniq(selectFields_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -135,9 +135,6 @@ class ensightWrite
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Eliminate duplicate 'word' entries
|
||||
static void uniqWords(wordReList&);
|
||||
|
||||
//- Ensight case handler
|
||||
ensightCase& ensCase()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user