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

cellToPoint.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 "cellToPoint.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <meshTools/cellSet.H>
00029 
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 defineTypeNameAndDebug(cellToPoint, 0);
00038 
00039 addToRunTimeSelectionTable(topoSetSource, cellToPoint, word);
00040 
00041 addToRunTimeSelectionTable(topoSetSource, cellToPoint, istream);
00042 
00043 }
00044 
00045 
00046 Foam::topoSetSource::addToUsageTable Foam::cellToPoint::usage_
00047 (
00048     cellToPoint::typeName,
00049     "\n    Usage: cellToPoint <cellSet> all\n\n"
00050     "    Select all points of cells in the cellSet\n\n"
00051 );
00052 
00053 template<>
00054 const char* Foam::NamedEnum<Foam::cellToPoint::cellAction, 1>::names[] =
00055 {
00056     "all"
00057 };
00058 
00059 const Foam::NamedEnum<Foam::cellToPoint::cellAction, 1>
00060     Foam::cellToPoint::cellActionNames_;
00061 
00062 
00063 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00064 
00065 void Foam::cellToPoint::combine(topoSet& set, const bool add) const
00066 {
00067     // Load the set
00068     cellSet loadedSet(mesh_, setName_);
00069 
00070     // Add all point from cells in loadedSet
00071     for
00072     (
00073         cellSet::const_iterator iter = loadedSet.begin();
00074         iter != loadedSet.end();
00075         ++iter
00076     )
00077     {
00078         label cellI = iter.key();
00079 
00080         const labelList& cFaces = mesh_.cells()[cellI];
00081 
00082         forAll(cFaces, cFaceI)
00083         {
00084             const face& f = mesh_.faces()[cFaces[cFaceI]];
00085 
00086             forAll(f, fp)
00087             {
00088                 addOrDelete(set, f[fp], add);
00089             }
00090         }
00091     }
00092 }
00093 
00094 
00095 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00096 
00097 // Construct from components
00098 Foam::cellToPoint::cellToPoint
00099 (
00100     const polyMesh& mesh,
00101     const word& setName,
00102     const cellAction option
00103 )
00104 :
00105     topoSetSource(mesh),
00106     setName_(setName),
00107     option_(option)
00108 {}
00109 
00110 
00111 // Construct from dictionary
00112 Foam::cellToPoint::cellToPoint
00113 (
00114     const polyMesh& mesh,
00115     const dictionary& dict
00116 )
00117 :
00118     topoSetSource(mesh),
00119     setName_(dict.lookup("set")),
00120     option_(cellActionNames_.read(dict.lookup("option")))
00121 {}
00122 
00123 
00124 // Construct from Istream
00125 Foam::cellToPoint::cellToPoint
00126 (
00127     const polyMesh& mesh,
00128     Istream& is
00129 )
00130 :
00131     topoSetSource(mesh),
00132     setName_(checkIs(is)),
00133     option_(cellActionNames_.read(checkIs(is)))
00134 {}
00135 
00136 
00137 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00138 
00139 Foam::cellToPoint::~cellToPoint()
00140 {}
00141 
00142 
00143 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00144 
00145 void Foam::cellToPoint::applyToSet
00146 (
00147     const topoSetSource::setAction action,
00148     topoSet& set
00149 ) const
00150 {
00151     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00152     {
00153         Info<< "    Adding from " << setName_ << " ..." << endl;
00154 
00155         combine(set, true);
00156     }
00157     else if (action == topoSetSource::DELETE)
00158     {
00159         Info<< "    Removing from " << setName_ << " ..." << endl;
00160 
00161         combine(set, false);
00162     }
00163 }
00164 
00165 
00166 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines