OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "faceToPoint.H"
00030 #include "polyMesh.H"
00031 #include "faceSet.H"
00032 
00033 #include "addToRunTimeSelectionTable.H"
00034 
00035 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00036 
00037 namespace Foam
00038 {
00039 
00040 defineTypeNameAndDebug(faceToPoint, 0);
00041 
00042 addToRunTimeSelectionTable(topoSetSource, faceToPoint, word);
00043 
00044 addToRunTimeSelectionTable(topoSetSource, faceToPoint, istream);
00045 
00046 }
00047 
00048 
00049 Foam::topoSetSource::addToUsageTable Foam::faceToPoint::usage_
00050 (
00051     faceToPoint::typeName,
00052     "\n    Usage: faceToPoint <faceSet> all\n\n"
00053     "    Select all points of faces in the faceSet\n\n"
00054 );
00055 
00056 template<>
00057 const char* Foam::NamedEnum<Foam::faceToPoint::faceAction, 1>::names[] =
00058 {
00059     "all"
00060 };
00061 
00062 const Foam::NamedEnum<Foam::faceToPoint::faceAction, 1>
00063     Foam::faceToPoint::faceActionNames_;
00064 
00065 
00066 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00067 
00068 void Foam::faceToPoint::combine(topoSet& set, const bool add) const
00069 {
00070     // Load the set
00071     faceSet loadedSet(mesh_, setName_);
00072 
00073     // Add all points from faces in loadedSet
00074     for
00075     (
00076         faceSet::const_iterator iter = loadedSet.begin();
00077         iter != loadedSet.end();
00078         ++iter
00079     )
00080     {
00081         const face& f = mesh_.faces()[iter.key()];
00082 
00083         forAll(f, fp)
00084         {
00085             addOrDelete(set, f[fp], add);
00086         }
00087     }
00088 }
00089 
00090 
00091 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00092 
00093 // Construct from components
00094 Foam::faceToPoint::faceToPoint
00095 (
00096     const polyMesh& mesh,
00097     const word& setName,
00098     const faceAction option
00099 )
00100 :
00101     topoSetSource(mesh),
00102     setName_(setName),
00103     option_(option)
00104 {}
00105 
00106 
00107 // Construct from dictionary
00108 Foam::faceToPoint::faceToPoint
00109 (
00110     const polyMesh& mesh,
00111     const dictionary& dict          
00112 )
00113 :
00114     topoSetSource(mesh),
00115     setName_(dict.lookup("set")),
00116     option_(faceActionNames_.read(dict.lookup("option")))
00117 {}
00118 
00119 
00120 // Construct from Istream
00121 Foam::faceToPoint::faceToPoint
00122 (
00123     const polyMesh& mesh,
00124     Istream& is
00125 )
00126 :
00127     topoSetSource(mesh),
00128     setName_(checkIs(is)),
00129     option_(faceActionNames_.read(checkIs(is)))
00130 {}
00131 
00132 
00133 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00134 
00135 Foam::faceToPoint::~faceToPoint()
00136 {}
00137 
00138 
00139 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00140 
00141 void Foam::faceToPoint::applyToSet
00142 (
00143     const topoSetSource::setAction action,
00144     topoSet& set
00145 ) const
00146 {
00147     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00148     {
00149         Info<< "    Adding points from face in faceSet " << setName_
00150             << " ..." << endl;
00151 
00152         combine(set, true);
00153     }
00154     else if (action == topoSetSource::DELETE)
00155     {
00156         Info<< "    Removing points from face in faceSet " << setName_
00157             << " ..." << endl;
00158 
00159         combine(set, false);
00160     }
00161 }
00162 
00163 
00164 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd