ENH: consistency updates for patchToFace topoSetSource (#1060)

- Support specification with "patches" and "patch" keywords
  (similar to zone selection). Keyword "name" for compatibility.
This commit is contained in:
Mark Olesen
2018-10-30 12:01:36 +00:00
parent de1832abdd
commit 9a87a043d6
21 changed files with 56 additions and 44 deletions

View File

@ -51,7 +51,7 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const
{ {
labelHashSet patchIDs = mesh_.boundaryMesh().patchSet labelHashSet patchIDs = mesh_.boundaryMesh().patchSet
( (
List<wordRe>(1, patchName_), selectedPatches_,
true, // warn if not found true, // warn if not found
true // use patch groups if available true // use patch groups if available
); );
@ -77,8 +77,10 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const
if (patchIDs.empty()) if (patchIDs.empty())
{ {
WarningInFunction WarningInFunction
<< "Cannot find any patch named " << patchName_ << endl << "Cannot find any patches matching "
<< "Valid names are " << mesh_.boundaryMesh().names() << endl; << flatOutput(selectedPatches_) << nl
<< "Valid names are " << flatOutput(mesh_.boundaryMesh().names())
<< endl;
} }
} }
@ -88,11 +90,11 @@ void Foam::patchToFace::combine(topoSet& set, const bool add) const
Foam::patchToFace::patchToFace Foam::patchToFace::patchToFace
( (
const polyMesh& mesh, const polyMesh& mesh,
const word& patchName const wordRe& patchName
) )
: :
topoSetSource(mesh), topoSetSource(mesh),
patchName_(patchName) selectedPatches_(one(), patchName)
{} {}
@ -103,8 +105,16 @@ Foam::patchToFace::patchToFace
) )
: :
topoSetSource(mesh), topoSetSource(mesh),
patchName_(dict.get<wordRe>("name")) selectedPatches_()
{} {
// Look for 'patches' and 'patch', but accept 'name' as well
if (!dict.readIfPresent("patches", selectedPatches_))
{
selectedPatches_.resize(1);
selectedPatches_.first() =
dict.getCompat<wordRe>("patch", {{"name", 1806}});
}
}
Foam::patchToFace::patchToFace Foam::patchToFace::patchToFace
@ -114,7 +124,7 @@ Foam::patchToFace::patchToFace
) )
: :
topoSetSource(mesh), topoSetSource(mesh),
patchName_(checkIs(is)) selectedPatches_(one(), wordRe(checkIs(is)))
{} {}
@ -128,14 +138,15 @@ void Foam::patchToFace::applyToSet
{ {
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{ {
Info<< " Adding all faces of patch " << patchName_ << " ..." << endl; Info<< " Adding all faces of patches "
<< flatOutput(selectedPatches_) << " ..." << endl;
combine(set, true); combine(set, true);
} }
else if (action == topoSetSource::DELETE) else if (action == topoSetSource::DELETE)
{ {
Info<< " Removing all faces of patch " << patchName_ << " ..." Info<< " Removing all faces of patches "
<< endl; << flatOutput(selectedPatches_) << " ..." << endl;
combine(set, false); combine(set, false);
} }

View File

@ -3,7 +3,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) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,10 +29,15 @@ Description
\heading Dictionary parameters \heading Dictionary parameters
\table \table
Property | Description | Required | Default Property | Description | Required | Default
name | Patch name or regex to select | yes | patch | The face zone name or regex | possibly |
patches | The face zone names or regexs | possibly |
name | Older specification for 'patch' | no |
\endtable \endtable
Note
Selection of multiple patches has precedence.
SourceFiles SourceFiles
patchToFace.C patchToFace.C
@ -42,7 +47,7 @@ SourceFiles
#define patchToFace_H #define patchToFace_H
#include "topoSetSource.H" #include "topoSetSource.H"
#include "wordRe.H" #include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -63,8 +68,8 @@ class patchToFace
//- Add usage string //- Add usage string
static addToUsageTable usage_; static addToUsageTable usage_;
//- Name/regular expression of patch //- Matcher for patches
wordRe patchName_; wordRes selectedPatches_;
// Private Member Functions // Private Member Functions
@ -80,11 +85,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
patchToFace patchToFace(const polyMesh& mesh, const wordRe& patchName);
(
const polyMesh& mesh,
const word& patchName
);
//- Construct from dictionary //- Construct from dictionary
patchToFace(const polyMesh& mesh, const dictionary& dict); patchToFace(const polyMesh& mesh, const dictionary& dict);

View File

@ -67,7 +67,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name inlet; patch inlet;
} }
} }

View File

@ -36,7 +36,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name coupledWallTmp; patch coupledWallTmp;
} }
} }

View File

@ -24,7 +24,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name coupledPatch; patch coupledPatch;
} }
} }

View File

@ -27,7 +27,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name couple1; patch couple1;
} }
} }
{ {
@ -49,7 +49,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name couple2; patch couple2;
} }
} }
{ {

View File

@ -24,7 +24,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name outerCylinder; patch outerCylinder;
} }
} }

View File

@ -27,7 +27,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name "AMI.*"; patch "AMI.*";
} }
} }
); );

View File

@ -24,7 +24,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name "side1"; patch side1;
} }
} }
{ {
@ -57,7 +57,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name "walls"; patch walls;
} }
} }
{ {

View File

@ -24,7 +24,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name filmWalls; patch filmWalls;
} }
} }
{ {

View File

@ -24,7 +24,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name filmWalls; patch filmWalls;
} }
} }
{ {

View File

@ -24,7 +24,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name filmWalls; patch filmWalls;
} }
} }
{ {

View File

@ -186,7 +186,7 @@ FoamFile
// // All faces of patch // // All faces of patch
// source patchToFace; // source patchToFace;
// { // {
// name ".*Wall"; // Name of patch, regular expressions allowed // patch ".*Wall"; // Name of patch, regular expressions allowed
// } // }
// //
// // All faces of faceZone // // All faces of faceZone

View File

@ -21,7 +21,7 @@ newFromPatch
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name outer; patch outer;
} }
} }

View File

@ -66,7 +66,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name top; patch top;
} }
} }
@ -192,7 +192,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name bottom; patch bottom;
} }
} }

View File

@ -24,7 +24,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name sides; patch sides;
} }
} }

View File

@ -24,7 +24,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name outerCylinder; patch outerCylinder;
} }
} }

View File

@ -27,7 +27,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name "AMI.*"; patch "AMI.*";
} }
} }
); );

View File

@ -41,7 +41,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name freeSurface; patch freeSurface;
} }
} }

View File

@ -24,7 +24,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name floatingObject; patch floatingObject;
} }
} }

View File

@ -41,7 +41,7 @@ actions
source patchToFace; source patchToFace;
sourceInfo sourceInfo
{ {
name freeSurface; patch freeSurface;
} }
} }