ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / meshTools / sets / topoSetSource / topoSetSource.C
blob809fbac46d2d020b1a4da9f57967a47bfad87644
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "topoSetSource.H"
27 #include "polyMesh.H"
28 #include "topoSet.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTypeNameAndDebug(topoSetSource, 0);
35     defineRunTimeSelectionTable(topoSetSource, word);
36     defineRunTimeSelectionTable(topoSetSource, istream);
38     template<>
39     const char* Foam::NamedEnum
40     <
41         Foam::topoSetSource::setAction,
42         8
43     >::names[] =
44     {
45         "clear",
46         "new",
47         "invert",
48         "add",
49         "delete",
50         "subset",
51         "list",
52         "remove"
53     };
57 Foam::HashTable<Foam::string>* Foam::topoSetSource::usageTablePtr_ = NULL;
60 const Foam::NamedEnum<Foam::topoSetSource::setAction, 8>
61     Foam::topoSetSource::actionNames_;
64 const Foam::string Foam::topoSetSource::illegalSource_
66     "Illegal topoSetSource name"
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 Foam::autoPtr<Foam::topoSetSource> Foam::topoSetSource::New
75     const word& topoSetSourceType,
76     const polyMesh& mesh,
77     const dictionary& dict
80     wordConstructorTable::iterator cstrIter =
81         wordConstructorTablePtr_->find(topoSetSourceType);
83     if (cstrIter == wordConstructorTablePtr_->end())
84     {
85         FatalErrorIn
86         (
87             "topoSetSource::New(const word&, "
88             "const polyMesh&, const dictionary&)"
89         )   << "Unknown topoSetSource type " << topoSetSourceType
90             << endl << endl
91             << "Valid topoSetSource types : " << endl
92             << wordConstructorTablePtr_->sortedToc()
93             << exit(FatalError);
94     }
96     return autoPtr<topoSetSource>(cstrIter()(mesh, dict));
100 Foam::autoPtr<Foam::topoSetSource> Foam::topoSetSource::New
102     const word& topoSetSourceType,
103     const polyMesh& mesh,
104     Istream& is
107     istreamConstructorTable::iterator cstrIter =
108         istreamConstructorTablePtr_->find(topoSetSourceType);
110     if (cstrIter == istreamConstructorTablePtr_->end())
111     {
112         FatalErrorIn
113         (
114             "topoSetSource::New(const word&, "
115             "const polyMesh&, Istream&)"
116         )   << "Unknown topoSetSource type " << topoSetSourceType
117             << endl << endl
118             << "Valid topoSetSource types : " << endl
119             << istreamConstructorTablePtr_->sortedToc()
120             << exit(FatalError);
121     }
123     return autoPtr<topoSetSource>(cstrIter()(mesh, is));
127 Foam::Istream& Foam::topoSetSource::checkIs(Istream& is)
129     if (is.good() && !is.eof())
130     {
131         return is;
132     }
133     else
134     {
135         FatalErrorIn("cellToFace::cellToFace") << "Istream not good"
136             << exit(FatalError);
138         return is;
139     }
143 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
145 void Foam::topoSetSource::addOrDelete
147     topoSet& set,
148     const label cellI,
149     const bool add
150 ) const
152     if (add)
153     {
154         set.insert(cellI);
155     }
156     else
157     {
158         set.erase(cellI);
159     }
163 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
165 Foam::topoSetSource::topoSetSource(const polyMesh& mesh)
167     mesh_(mesh)
171 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
173 Foam::topoSetSource::~topoSetSource()
177 // ************************************************************************* //