Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / meshTools / sets / pointSources / setToPoint / setToPoint.C
blob93bd125cee6b42cd657795f4e4f0c11dcbd7ae75
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 "setToPoint.H"
28 #include "polyMesh.H"
29 #include "pointSet.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 namespace Foam
38 defineTypeNameAndDebug(setToPoint, 0);
40 addToRunTimeSelectionTable(topoSetSource, setToPoint, word);
42 addToRunTimeSelectionTable(topoSetSource, setToPoint, istream);
47 Foam::topoSetSource::addToUsageTable Foam::setToPoint::usage_
49     setToPoint::typeName,
50     "\n    Usage: setToPoint set\n\n"
51     "    Select all points in the pointSet\n\n"
55 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
57 void Foam::setToPoint::combine(topoSet& set, const bool add) const
59     pointSet cs
60     (
61         mesh_,
62         setName_
63     );
65     const labelList pointLabels = cs.toc();
67     if (pointLabels.size() > 0)
68     {
69         forAll (pointLabels, i)
70         {
71             // Only do active points
72             if (pointLabels[i] < mesh_.nPoints())
73             {
74                 addOrDelete(set, pointLabels[i], add);
75             }
76         }
77     }
78     else
79     {
80         WarningIn("setToPoint::combine(topoSet&, const bool)")
81             << "Point set named " << setName_ << " is empty" << endl;
82     }
86 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
88 // Construct from components
89 Foam::setToPoint::setToPoint
91     const polyMesh& mesh,
92     const word& setName
95     topoSetSource(mesh),
96     setName_(setName)
100 // Construct from dictionary
101 Foam::setToPoint::setToPoint
103     const polyMesh& mesh,
104     const dictionary& dict
107     topoSetSource(mesh),
108     setName_(dict.lookup("name"))
112 // Construct from Istream
113 Foam::setToPoint::setToPoint
115     const polyMesh& mesh,
116     Istream& is
119     topoSetSource(mesh),
120     setName_(checkIs(is))
124 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
126 Foam::setToPoint::~setToPoint()
130 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
132 void Foam::setToPoint::applyToSet
134     const topoSetSource::setAction action,
135     topoSet& set
136 ) const
138     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
139     {
140         Info<< "    Adding all points of pointSet " << setName_ << " ..."
141             << endl;
143         combine(set, true);
144     }
145     else if (action == topoSetSource::DELETE)
146     {
147         Info<< "    Removing all points of pointSet " << setName_ << " ..."
148             << endl;
150         combine(set, false);
151     }
155 // ************************************************************************* //