BUG: PointEdgeWave : n cyclics bool instead of label
[OpenFOAM-1.6.x.git] / src / meshTools / sets / pointZoneSources / setToPointZone / setToPointZone.C
blob80b76f5eed4fd55ca9cc114f17879c5980f89d58
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 "setToPointZone.H"
28 #include "polyMesh.H"
29 #include "pointZoneSet.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 namespace Foam
38 defineTypeNameAndDebug(setToPointZone, 0);
40 addToRunTimeSelectionTable(topoSetSource, setToPointZone, word);
42 addToRunTimeSelectionTable(topoSetSource, setToPointZone, istream);
47 Foam::topoSetSource::addToUsageTable Foam::setToPointZone::usage_
49     setToPointZone::typeName,
50     "\n    Usage: setToPointZone <pointSet>\n\n"
51     "    Select all points in the pointSet.\n\n"
55 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
57 // Construct from components
58 Foam::setToPointZone::setToPointZone
60     const polyMesh& mesh,
61     const word& setName
64     topoSetSource(mesh),
65     setName_(setName)
69 // Construct from dictionary
70 Foam::setToPointZone::setToPointZone
72     const polyMesh& mesh,
73     const dictionary& dict
76     topoSetSource(mesh),
77     setName_(dict.lookup("set"))
81 // Construct from Istream
82 Foam::setToPointZone::setToPointZone
84     const polyMesh& mesh,
85     Istream& is
88     topoSetSource(mesh),
89     setName_(checkIs(is))
93 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
95 Foam::setToPointZone::~setToPointZone()
99 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
101 void Foam::setToPointZone::applyToSet
103     const topoSetSource::setAction action,
104     topoSet& set
105 ) const
107     if (!isA<pointZoneSet>(set))
108     {
109         WarningIn
110         (
111             "setToPointZone::applyToSet(const topoSetSource::setAction"
112             ", topoSet"
113         )   << "Operation only allowed on a pointZoneSet." << endl;
114     }
115     else
116     {
117         pointZoneSet& fzSet = refCast<pointZoneSet>(set);
119         if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
120         {
121             Info<< "    Adding all points from pointSet " << setName_
122                 << " ..." << endl;
124             // Load the sets
125             pointSet fSet(mesh_, setName_);
127             // Start off from copy
128             DynamicList<label> newAddressing(fzSet.addressing());
130             forAllConstIter(pointSet, fSet, iter)
131             {
132                 label pointI = iter.key();
134                 if (!fzSet.found(pointI))
135                 {
136                     newAddressing.append(pointI);
137                 }
138             }
140             fzSet.addressing().transfer(newAddressing);
141             fzSet.updateSet();
142         }
143         else if (action == topoSetSource::DELETE)
144         {
145             Info<< "    Removing all points from pointSet " << setName_
146                 << " ..." << endl;
148             // Load the set
149             pointSet loadedSet(mesh_, setName_);
151             // Start off empty
152             DynamicList<label> newAddressing(fzSet.addressing().size());
154             forAll(fzSet.addressing(), i)
155             {
156                 if (!loadedSet.found(fzSet.addressing()[i]))
157                 {
158                     newAddressing.append(fzSet.addressing()[i]);
159                 }
160             }
161             fzSet.addressing().transfer(newAddressing);
162             fzSet.updateSet();
163         }
164     }
168 // ************************************************************************* //