Commit c2e58dca authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: support multiple zones for topo set sources (#1060)

- uses the keywords 'zones' and 'zone' to avoid potential conflicts
  with a named topoSet action, but accepts 'name' for compatibility.
parent 26f6f425
......@@ -63,7 +63,9 @@ FoamFile
// source faceZoneToCell;
// sourceInfo
// {
// name ".*Zone"; // Name of faceZone, regular expressions allowed
// zones (".*Zone"); // Name of faceZone, regular expressions allowed
// // OR zone ".*Zone"; // Name of faceZone, regular expressions allowed
// // OR name ".*Zone"; // Name of faceZone, regular expressions allowed
// option master; // master/slave
// }
//
......
......@@ -65,7 +65,7 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
for (const faceZone& zone : mesh_.faceZones())
{
if (zoneName_.match(zone.name()))
if (selectedZones_.match(zone.name()))
{
hasMatched = true;
......@@ -77,8 +77,8 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
);
Info<< " Found matching zone " << zone.name()
<< " with " << cellLabels.size() << " cells on selected side."
<< endl;
<< " with " << cellLabels.size() << " cells on "
<< faceActionNames_[option_] << " side" << endl;
for (const label celli : cellLabels)
{
......@@ -94,7 +94,8 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
if (!hasMatched)
{
WarningInFunction
<< "Cannot find any faceZone named " << zoneName_ << nl
<< "Cannot find any faceZone matching "
<< flatOutput(selectedZones_) << nl
<< "Valid names: " << flatOutput(mesh_.faceZones().names())
<< endl;
}
......@@ -106,12 +107,12 @@ void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const
Foam::faceZoneToCell::faceZoneToCell
(
const polyMesh& mesh,
const word& zoneName,
const wordRe& zoneName,
const faceAction option
)
:
topoSetSource(mesh),
zoneName_(zoneName),
selectedZones_(one(), zoneName),
option_(option)
{}
......@@ -123,9 +124,17 @@ Foam::faceZoneToCell::faceZoneToCell
)
:
topoSetSource(mesh),
zoneName_(dict.get<wordRe>("name")),
selectedZones_(),
option_(faceActionNames_.get("option", dict))
{}
{
// Look for 'zones' and 'zone', but accept 'name' as well
if (!dict.readIfPresent("zones", selectedZones_))
{
selectedZones_.resize(1);
selectedZones_.first() =
dict.getCompat<wordRe>("zone", {{"name", 1806}});
}
}
Foam::faceZoneToCell::faceZoneToCell
......@@ -135,7 +144,7 @@ Foam::faceZoneToCell::faceZoneToCell
)
:
topoSetSource(mesh),
zoneName_(checkIs(is)),
selectedZones_(one(), wordRe(checkIs(is))),
option_(faceActionNames_.read(checkIs(is)))
{}
......@@ -151,14 +160,16 @@ void Foam::faceZoneToCell::applyToSet
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all " << faceActionNames_[option_]
<< " cells of faceZone " << zoneName_ << " ..." << endl;
<< " cells of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all " << faceActionNames_[option_]
<< " cells of faceZone " << zoneName_ << " ..." << endl;
<< " cells of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
combine(set, false);
}
......
......@@ -29,11 +29,16 @@ Description
\heading Dictionary parameters
\table
Property | Description | Required | Default
name | The face zone name or regex | yes |
option | Selection type (master / slave) | yes |
Property | Description | Required | Default
option | Selection type (master / slave) | yes |
zone | The face zone name or regex | possibly |
zones | The face zone names or regexs | possibly |
name | Older specification for 'zone' | no |
\endtable
Note
Selection of multiple zones has precedence.
SourceFiles
faceZoneToCell.C
......@@ -43,7 +48,7 @@ SourceFiles
#define faceZoneToCell_H
#include "topoSetSource.H"
#include "wordRe.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -75,8 +80,8 @@ private:
//- Add usage string
static addToUsageTable usage_;
//- Name/regular expression of faceZone
wordRe zoneName_;
//- Matcher for face zones
wordRes selectedZones_;
//- Option
faceAction option_;
......@@ -98,7 +103,7 @@ public:
faceZoneToCell
(
const polyMesh& mesh,
const word& zoneName,
const wordRe& zoneName,
const faceAction option
);
......@@ -115,7 +120,7 @@ public:
// Member Functions
virtual sourceType setType() const
virtual topoSetSource::sourceType setType() const
{
return CELLSETSOURCE;
}
......
......@@ -54,7 +54,7 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const
for (const cellZone& zone : mesh_.cellZones())
{
if (zoneName_.match(zone.name()))
if (selectedZones_.match(zone.name()))
{
hasMatched = true;
......@@ -77,7 +77,8 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const
if (!hasMatched)
{
WarningInFunction
<< "Cannot find any cellZone named " << zoneName_ << nl
<< "Cannot find any cellZone matching "
<< flatOutput(selectedZones_) << nl
<< "Valid names: " << flatOutput(mesh_.cellZones().names())
<< endl;
}
......@@ -89,11 +90,11 @@ void Foam::zoneToCell::combine(topoSet& set, const bool add) const
Foam::zoneToCell::zoneToCell
(
const polyMesh& mesh,
const word& zoneName
const wordRe& zoneName
)
:
topoSetSource(mesh),
zoneName_(zoneName)
selectedZones_(one(), zoneName)
{}
......@@ -104,8 +105,16 @@ Foam::zoneToCell::zoneToCell
)
:
topoSetSource(mesh),
zoneName_(dict.get<wordRe>("name"))
{}
selectedZones_()
{
// Look for 'zones' and 'zone', but accept 'name' as well
if (!dict.readIfPresent("zones", selectedZones_))
{
selectedZones_.resize(1);
selectedZones_.first() =
dict.getCompat<wordRe>("zone", {{"name", 1806}});
}
}
Foam::zoneToCell::zoneToCell
......@@ -115,7 +124,7 @@ Foam::zoneToCell::zoneToCell
)
:
topoSetSource(mesh),
zoneName_(checkIs(is))
selectedZones_(one(), wordRe(checkIs(is)))
{}
......@@ -129,15 +138,15 @@ void Foam::zoneToCell::applyToSet
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all cells of cellZone " << zoneName_ << " ..."
<< endl;
Info<< " Adding all cells of cell zones "
<< flatOutput(selectedZones_) << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all cells of cellZone " << zoneName_ << " ..."
<< endl;
Info<< " Removing all cells of cell zones "
<< flatOutput(selectedZones_) << " ..." << endl;
combine(set, false);
}
......
......@@ -25,14 +25,19 @@ Class
Foam::zoneToCell
Description
A topoSetSource to select cells based on cellZone.
A topoSetSource to select cells based on one or more cellZones.
\heading Dictionary parameters
\table
Property | Description | Required | Default
name | The cell zone name or regex | yes |
Property | Description | Required | Default
zone | The cell zone name or regex | possibly |
zones | The cell zone names or regexs | possibly |
name | Older specification for 'zone' | no |
\endtable
Note
Selection of multiple zones has precedence.
SourceFiles
zoneToCell.C
......@@ -42,7 +47,7 @@ SourceFiles
#define zoneToCell_H
#include "topoSetSource.H"
#include "wordRe.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -50,7 +55,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class zoneToCell Declaration
Class zoneToCell Declaration
\*---------------------------------------------------------------------------*/
class zoneToCell
......@@ -63,8 +68,8 @@ class zoneToCell
//- Add usage string
static addToUsageTable usage_;
//- Name/regular expression of cellZone
wordRe zoneName_;
//- Matcher for zones
wordRes selectedZones_;
// Private Member Functions
......@@ -80,11 +85,7 @@ public:
// Constructors
//- Construct from components
zoneToCell
(
const polyMesh& mesh,
const word& zoneName
);
zoneToCell(const polyMesh& mesh, const wordRe& zoneName);
//- Construct from dictionary
zoneToCell(const polyMesh& mesh, const dictionary& dict);
......@@ -99,7 +100,7 @@ public:
// Member Functions
virtual sourceType setType() const
virtual topoSetSource::sourceType setType() const
{
return CELLSETSOURCE;
}
......
......@@ -82,7 +82,7 @@ public:
setToCellZone(const polyMesh& mesh, const dictionary& dict);
//- Construct from Istream
setToCellZone(const polyMesh& mesh, Istream& is );
setToCellZone(const polyMesh& mesh, Istream& is);
//- Destructor
......
......@@ -54,7 +54,7 @@ void Foam::zoneToFace::combine(topoSet& set, const bool add) const
for (const faceZone& zone : mesh_.faceZones())
{
if (zoneName_.match(zone.name()))
if (selectedZones_.match(zone.name()))
{
hasMatched = true;
......@@ -77,8 +77,10 @@ void Foam::zoneToFace::combine(topoSet& set, const bool add) const
if (!hasMatched)
{
WarningInFunction
<< "Cannot find any faceZone named " << zoneName_ << endl
<< "Valid names are " << mesh_.faceZones().names() << endl;
<< "Cannot find any faceZone matching "
<< flatOutput(selectedZones_) << nl
<< "Valid names are " << flatOutput(mesh_.faceZones().names())
<< endl;
}
}
......@@ -88,11 +90,11 @@ void Foam::zoneToFace::combine(topoSet& set, const bool add) const
Foam::zoneToFace::zoneToFace
(
const polyMesh& mesh,
const word& zoneName
const wordRe& zoneName
)
:
topoSetSource(mesh),
zoneName_(zoneName)
selectedZones_(one(), zoneName)
{}
......@@ -103,8 +105,16 @@ Foam::zoneToFace::zoneToFace
)
:
topoSetSource(mesh),
zoneName_(dict.get<wordRe>("name"))
{}
selectedZones_()
{
// Look for 'zones' and 'zone', but accept 'name' as well
if (!dict.readIfPresent("zones", selectedZones_))
{
selectedZones_.resize(1);
selectedZones_.first() =
dict.getCompat<wordRe>("zone", {{"name", 1806}});
}
}
Foam::zoneToFace::zoneToFace
......@@ -114,7 +124,7 @@ Foam::zoneToFace::zoneToFace
)
:
topoSetSource(mesh),
zoneName_(checkIs(is))
selectedZones_(one(), wordRe(checkIs(is)))
{}
......@@ -128,15 +138,15 @@ void Foam::zoneToFace::applyToSet
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all faces of faceZone " << zoneName_ << " ..."
<< endl;
Info<< " Adding all faces of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all faces of faceZone " << zoneName_ << " ..."
<< endl;
Info<< " Removing all faces of face zones "
<< flatOutput(selectedZones_) << " ..." << endl;
combine(set, false);
}
......
......@@ -25,14 +25,19 @@ Class
Foam::zoneToFace
Description
A topoSetSource to select faces based on faceZone.
A topoSetSource to select faces based on one of more faceZones.
\heading Dictionary parameters
\table
Property | Description | Required | Default
name | The face zone name or regex | yes |
Property | Description | Required | Default
zone | The face zone name or regex | possibly |
zones | The face zone names or regexs | possibly |
name | Older specification for 'zone' | no |
\endtable
Note
Selection of multiple zones has precedence.
SourceFiles
zoneToFace.C
......@@ -42,7 +47,7 @@ SourceFiles
#define zoneToFace_H
#include "topoSetSource.H"
#include "wordRe.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -50,7 +55,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class zoneToFace Declaration
Class zoneToFace Declaration
\*---------------------------------------------------------------------------*/
class zoneToFace
......@@ -63,8 +68,8 @@ class zoneToFace
//- Add usage string
static addToUsageTable usage_;
//- Name/regular expression of the faceZone
wordRe zoneName_;
//- Matcher for zones
wordRes selectedZones_;
// Private Member Functions
......@@ -80,11 +85,7 @@ public:
// Constructors
//- Construct from components
zoneToFace
(
const polyMesh& mesh,
const word& zoneName
);
zoneToFace(const polyMesh& mesh, const wordRe& zoneName);
//- Construct from dictionary
zoneToFace(const polyMesh& mesh, const dictionary& dict);
......@@ -99,7 +100,7 @@ public:
// Member Functions
virtual sourceType setType() const
virtual topoSetSource::sourceType setType() const
{
return FACESETSOURCE;
}
......
......@@ -54,7 +54,7 @@ void Foam::zoneToPoint::combine(topoSet& set, const bool add) const
for (const pointZone& zone : mesh_.pointZones())
{
if (zoneName_.match(zone.name()))
if (selectedZones_.match(zone.name()))
{
hasMatched = true;
......@@ -77,7 +77,8 @@ void Foam::zoneToPoint::combine(topoSet& set, const bool add) const
if (!hasMatched)
{
WarningInFunction
<< "Cannot find any pointZone named " << zoneName_ << nl
<< "Cannot find any pointZone matching "
<< flatOutput(selectedZones_) << nl
<< "Valid names: " << flatOutput(mesh_.pointZones().names())
<< endl;
}
......@@ -89,11 +90,11 @@ void Foam::zoneToPoint::combine(topoSet& set, const bool add) const
Foam::zoneToPoint::zoneToPoint
(
const polyMesh& mesh,
const word& zoneName
const wordRe& zoneName
)
:
topoSetSource(mesh),
zoneName_(zoneName)
selectedZones_(one(), zoneName)
{}
......@@ -104,8 +105,16 @@ Foam::zoneToPoint::zoneToPoint
)
:
topoSetSource(mesh),
zoneName_(dict.get<wordRe>("name"))
{}
selectedZones_()
{
// Look for 'zones' and 'zone', but accept 'name' as well
if (!dict.readIfPresent("zones", selectedZones_))
{
selectedZones_.resize(1);
selectedZones_.first() =
dict.getCompat<wordRe>("zone", {{"name", 1806}});
}
}
Foam::zoneToPoint::zoneToPoint
......@@ -115,7 +124,7 @@ Foam::zoneToPoint::zoneToPoint
)
:
topoSetSource(mesh),
zoneName_(checkIs(is))
selectedZones_(one(), wordRe(checkIs(is)))
{}
......@@ -129,15 +138,15 @@ void Foam::zoneToPoint::applyToSet
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all points of pointZone " << zoneName_ << " ..."
<< endl;
Info<< " Adding all points of point zones "
<< flatOutput(selectedZones_) << " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all points of pointZone " << zoneName_ << " ..."
<< endl;
Info<< " Removing all points of point zones "
<< flatOutput(selectedZones_) << " ..." << endl;
combine(set, false);
}
......
......@@ -25,14 +25,19 @@ Class
Foam::zoneToPoint
Description
A topoSetSource to select points based on pointZone.
A topoSetSource to select points based on one or more pointZones.
\heading Dictionary parameters
\table
Property | Description | Required | Default
name | The point zone name or regex | yes |
Property | Description | Required | Default
zone | The point zone name or regex | possibly |
zones | The point zone names or regexs | possibly |
name | Older specification for 'zone' | no |
\endtable
Note
Selection of multiple zones has precedence.
SourceFiles
zoneToPoint.C
......@@ -42,7 +47,7 @@ SourceFiles
#define zoneToPoint_H
#include "topoSetSource.H"
#include "wordRe.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -50,7 +55,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class zoneToPoint Declaration
Class zoneToPoint Declaration
\*---------------------------------------------------------------------------*/
class zoneToPoint
......@@ -63,8 +68,8 @@ class zoneToPoint
//- Add usage string
static addToUsageTable usage_;
//- Name/regular expression of zone
wordRe zoneName_;
//- Matcher for zones
wordRes selectedZones_;
// Private Member Functions
......@@ -80,11 +85,7 @@ public:
// Constructors
//- Construct from components
zoneToPoint
(
const polyMesh& mesh,
const word& zoneName
);
zoneToPoint(const polyMesh& mesh, const wordRe& zoneName);