FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

zoneToFace.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "zoneToFace.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 
00029 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00030 
00031 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 defineTypeNameAndDebug(zoneToFace, 0);
00037 
00038 addToRunTimeSelectionTable(topoSetSource, zoneToFace, word);
00039 
00040 addToRunTimeSelectionTable(topoSetSource, zoneToFace, istream);
00041 
00042 }
00043 
00044 
00045 Foam::topoSetSource::addToUsageTable Foam::zoneToFace::usage_
00046 (
00047     zoneToFace::typeName,
00048     "\n    Usage: zoneToFace zone\n\n"
00049     "    Select all faces in the faceZone."
00050     " Note:accepts wildcards for zone.\n\n"
00051 );
00052 
00053 
00054 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00055 
00056 void Foam::zoneToFace::combine(topoSet& set, const bool add) const
00057 {
00058     bool hasMatched = false;
00059 
00060     forAll(mesh_.faceZones(), i)
00061     {
00062         const faceZone& zone = mesh_.faceZones()[i];
00063 
00064         if (zoneName_.match(zone.name()))
00065         {
00066             const labelList& faceLabels = mesh_.faceZones()[i];
00067 
00068             Info<< "    Found matching zone " << zone.name()
00069                 << " with " << faceLabels.size() << " faces." << endl;
00070 
00071             hasMatched = true;
00072 
00073             forAll(faceLabels, i)
00074             {
00075                 // Only do active faces
00076                 if (faceLabels[i] < mesh_.nFaces())
00077                 {
00078                     addOrDelete(set, faceLabels[i], add);
00079                 }
00080             }
00081         }
00082     }
00083 
00084     if (!hasMatched)
00085     {
00086         WarningIn("zoneToFace::combine(topoSet&, const bool)")
00087             << "Cannot find any faceZone named " << zoneName_ << endl
00088             << "Valid names are " << mesh_.faceZones().names() << endl;
00089     }
00090 }
00091 
00092 
00093 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00094 
00095 // Construct from components
00096 Foam::zoneToFace::zoneToFace
00097 (
00098     const polyMesh& mesh,
00099     const word& zoneName
00100 )
00101 :
00102     topoSetSource(mesh),
00103     zoneName_(zoneName)
00104 {}
00105 
00106 
00107 // Construct from dictionary
00108 Foam::zoneToFace::zoneToFace
00109 (
00110     const polyMesh& mesh,
00111     const dictionary& dict
00112 )
00113 :
00114     topoSetSource(mesh),
00115     zoneName_(dict.lookup("name"))
00116 {}
00117 
00118 
00119 // Construct from Istream
00120 Foam::zoneToFace::zoneToFace
00121 (
00122     const polyMesh& mesh,
00123     Istream& is
00124 )
00125 :
00126     topoSetSource(mesh),
00127     zoneName_(checkIs(is))
00128 {}
00129 
00130 
00131 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00132 
00133 Foam::zoneToFace::~zoneToFace()
00134 {}
00135 
00136 
00137 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00138 
00139 void Foam::zoneToFace::applyToSet
00140 (
00141     const topoSetSource::setAction action,
00142     topoSet& set
00143 ) const
00144 {
00145     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00146     {
00147         Info<< "    Adding all faces of faceZone " << zoneName_ << " ..."
00148             << endl;
00149 
00150         combine(set, true);
00151     }
00152     else if (action == topoSetSource::DELETE)
00153     {
00154         Info<< "    Removing all faces of faceZone " << zoneName_ << " ..."
00155             << endl;
00156 
00157         combine(set, false);
00158     }
00159 }
00160 
00161 
00162 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines