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

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