initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / sets / pointSources / labelToPoint / labelToPoint.C
bloba80ca084d67388bcca16e94ba440d9beb43baaa4
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 Description
27 \*---------------------------------------------------------------------------*/
29 #include "labelToPoint.H"
30 #include "polyMesh.H"
32 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace Foam
39 defineTypeNameAndDebug(labelToPoint, 0);
41 addToRunTimeSelectionTable(topoSetSource, labelToPoint, word);
43 addToRunTimeSelectionTable(topoSetSource, labelToPoint, istream);
48 Foam::topoSetSource::addToUsageTable Foam::labelToPoint::usage_
50     labelToPoint::typeName,
51     "\n    Usage: labelToPoint (i0 i1 .. in)\n\n"
52     "    Select points by label\n\n"
56 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
58 void Foam::labelToPoint::combine(topoSet& set, const bool add) const
60     forAll(labels_, labelI)
61     {
62         addOrDelete(set, labels_[labelI], add);
63     }
67 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
69 // Construct from components
70 Foam::labelToPoint::labelToPoint
72     const polyMesh& mesh,
73     const labelList& labels
76     topoSetSource(mesh),
77     labels_(labels)
81 // Construct from dictionary
82 Foam::labelToPoint::labelToPoint
84     const polyMesh& mesh,
85     const dictionary& dict
88     topoSetSource(mesh),
89     labels_(dict.lookup("value"))
93 // Construct from Istream
94 Foam::labelToPoint::labelToPoint
96     const polyMesh& mesh,
97     Istream& is
100     topoSetSource(mesh),
101     labels_(checkIs(is))
105 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
107 Foam::labelToPoint::~labelToPoint()
111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
113 void Foam::labelToPoint::applyToSet
115     const topoSetSource::setAction action,
116     topoSet& set
117 ) const
119     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
120     {
121         Info<< "    Adding points mentioned in dictionary" << " ..." << endl;
123         combine(set, true);
124     }
125     else if (action == topoSetSource::DELETE)
126     {
127         Info<< "    Removing points mentioned in dictionary" << " ..."
128             << endl;
130         combine(set, false);
131     }
135 // ************************************************************************* //