initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / sets / topoSetSource / topoSetSource.C
blob199c47203e97a89eec024d330cad4a3c01a792a1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
27 \*---------------------------------------------------------------------------*/
29 #include "topoSetSource.H"
30 #include "polyMesh.H"
31 #include "topoSet.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 namespace Foam
38 defineTypeNameAndDebug(topoSetSource, 0);
39 defineRunTimeSelectionTable(topoSetSource, word);
40 defineRunTimeSelectionTable(topoSetSource, istream);
42 // Construct named object from dictionary
43 autoPtr<topoSetSource> topoSetSource::New
45     const word& topoSetSourceType,
46     const polyMesh& mesh,
47     const dictionary& dict
50     wordConstructorTable::iterator cstrIter =
51         wordConstructorTablePtr_
52             ->find(topoSetSourceType);
54     if (cstrIter == wordConstructorTablePtr_->end())
55     {
56         FatalErrorIn
57         (
58             "topoSetSource::New(const word&, "
59             "const polyMesh&, const dictionary&)"
60         )   << "Unknown topoSetSource type " << topoSetSourceType
61             << endl << endl
62             << "Valid topoSetSource types : " << endl
63             << wordConstructorTablePtr_->toc()
64             << exit(FatalError);
65     }
67     return autoPtr<topoSetSource>(cstrIter()(mesh, dict));
71 // Construct named object from Istream
72 autoPtr<topoSetSource> topoSetSource::New
74     const word& topoSetSourceType,
75     const polyMesh& mesh,
76     Istream& is
79     istreamConstructorTable::iterator cstrIter =
80         istreamConstructorTablePtr_
81             ->find(topoSetSourceType);
83     if (cstrIter == istreamConstructorTablePtr_->end())
84     {
85         FatalErrorIn
86         (
87             "topoSetSource::New(const word&, "
88             "const polyMesh&, Istream&)"
89         )   << "Unknown topoSetSource type " << topoSetSourceType
90             << endl << endl
91             << "Valid topoSetSource types : " << endl
92             << istreamConstructorTablePtr_->toc()
93             << exit(FatalError);
94     }
96     return autoPtr<topoSetSource>(cstrIter()(mesh, is));
100 } // End namespace Foam
103 Foam::HashTable<Foam::string>* Foam::topoSetSource::usageTablePtr_ = NULL;
105 template<>
106 const char* Foam::NamedEnum<Foam::topoSetSource::setAction, 7>::names[] =
108     "clear",
109     "new",
110     "invert",
111     "add",
112     "delete",
113     "subset",
114     "list"
118 const Foam::NamedEnum<Foam::topoSetSource::setAction, 7>
119     Foam::topoSetSource::actionNames_;
122 const Foam::string Foam::topoSetSource::illegalSource_
124     "Illegal topoSetSource name"
128 Foam::Istream& Foam::topoSetSource::checkIs(Istream& is)
130     if (is.good() && !is.eof())
131     {
132         return is;
133     }
134     else
135     {
136         FatalErrorIn("cellToFace::cellToFace") << "Istream not good"
137             << exit(FatalError);
139         return is;
140     }
144 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
146 void Foam::topoSetSource::addOrDelete
148     topoSet& set,
149     const label cellI,
150     const bool add
151 ) const
153     if (add)
154     {
155         set.insert(cellI);
156     }
157     else
158     {
159         set.erase(cellI);
160     }
164 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
166 // Construct from components
167 Foam::topoSetSource::topoSetSource(const polyMesh& mesh)
169     mesh_(mesh)
173 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
175 Foam::topoSetSource::~topoSetSource()
179 // ************************************************************************* //