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

@ -69,7 +69,7 @@ Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh)
Foam::labelHashSet Foam::cellDistFuncs::getPatchIDs
(
const wordReList& patchNames
const UList<wordRe>& patchNames
) const
{
return mesh().boundaryMesh().patchSet(patchNames, false);

View File

@ -38,7 +38,7 @@ SourceFiles
#include "HashSet.H"
#include "Map.H"
#include "wordReList.H"
#include "wordRe.H"
#include "scalarField.H"
#include "point.H"
#include "primitivePatch.H"
@ -98,7 +98,7 @@ public:
}
//- Return the set of patch IDs corresponding to the given names
labelHashSet getPatchIDs(const wordReList& patchNames) const;
labelHashSet getPatchIDs(const UList<wordRe>& patchNames) const;
//- Get patchIDs of/derived off certain type (e.g. 'processorPolyPatch')
// Uses isA, not isType

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,7 +54,7 @@ Foam::wordList Foam::subTriSurfaceMesh::patchNames(const triSurface& s)
Foam::labelList Foam::subTriSurfaceMesh::selectedRegions
(
const triSurface& s,
const wordReList& regionNames
const UList<wordRe>& regionNames
)
{
const wordList names(patchNames(s));
@ -92,7 +92,7 @@ Foam::triSurface Foam::subTriSurfaceMesh::subset
const triSurfaceMesh& s =
io.db().lookupObject<triSurfaceMesh>(subGeomName);
const wordReList regionNames(dict.lookup("patches"));
const wordRes regionNames(dict.lookup("patches"));
labelList regionMap(selectedRegions(s, regionNames));
@ -137,10 +137,4 @@ Foam::subTriSurfaceMesh::subTriSurfaceMesh
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::subTriSurfaceMesh::~subTriSurfaceMesh()
{}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,7 +76,7 @@ class subTriSurfaceMesh
static labelList selectedRegions
(
const triSurface& s,
const wordReList& regionNames
const UList<wordRe>& regionNames
);
//- Subset triSurface based on regions
@ -100,7 +100,7 @@ public:
//- Destructor
virtual ~subTriSurfaceMesh();
virtual ~subTriSurfaceMesh() = default;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -65,12 +65,6 @@ Foam::triSurfaceLoader::triSurfaceLoader(const Time& runTime)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::triSurfaceLoader::~triSurfaceLoader()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::triSurfaceLoader::readDir()
@ -85,9 +79,8 @@ Foam::label Foam::triSurfaceLoader::readDir()
// (eg, files with/without .gz)
wordHashSet names(2*files.size());
forAll(files, filei)
for (const fileName& f : files)
{
const fileName& f = files[filei];
if (triSurface::canRead(f))
{
names.insert(f.name());
@ -151,7 +144,7 @@ Foam::label Foam::triSurfaceLoader::select(const wordRe& mat)
}
Foam::label Foam::triSurfaceLoader::select(const wordReList& matcher)
Foam::label Foam::triSurfaceLoader::select(const UList<wordRe>& matcher)
{
// Need to be more careful when select.
// - preserve same order as the input matcher itself
@ -167,18 +160,15 @@ Foam::label Foam::triSurfaceLoader::select(const wordReList& matcher)
wordHashSet hashedMissing(2*matcher.size());
// Exact matches must exist
forAll(matcher, i)
for (const wordRe& mat : matcher)
{
const wordRe& mat = matcher[i];
if (mat.isPattern())
{
labelList indices = findMatchingStrings(mat, available_);
sort(indices);
forAll(indices, j)
for (const label idx : indices)
{
const label idx = indices[j];
if (hashedFound.insert(idx))
{
foundIds.append(idx);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,7 +28,7 @@ Description
Convenience class for loading single or multiple surface files
from the constant/triSurface (or other) directory.
Surfaces selection based on word, wordRe, wordReList.
Surfaces selection based on word, wordRe, list of wordRe.
If multiple surfaces are selected, they are concatenated into a
single surface with offset faces,points,regions.
@ -109,7 +109,7 @@ public:
//- Destructor
~triSurfaceLoader();
~triSurfaceLoader() = default;
// Member Functions
@ -151,7 +151,7 @@ public:
label select(const wordRe& mat);
//- Populates 'selected' with a subset of the available files.
label select(const wordReList& matcher);
label select(const UList<wordRe>& matcher);
//- Load a single file, or load and combine multiple selected files
// Optionally scale the surface(s) on input, with a zero or negative