diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index d5133cb33dad9e45beb50fa4785fdaee749b2d39..a61d00246e04323e182603105061d72d9150acd6 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -90,6 +90,7 @@ $(cellSources)/nbrToCell/nbrToCell.C $(cellSources)/zoneToCell/zoneToCell.C $(cellSources)/sphereToCell/sphereToCell.C $(cellSources)/cylinderToCell/cylinderToCell.C +$(cellSources)/faceZoneToCell/faceZoneToCell.C faceSources = sets/faceSources $(faceSources)/faceToFace/faceToFace.C diff --git a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C new file mode 100644 index 0000000000000000000000000000000000000000..526620fe14746be56d0e433274be25edb0b5d8cd --- /dev/null +++ b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.C @@ -0,0 +1,185 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "faceZoneToCell.H" +#include "polyMesh.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(faceZoneToCell, 0); + +addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, word); + +addToRunTimeSelectionTable(topoSetSource, faceZoneToCell, istream); + +} + + +Foam::topoSetSource::addToUsageTable Foam::faceZoneToCell::usage_ +( + faceZoneToCell::typeName, + "\n Usage: faceZoneToCell zone master|slave\n\n" + " Select master or slave side of the faceZone." + " Note:accepts wildcards for zone.\n\n" +); + + +template<> +const char* Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2>::names[] = +{ + "master", + "slave" +}; + + +const Foam::NamedEnum<Foam::faceZoneToCell::faceAction, 2> + Foam::faceZoneToCell::faceActionNames_; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::faceZoneToCell::combine(topoSet& set, const bool add) const +{ + bool hasMatched = false; + + forAll(mesh_.faceZones(), i) + { + const faceZone& zone = mesh_.faceZones()[i]; + + if (zoneName_.match(zone.name())) + { + const labelList& cellLabels = + ( + option_ == MASTER + ? zone.masterCells() + : zone.slaveCells() + ); + + Info<< " Found matching zone " << zone.name() + << " with " << cellLabels.size() << " cells on selected side." + << endl; + + hasMatched = true; + + forAll(cellLabels, i) + { + // Only do active cells + if (cellLabels[i] < mesh_.nCells()) + { + addOrDelete(set, cellLabels[i], add); + } + } + } + } + + if (!hasMatched) + { + WarningIn("faceZoneToCell::combine(topoSet&, const bool)") + << "Cannot find any faceZone named " << zoneName_ << endl + << "Valid names are " << mesh_.faceZones().names() << endl; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::faceZoneToCell::faceZoneToCell +( + const polyMesh& mesh, + const word& zoneName, + const faceAction option +) +: + topoSetSource(mesh), + zoneName_(zoneName), + option_(option) +{} + + +// Construct from dictionary +Foam::faceZoneToCell::faceZoneToCell +( + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetSource(mesh), + zoneName_(dict.lookup("name")), + option_(faceActionNames_.read(dict.lookup("option"))) +{} + + +// Construct from Istream +Foam::faceZoneToCell::faceZoneToCell +( + const polyMesh& mesh, + Istream& is +) +: + topoSetSource(mesh), + zoneName_(checkIs(is)), + option_(faceActionNames_.read(checkIs(is))) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::faceZoneToCell::~faceZoneToCell() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::faceZoneToCell::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + { + Info<< " Adding all " << faceActionNames_[option_] + << " cells of faceZone " << zoneName_ << " ..." << endl; + + combine(set, true); + } + else if (action == topoSetSource::DELETE) + { + Info<< " Removing all " << faceActionNames_[option_] + << " cells of faceZone " << zoneName_ << " ..." << endl; + + combine(set, false); + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H new file mode 100644 index 0000000000000000000000000000000000000000..b09c58399fcca136725ec959690542ff25221318 --- /dev/null +++ b/src/meshTools/sets/cellSources/faceZoneToCell/faceZoneToCell.H @@ -0,0 +1,138 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::faceZoneToCell + +Description + A topoSetSource to select cells based on side of faceZone. + +SourceFiles + faceZoneToCell.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceZoneToCell_H +#define faceZoneToCell_H + +#include "topoSetSource.H" +#include "wordRe.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class faceZoneToCell Declaration +\*---------------------------------------------------------------------------*/ + +class faceZoneToCell +: + public topoSetSource +{ +public: + //- Enumeration defining the valid options + enum faceAction + { + MASTER, + SLAVE + }; + +private: + + // Private data + + static const NamedEnum<faceAction, 2> faceActionNames_; + + //- Add usage string + static addToUsageTable usage_; + + //- Name/regular expression of faceZone + wordRe zoneName_; + + //- Option + faceAction option_; + + + // Private Member Functions + + void combine(topoSet& set, const bool add) const; + + +public: + + //- Runtime type information + TypeName("faceZoneToCell"); + + // Constructors + + //- Construct from components + faceZoneToCell + ( + const polyMesh& mesh, + const word& zoneName, + const faceAction option + ); + + //- Construct from dictionary + faceZoneToCell + ( + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from Istream + faceZoneToCell + ( + const polyMesh& mesh, + Istream& + ); + + + // Destructor + + virtual ~faceZoneToCell(); + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C index 0dcd1e0ffb8b733911aebf50cdaab88e67a0c0f9..14b6deb7f37771b062c29e8d635f7feae33448aa 100644 --- a/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C +++ b/src/meshTools/sets/cellSources/zoneToCell/zoneToCell.C @@ -47,7 +47,8 @@ Foam::topoSetSource::addToUsageTable Foam::zoneToCell::usage_ ( zoneToCell::typeName, "\n Usage: zoneToCell zone\n\n" - " Select all cells in the cellZone\n\n" + " Select all cells in the cellZone." + " Note:accepts wildcards for zone.\n\n" ); diff --git a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C index 9bcf49690ffc285ae3db1568476ba31edc0e9353..000db639a96180f2e24ada7aa4f08b4a621685e4 100644 --- a/src/meshTools/sets/faceSources/patchToFace/patchToFace.C +++ b/src/meshTools/sets/faceSources/patchToFace/patchToFace.C @@ -49,7 +49,7 @@ Foam::topoSetSource::addToUsageTable Foam::patchToFace::usage_ ( patchToFace::typeName, "\n Usage: patchToFace patch\n\n" - " Select all faces in the patch\n\n" + " Select all faces in the patch. Note:accepts wildcards for patch.\n\n" ); diff --git a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C index 12cbab560d68ff36281aa34ca6bead1a4b8926f9..465632f2b1091fcdf774b99a0eb076ab16600d15 100644 --- a/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C +++ b/src/meshTools/sets/faceSources/zoneToFace/zoneToFace.C @@ -47,7 +47,8 @@ Foam::topoSetSource::addToUsageTable Foam::zoneToFace::usage_ ( zoneToFace::typeName, "\n Usage: zoneToFace zone\n\n" - " Select all faces in the faceZone\n\n" + " Select all faces in the faceZone." + " Note:accepts wildcards for zone.\n\n" ); diff --git a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C index 4b5148c558c8d0915109d9e87591076d705db5fc..0558093afa54d58b53c6c6eed6435a7dba6f6798 100644 --- a/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C +++ b/src/meshTools/sets/pointSources/zoneToPoint/zoneToPoint.C @@ -47,7 +47,8 @@ Foam::topoSetSource::addToUsageTable Foam::zoneToPoint::usage_ ( zoneToPoint::typeName, "\n Usage: zoneToPoint zone\n\n" - " Select all points in the pointZone\n\n" + " Select all points in the pointZone." + " Note:accepts wildcards for zone.\n\n" );