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

labelToFace.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 "labelToFace.H"
00030 #include "polyMesh.H"
00031 
00032 #include "addToRunTimeSelectionTable.H"
00033 
00034 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 defineTypeNameAndDebug(labelToFace, 0);
00040 
00041 addToRunTimeSelectionTable(topoSetSource, labelToFace, word);
00042 
00043 addToRunTimeSelectionTable(topoSetSource, labelToFace, istream);
00044 
00045 }
00046 
00047 
00048 Foam::topoSetSource::addToUsageTable Foam::labelToFace::usage_
00049 (
00050     labelToFace::typeName,
00051     "\n    Usage: labelToFace (i0 i1 .. in)\n\n"
00052     "    Select faces by label\n\n"
00053 );
00054 
00055 
00056 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00057 
00058 void Foam::labelToFace::combine(topoSet& set, const bool add) const
00059 {
00060     forAll(labels_, labelI)
00061     {
00062         addOrDelete(set, labels_[labelI], add);
00063     }
00064 }
00065 
00066 
00067 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00068 
00069 // Construct from components
00070 Foam::labelToFace::labelToFace
00071 (
00072     const polyMesh& mesh,
00073     const labelList& labels
00074 )
00075 :
00076     topoSetSource(mesh),
00077     labels_(labels)
00078 {}
00079 
00080 
00081 // Construct from dictionary
00082 Foam::labelToFace::labelToFace
00083 (
00084     const polyMesh& mesh,
00085     const dictionary& dict
00086 )
00087 :
00088     topoSetSource(mesh),
00089     labels_(dict.lookup("value"))
00090 {}
00091 
00092 
00093 // Construct from Istream
00094 Foam::labelToFace::labelToFace
00095 (
00096     const polyMesh& mesh,
00097     Istream& is
00098 )
00099 :
00100     topoSetSource(mesh),
00101     labels_(checkIs(is))
00102 {}
00103 
00104 
00105 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00106 
00107 Foam::labelToFace::~labelToFace()
00108 {}
00109 
00110 
00111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00112 
00113 void Foam::labelToFace::applyToSet
00114 (
00115     const topoSetSource::setAction action,
00116     topoSet& set
00117 ) const
00118 {
00119     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00120     {
00121         Info<< "    Adding faces mentioned in dictionary" << " ..." << endl;
00122 
00123         combine(set, true);
00124     }
00125     else if (action == topoSetSource::DELETE)
00126     {
00127         Info<< "    Removing faces mentioned dictionary" << " ..." << endl;
00128 
00129         combine(set, false);
00130     }
00131 }
00132 
00133 
00134 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd