FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

faceToPoint.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "faceToPoint.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <meshTools/faceSet.H>
00029 
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 defineTypeNameAndDebug(faceToPoint, 0);
00038 
00039 addToRunTimeSelectionTable(topoSetSource, faceToPoint, word);
00040 
00041 addToRunTimeSelectionTable(topoSetSource, faceToPoint, istream);
00042 
00043 }
00044 
00045 
00046 Foam::topoSetSource::addToUsageTable Foam::faceToPoint::usage_
00047 (
00048     faceToPoint::typeName,
00049     "\n    Usage: faceToPoint <faceSet> all\n\n"
00050     "    Select all points of faces in the faceSet\n\n"
00051 );
00052 
00053 template<>
00054 const char* Foam::NamedEnum<Foam::faceToPoint::faceAction, 1>::names[] =
00055 {
00056     "all"
00057 };
00058 
00059 const Foam::NamedEnum<Foam::faceToPoint::faceAction, 1>
00060     Foam::faceToPoint::faceActionNames_;
00061 
00062 
00063 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00064 
00065 void Foam::faceToPoint::combine(topoSet& set, const bool add) const
00066 {
00067     // Load the set
00068     faceSet loadedSet(mesh_, setName_);
00069 
00070     // Add all points from faces in loadedSet
00071     for
00072     (
00073         faceSet::const_iterator iter = loadedSet.begin();
00074         iter != loadedSet.end();
00075         ++iter
00076     )
00077     {
00078         const face& f = mesh_.faces()[iter.key()];
00079 
00080         forAll(f, fp)
00081         {
00082             addOrDelete(set, f[fp], add);
00083         }
00084     }
00085 }
00086 
00087 
00088 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00089 
00090 // Construct from components
00091 Foam::faceToPoint::faceToPoint
00092 (
00093     const polyMesh& mesh,
00094     const word& setName,
00095     const faceAction option
00096 )
00097 :
00098     topoSetSource(mesh),
00099     setName_(setName),
00100     option_(option)
00101 {}
00102 
00103 
00104 // Construct from dictionary
00105 Foam::faceToPoint::faceToPoint
00106 (
00107     const polyMesh& mesh,
00108     const dictionary& dict
00109 )
00110 :
00111     topoSetSource(mesh),
00112     setName_(dict.lookup("set")),
00113     option_(faceActionNames_.read(dict.lookup("option")))
00114 {}
00115 
00116 
00117 // Construct from Istream
00118 Foam::faceToPoint::faceToPoint
00119 (
00120     const polyMesh& mesh,
00121     Istream& is
00122 )
00123 :
00124     topoSetSource(mesh),
00125     setName_(checkIs(is)),
00126     option_(faceActionNames_.read(checkIs(is)))
00127 {}
00128 
00129 
00130 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00131 
00132 Foam::faceToPoint::~faceToPoint()
00133 {}
00134 
00135 
00136 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00137 
00138 void Foam::faceToPoint::applyToSet
00139 (
00140     const topoSetSource::setAction action,
00141     topoSet& set
00142 ) const
00143 {
00144     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00145     {
00146         Info<< "    Adding points from face in faceSet " << setName_
00147             << " ..." << endl;
00148 
00149         combine(set, true);
00150     }
00151     else if (action == topoSetSource::DELETE)
00152     {
00153         Info<< "    Removing points from face in faceSet " << setName_
00154             << " ..." << endl;
00155 
00156         combine(set, false);
00157     }
00158 }
00159 
00160 
00161 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines