initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / sets / pointSources / faceToPoint / faceToPoint.C
blob1ae3fb1f66facf495ed78d3197c49b14b3203890
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 "faceToPoint.H"
30 #include "polyMesh.H"
31 #include "faceSet.H"
33 #include "addToRunTimeSelectionTable.H"
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 namespace Foam
40 defineTypeNameAndDebug(faceToPoint, 0);
42 addToRunTimeSelectionTable(topoSetSource, faceToPoint, word);
44 addToRunTimeSelectionTable(topoSetSource, faceToPoint, istream);
49 Foam::topoSetSource::addToUsageTable Foam::faceToPoint::usage_
51     faceToPoint::typeName,
52     "\n    Usage: faceToPoint <faceSet> all\n\n"
53     "    Select all points of faces in the faceSet\n\n"
56 template<>
57 const char* Foam::NamedEnum<Foam::faceToPoint::faceAction, 1>::names[] =
59     "all"
62 const Foam::NamedEnum<Foam::faceToPoint::faceAction, 1>
63     Foam::faceToPoint::faceActionNames_;
66 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
68 void Foam::faceToPoint::combine(topoSet& set, const bool add) const
70     // Load the set
71     faceSet loadedSet(mesh_, setName_);
73     // Add all points from faces in loadedSet
74     for
75     (
76         faceSet::const_iterator iter = loadedSet.begin();
77         iter != loadedSet.end();
78         ++iter
79     )
80     {
81         const face& f = mesh_.faces()[iter.key()];
83         forAll(f, fp)
84         {
85             addOrDelete(set, f[fp], add);
86         }
87     }
91 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
93 // Construct from components
94 Foam::faceToPoint::faceToPoint
96     const polyMesh& mesh,
97     const word& setName,
98     const faceAction option
101     topoSetSource(mesh),
102     setName_(setName),
103     option_(option)
107 // Construct from dictionary
108 Foam::faceToPoint::faceToPoint
110     const polyMesh& mesh,
111     const dictionary& dict          
114     topoSetSource(mesh),
115     setName_(dict.lookup("set")),
116     option_(faceActionNames_.read(dict.lookup("option")))
120 // Construct from Istream
121 Foam::faceToPoint::faceToPoint
123     const polyMesh& mesh,
124     Istream& is
127     topoSetSource(mesh),
128     setName_(checkIs(is)),
129     option_(faceActionNames_.read(checkIs(is)))
133 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
135 Foam::faceToPoint::~faceToPoint()
139 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
141 void Foam::faceToPoint::applyToSet
143     const topoSetSource::setAction action,
144     topoSet& set
145 ) const
147     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
148     {
149         Info<< "    Adding points from face in faceSet " << setName_
150             << " ..." << endl;
152         combine(set, true);
153     }
154     else if (action == topoSetSource::DELETE)
155     {
156         Info<< "    Removing points from face in faceSet " << setName_
157             << " ..." << endl;
159         combine(set, false);
160     }
164 // ************************************************************************* //