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

topoSetSource.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 "topoSetSource.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <meshTools/topoSet.H>
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 defineTypeNameAndDebug(topoSetSource, 0);
00036 defineRunTimeSelectionTable(topoSetSource, word);
00037 defineRunTimeSelectionTable(topoSetSource, istream);
00038 
00039 // Construct named object from dictionary
00040 autoPtr<topoSetSource> topoSetSource::New
00041 (
00042     const word& topoSetSourceType,
00043     const polyMesh& mesh,
00044     const dictionary& dict
00045 )
00046 {
00047     wordConstructorTable::iterator cstrIter =
00048         wordConstructorTablePtr_
00049             ->find(topoSetSourceType);
00050 
00051     if (cstrIter == wordConstructorTablePtr_->end())
00052     {
00053         FatalErrorIn
00054         (
00055             "topoSetSource::New(const word&, "
00056             "const polyMesh&, const dictionary&)"
00057         )   << "Unknown topoSetSource type " << topoSetSourceType
00058             << endl << endl
00059             << "Valid topoSetSource types : " << endl
00060             << wordConstructorTablePtr_->sortedToc()
00061             << exit(FatalError);
00062     }
00063 
00064     return autoPtr<topoSetSource>(cstrIter()(mesh, dict));
00065 }
00066 
00067 
00068 // Construct named object from Istream
00069 autoPtr<topoSetSource> topoSetSource::New
00070 (
00071     const word& topoSetSourceType,
00072     const polyMesh& mesh,
00073     Istream& is
00074 )
00075 {
00076     istreamConstructorTable::iterator cstrIter =
00077         istreamConstructorTablePtr_
00078             ->find(topoSetSourceType);
00079 
00080     if (cstrIter == istreamConstructorTablePtr_->end())
00081     {
00082         FatalErrorIn
00083         (
00084             "topoSetSource::New(const word&, "
00085             "const polyMesh&, Istream&)"
00086         )   << "Unknown topoSetSource type " << topoSetSourceType
00087             << endl << endl
00088             << "Valid topoSetSource types : " << endl
00089             << istreamConstructorTablePtr_->sortedToc()
00090             << exit(FatalError);
00091     }
00092 
00093     return autoPtr<topoSetSource>(cstrIter()(mesh, is));
00094 }
00095 
00096 
00097 } // End namespace Foam
00098 
00099 
00100 Foam::HashTable<Foam::string>* Foam::topoSetSource::usageTablePtr_ = NULL;
00101 
00102 template<>
00103 const char* Foam::NamedEnum<Foam::topoSetSource::setAction, 8>::names[] =
00104 {
00105     "clear",
00106     "new",
00107     "invert",
00108     "add",
00109     "delete",
00110     "subset",
00111     "list",
00112     "remove"
00113 };
00114 
00115 
00116 const Foam::NamedEnum<Foam::topoSetSource::setAction, 8>
00117     Foam::topoSetSource::actionNames_;
00118 
00119 
00120 const Foam::string Foam::topoSetSource::illegalSource_
00121 (
00122     "Illegal topoSetSource name"
00123 );
00124 
00125 
00126 Foam::Istream& Foam::topoSetSource::checkIs(Istream& is)
00127 {
00128     if (is.good() && !is.eof())
00129     {
00130         return is;
00131     }
00132     else
00133     {
00134         FatalErrorIn("cellToFace::cellToFace") << "Istream not good"
00135             << exit(FatalError);
00136 
00137         return is;
00138     }
00139 }
00140 
00141 
00142 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00143 
00144 void Foam::topoSetSource::addOrDelete
00145 (
00146     topoSet& set,
00147     const label cellI,
00148     const bool add
00149 ) const
00150 {
00151     if (add)
00152     {
00153         set.insert(cellI);
00154     }
00155     else
00156     {
00157         set.erase(cellI);
00158     }
00159 }
00160 
00161 
00162 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00163 
00164 // Construct from components
00165 Foam::topoSetSource::topoSetSource(const polyMesh& mesh)
00166 :
00167     mesh_(mesh)
00168 {}
00169 
00170 
00171 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00172 
00173 Foam::topoSetSource::~topoSetSource()
00174 {}
00175 
00176 
00177 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines