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 Foam::labelHashSet Foam::polyBoundaryMesh::patchSet
( (
const wordList& patchNames const wordReList& patchNames,
const bool warnNotFound
) const ) const
{ {
wordList allPatchNames = names(); const wordList allPatchNames(this->names());
labelHashSet ps(size()); labelHashSet ids(size());
forAll(patchNames, i) forAll(patchNames, i)
{ {
@ -562,20 +563,23 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet
// of all patch names for matches // of all patch names for matches
labelList patchIDs = findStrings(patchNames[i], allPatchNames); labelList patchIDs = findStrings(patchNames[i], allPatchNames);
if (patchIDs.empty()) if (patchIDs.empty() && warnNotFound)
{ {
WarningIn("polyBoundaryMesh::patchSet(const wordList&)") WarningIn
<< "Cannot find any patch names matching " << patchNames[i] (
"polyBoundaryMesh::patchSet"
"(const wordReList&, const bool) const"
) << "Cannot find any patch names matching " << patchNames[i]
<< endl; << endl;
} }
forAll(patchIDs, j) 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 "polyPatchList.H"
#include "regIOobject.H" #include "regIOobject.H"
#include "labelPair.H" #include "labelPair.H"
#include "wordReList.H"
#include "HashSet.H" #include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -166,9 +167,13 @@ public:
//- Per boundary face label the patch index //- Per boundary face label the patch index
const labelList& patchID() const; const labelList& patchID() const;
//- Return the set of patch IDs corresponding to the given list of names //- Return the set of patch IDs corresponding to the given names
// Wild cards are expanded. // By default warns if given names are not found.
labelHashSet patchSet(const wordList&) const; labelHashSet patchSet
(
const wordReList& patchNames,
const bool warnNotFound = true
) const;
//- Check whether all procs have all patches and in same order. Return //- Check whether all procs have all patches and in same order. Return
// true if in error. // true if in error.

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,14 +28,9 @@ License
#include "wallPolyPatch.H" #include "wallPolyPatch.H"
#include "polyBoundaryMesh.H" #include "polyBoundaryMesh.H"
namespace Foam // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // defineTypeNameAndDebug(Foam::cellDistFuncs, 0);
defineTypeNameAndDebug(cellDistFuncs, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -61,7 +56,6 @@ Foam::label Foam::cellDistFuncs::findIndex
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from mesh
Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh) Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh)
: :
mesh_(mesh) mesh_(mesh)
@ -70,36 +64,12 @@ Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Get patch ids of named patches
Foam::labelHashSet Foam::cellDistFuncs::getPatchIDs Foam::labelHashSet Foam::cellDistFuncs::getPatchIDs
( (
const wordList& patchNames const wordReList& patchNames
) const ) const
{ {
const polyBoundaryMesh& bMesh = mesh().boundaryMesh(); return mesh().boundaryMesh().patchSet(patchNames, false);
// 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;
} }
@ -252,8 +222,10 @@ Foam::label Foam::cellDistFuncs::getPointNeighbours
// size of largest patch (out of supplied subset of patches) // size of largest patch (out of supplied subset of patches)
Foam::label Foam::cellDistFuncs::maxPatchSize(const labelHashSet& patchIDs) Foam::label Foam::cellDistFuncs::maxPatchSize
const (
const labelHashSet& patchIDs
) const
{ {
label maxSize = 0; 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) // sum of patch sizes (out of supplied subset of patches)
Foam::label Foam::cellDistFuncs::sumPatchSize(const labelHashSet& patchIDs) Foam::label Foam::cellDistFuncs::sumPatchSize
const (
const labelHashSet& patchIDs
)
const
{ {
label sum = 0; label sum = 0;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,7 +39,7 @@ SourceFiles
#include "scalarField.H" #include "scalarField.H"
#include "HashSet.H" #include "HashSet.H"
#include "Map.H" #include "Map.H"
#include "wordList.H" #include "wordReList.H"
#include "scalarField.H" #include "scalarField.H"
#include "point.H" #include "point.H"
#include "primitivePatch.H" #include "primitivePatch.H"
@ -98,8 +98,8 @@ public:
return mesh_; return mesh_;
} }
//- Get patchIDs of named patches //- Return the set of patch IDs corresponding to the given names
labelHashSet getPatchIDs(const wordList&) const; labelHashSet getPatchIDs(const wordReList& patchNames) const;
//- Get patchIDs of/derived off certain type (e.g. 'processorPolyPatch') //- Get patchIDs of/derived off certain type (e.g. 'processorPolyPatch')
// Uses isA, not isType // Uses isA, not isType

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -87,8 +87,7 @@ void Foam::nearWallFields::read(const dictionary& dict)
const fvMesh& mesh = refCast<const fvMesh>(obr_); const fvMesh& mesh = refCast<const fvMesh>(obr_);
dict.lookup("fields") >> fieldSet_; dict.lookup("fields") >> fieldSet_;
patchSet_ = patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches"));
mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches")));
distance_ = readScalar(dict.lookup("distance")); 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_); const fvMesh& mesh = refCast<const fvMesh>(obr_);
patchSet_ = patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches"));
mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches")));
if (directForceDensity_) if (directForceDensity_)
{ {