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

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