fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / meshTools / sets / topoSetSource / topoSetSource.C
blob0f51d5c870377bcb086bdb55b6e971b8cbfd5cab
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 \*---------------------------------------------------------------------------*/
27 #include "topoSetSource.H"
28 #include "polyMesh.H"
29 #include "topoSet.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 namespace Foam
36 defineTypeNameAndDebug(topoSetSource, 0);
37 defineRunTimeSelectionTable(topoSetSource, word);
38 defineRunTimeSelectionTable(topoSetSource, istream);
40 // Construct named object from dictionary
41 autoPtr<topoSetSource> topoSetSource::New
43     const word& topoSetSourceType,
44     const polyMesh& mesh,
45     const dictionary& dict
48     wordConstructorTable::iterator cstrIter =
49         wordConstructorTablePtr_
50             ->find(topoSetSourceType);
52     if (cstrIter == wordConstructorTablePtr_->end())
53     {
54         FatalErrorIn
55         (
56             "topoSetSource::New(const word&, "
57             "const polyMesh&, const dictionary&)"
58         )   << "Unknown topoSetSource type " << topoSetSourceType
59             << endl << endl
60             << "Valid topoSetSource types : " << endl
61             << wordConstructorTablePtr_->toc()
62             << exit(FatalError);
63     }
65     return autoPtr<topoSetSource>(cstrIter()(mesh, dict));
69 // Construct named object from Istream
70 autoPtr<topoSetSource> topoSetSource::New
72     const word& topoSetSourceType,
73     const polyMesh& mesh,
74     Istream& is
77     istreamConstructorTable::iterator cstrIter =
78         istreamConstructorTablePtr_
79             ->find(topoSetSourceType);
81     if (cstrIter == istreamConstructorTablePtr_->end())
82     {
83         FatalErrorIn
84         (
85             "topoSetSource::New(const word&, "
86             "const polyMesh&, Istream&)"
87         )   << "Unknown topoSetSource type " << topoSetSourceType
88             << endl << endl
89             << "Valid topoSetSource types : " << endl
90             << istreamConstructorTablePtr_->toc()
91             << exit(FatalError);
92     }
94     return autoPtr<topoSetSource>(cstrIter()(mesh, is));
98 } // End namespace Foam
101 Foam::HashTable<Foam::string>* Foam::topoSetSource::usageTablePtr_ = NULL;
103 template<>
104 const char* Foam::NamedEnum<Foam::topoSetSource::setAction, 8>::names[] =
106     "clear",
107     "new",
108     "invert",
109     "add",
110     "delete",
111     "subset",
112     "list",
113     "remove"
117 const Foam::NamedEnum<Foam::topoSetSource::setAction, 8>
118     Foam::topoSetSource::actionNames_;
121 const Foam::string Foam::topoSetSource::illegalSource_
123     "Illegal topoSetSource name"
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 // Construct from components
166 Foam::topoSetSource::topoSetSource(const polyMesh& mesh)
168     mesh_(mesh)
172 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
174 Foam::topoSetSource::~topoSetSource()
178 // ************************************************************************* //