STYLE: pass wordReList instead of wordList to polyBoundaryMesh::patchSet()

- make warning optional and reuse in cellDistFuncs::getPatchIDs
This commit is contained in:
Mark Olesen
2011-02-08 13:48:01 +01:00
parent 0f990cb447
commit 96edf6f32d
8 changed files with 47 additions and 65 deletions

View File

@ -550,11 +550,12 @@ Foam::label Foam::polyBoundaryMesh::whichPatch(const label faceIndex) const
Foam::labelHashSet Foam::polyBoundaryMesh::patchSet
(
const wordList& patchNames
const wordReList& patchNames,
const bool warnNotFound
) const
{
wordList allPatchNames = names();
labelHashSet ps(size());
const wordList allPatchNames(this->names());
labelHashSet ids(size());
forAll(patchNames, i)
{
@ -562,20 +563,23 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet
// of all patch names for matches
labelList patchIDs = findStrings(patchNames[i], allPatchNames);
if (patchIDs.empty())
if (patchIDs.empty() && warnNotFound)
{
WarningIn("polyBoundaryMesh::patchSet(const wordList&)")
<< "Cannot find any patch names matching " << patchNames[i]
WarningIn
(
"polyBoundaryMesh::patchSet"
"(const wordReList&, const bool) const"
) << "Cannot find any patch names matching " << patchNames[i]
<< endl;
}
forAll(patchIDs, j)
{
ps.insert(patchIDs[j]);
ids.insert(patchIDs[j]);
}
}
return ps;
return ids;
}

View File

@ -38,6 +38,7 @@ SourceFiles
#include "polyPatchList.H"
#include "regIOobject.H"
#include "labelPair.H"
#include "wordReList.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -166,9 +167,13 @@ public:
//- Per boundary face label the patch index
const labelList& patchID() const;
//- Return the set of patch IDs corresponding to the given list of names
// Wild cards are expanded.
labelHashSet patchSet(const wordList&) const;
//- Return the set of patch IDs corresponding to the given names
// By default warns if given names are not found.
labelHashSet patchSet
(
const wordReList& patchNames,
const bool warnNotFound = true
) const;
//- Check whether all procs have all patches and in same order. Return
// true if in error.

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,6 +36,7 @@ SourceFiles
#define inverseDistanceDiffusivity_H
#include "uniformDiffusivity.H"
#include "wordReList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,9 +54,8 @@ class inverseDistanceDiffusivity
// Private data
//- Patches selected to base the distance on
// These can contain regular expressions and the actual patch names
// will be searched for.
wordList patchNames_;
// These can contain patch names or regular expressions to search for.
wordReList patchNames_;
// Private Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,14 +28,9 @@ License
#include "wallPolyPatch.H"
#include "polyBoundaryMesh.H"
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(cellDistFuncs, 0);
}
defineTypeNameAndDebug(Foam::cellDistFuncs, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -61,7 +56,6 @@ Foam::label Foam::cellDistFuncs::findIndex
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from mesh
Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh)
:
mesh_(mesh)
@ -70,36 +64,12 @@ Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Get patch ids of named patches
Foam::labelHashSet Foam::cellDistFuncs::getPatchIDs
(
const wordList& patchNames
const wordReList& patchNames
) const
{
const polyBoundaryMesh& bMesh = mesh().boundaryMesh();
// Construct Set of patchNames for easy checking if included
HashSet<word> patchNamesHash(patchNames.size());
forAll(patchNames, patchI)
{
patchNamesHash.insert(patchNames[patchI]);
}
// Loop over all patches and check if patch name in hashset
labelHashSet patchIDs(bMesh.size());
forAll(bMesh, patchI)
{
const polyPatch& patch = bMesh[patchI];
if (patchNamesHash.found(patch.name()))
{
patchIDs.insert(patchI);
}
}
return patchIDs;
return mesh().boundaryMesh().patchSet(patchNames, false);
}
@ -252,8 +222,10 @@ Foam::label Foam::cellDistFuncs::getPointNeighbours
// size of largest patch (out of supplied subset of patches)
Foam::label Foam::cellDistFuncs::maxPatchSize(const labelHashSet& patchIDs)
const
Foam::label Foam::cellDistFuncs::maxPatchSize
(
const labelHashSet& patchIDs
) const
{
label maxSize = 0;
@ -271,8 +243,11 @@ Foam::label Foam::cellDistFuncs::maxPatchSize(const labelHashSet& patchIDs)
// sum of patch sizes (out of supplied subset of patches)
Foam::label Foam::cellDistFuncs::sumPatchSize(const labelHashSet& patchIDs)
const
Foam::label Foam::cellDistFuncs::sumPatchSize
(
const labelHashSet& patchIDs
)
const
{
label sum = 0;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,7 +39,7 @@ SourceFiles
#include "scalarField.H"
#include "HashSet.H"
#include "Map.H"
#include "wordList.H"
#include "wordReList.H"
#include "scalarField.H"
#include "point.H"
#include "primitivePatch.H"
@ -98,8 +98,8 @@ public:
return mesh_;
}
//- Get patchIDs of named patches
labelHashSet getPatchIDs(const wordList&) const;
//- Return the set of patch IDs corresponding to the given names
labelHashSet getPatchIDs(const wordReList& 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) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -87,8 +87,7 @@ void Foam::nearWallFields::read(const dictionary& dict)
const fvMesh& mesh = refCast<const fvMesh>(obr_);
dict.lookup("fields") >> fieldSet_;
patchSet_ =
mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches")));
patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches"));
distance_ = readScalar(dict.lookup("distance"));

View File

@ -229,8 +229,7 @@ void Foam::forces::read(const dictionary& dict)
const fvMesh& mesh = refCast<const fvMesh>(obr_);
patchSet_ =
mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches")));
patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches"));
if (directForceDensity_)
{