initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / sets / cellSources / labelToCell / labelToCell.C
blob0a4a2db7e5305261100bfbc375c986f1496b2326
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "labelToCell.H"
28 #include "polyMesh.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 namespace Foam
37 defineTypeNameAndDebug(labelToCell, 0);
39 addToRunTimeSelectionTable(topoSetSource, labelToCell, word);
41 addToRunTimeSelectionTable(topoSetSource, labelToCell, istream);
46 Foam::topoSetSource::addToUsageTable Foam::labelToCell::usage_
48     labelToCell::typeName,
49     "\n    Usage: labelToCell (i0 i1 .. in)\n\n"
50     "    Select cells by cellLabel\n\n"
54 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
56 void Foam::labelToCell::combine(topoSet& set, const bool add) const
58     forAll(labels_, labelI)
59     {
60         addOrDelete(set, labels_[labelI], add);
61     }
65 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
67 // Construct from components
68 Foam::labelToCell::labelToCell
70     const polyMesh& mesh,
71     const labelList& labels
74     topoSetSource(mesh),
75     labels_(labels)
79 // Construct from dictionary
80 Foam::labelToCell::labelToCell
82     const polyMesh& mesh,
83     const dictionary& dict
86     topoSetSource(mesh),
87     labels_(dict.lookup("value"))
91 // Construct from Istream
92 Foam::labelToCell::labelToCell
94     const polyMesh& mesh,
95     Istream& is
98     topoSetSource(mesh),
99     labels_(checkIs(is))
103 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
105 Foam::labelToCell::~labelToCell()
109 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
111 void Foam::labelToCell::applyToSet
113     const topoSetSource::setAction action,
114     topoSet& set
115 ) const
117     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
118     {
119         Info<< "    Adding cells mentioned in dictionary" << " ..." << endl;
121         combine(set, true);
122     }
123     else if (action == topoSetSource::DELETE)
124     {
125         Info<< "    Removing cells mentioned in dictionary" << " ..." << endl;
127         combine(set, false);
128     }
132 // ************************************************************************* //