OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

patchToFace.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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "patchToFace.H"
00030 #include "polyMesh.H"
00031 
00032 #include "addToRunTimeSelectionTable.H"
00033 
00034 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 defineTypeNameAndDebug(patchToFace, 0);
00040 
00041 addToRunTimeSelectionTable(topoSetSource, patchToFace, word);
00042 
00043 addToRunTimeSelectionTable(topoSetSource, patchToFace, istream);
00044 
00045 }
00046 
00047 
00048 Foam::topoSetSource::addToUsageTable Foam::patchToFace::usage_
00049 (
00050     patchToFace::typeName,
00051     "\n    Usage: patchToFace patch\n\n"
00052     "    Select all faces in the patch. Note:accepts wildcards for patch.\n\n"
00053 );
00054 
00055 
00056 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00057 
00058 void Foam::patchToFace::combine(topoSet& set, const bool add) const
00059 {
00060     bool hasMatched = false;
00061 
00062     forAll(mesh_.boundaryMesh(), patchI)
00063     {
00064         const polyPatch& pp = mesh_.boundaryMesh()[patchI];
00065 
00066         if (patchName_.match(pp.name()))
00067         {
00068             Info<< "    Found matching patch " << pp.name()
00069                 << " with " << pp.size() << " faces." << endl;
00070 
00071             hasMatched = true;
00072 
00073 
00074             for
00075             (
00076                 label faceI = pp.start();
00077                 faceI < pp.start() + pp.size();
00078                 faceI++
00079             )
00080             {
00081                 addOrDelete(set, faceI, add);
00082             }
00083         }
00084     }
00085 
00086     if (!hasMatched)
00087     {
00088         WarningIn("patchToFace::combine(topoSet&, const bool)")
00089             << "Cannot find any patch named " << patchName_ << endl
00090             << "Valid names are " << mesh_.boundaryMesh().names() << endl;
00091     }
00092 }
00093 
00094 
00095 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00096 
00097 // Construct from components
00098 Foam::patchToFace::patchToFace
00099 (
00100     const polyMesh& mesh,
00101     const word& patchName
00102 )
00103 :
00104     topoSetSource(mesh),
00105     patchName_(patchName)
00106 {}
00107 
00108 
00109 // Construct from dictionary
00110 Foam::patchToFace::patchToFace
00111 (
00112     const polyMesh& mesh,
00113     const dictionary& dict
00114 )
00115 :
00116     topoSetSource(mesh),
00117     patchName_(dict.lookup("name"))
00118 {}
00119 
00120 
00121 // Construct from Istream
00122 Foam::patchToFace::patchToFace
00123 (
00124     const polyMesh& mesh,
00125     Istream& is
00126 )
00127 :
00128     topoSetSource(mesh),
00129     patchName_(checkIs(is))
00130 {}
00131 
00132 
00133 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00134 
00135 Foam::patchToFace::~patchToFace()
00136 {}
00137 
00138 
00139 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00140 
00141 void Foam::patchToFace::applyToSet
00142 (
00143     const topoSetSource::setAction action,
00144     topoSet& set
00145 ) const
00146 {
00147     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00148     {
00149         Info<< "    Adding all faces of patch " << patchName_ << " ..." << endl;
00150 
00151         combine(set, true);
00152     }
00153     else if (action == topoSetSource::DELETE)
00154     {
00155         Info<< "    Removing all faces of patch " << patchName_ << " ..."
00156             << endl;
00157 
00158         combine(set, false);
00159     }
00160 }
00161 
00162 
00163 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd