FreeFOAM The Cross-Platform CFD Toolkit
topoSetSource.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "topoSetSource.H"
27 #include <OpenFOAM/polyMesh.H>
28 #include <meshTools/topoSet.H>
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 defineTypeNameAndDebug(topoSetSource, 0);
36 defineRunTimeSelectionTable(topoSetSource, word);
37 defineRunTimeSelectionTable(topoSetSource, istream);
38 
39 // Construct named object from dictionary
40 autoPtr<topoSetSource> topoSetSource::New
41 (
42  const word& topoSetSourceType,
43  const polyMesh& mesh,
44  const dictionary& dict
45 )
46 {
47  wordConstructorTable::iterator cstrIter =
48  wordConstructorTablePtr_
49  ->find(topoSetSourceType);
50 
51  if (cstrIter == wordConstructorTablePtr_->end())
52  {
54  (
55  "topoSetSource::New(const word&, "
56  "const polyMesh&, const dictionary&)"
57  ) << "Unknown topoSetSource type " << topoSetSourceType
58  << endl << endl
59  << "Valid topoSetSource types : " << endl
60  << wordConstructorTablePtr_->sortedToc()
61  << exit(FatalError);
62  }
63 
64  return autoPtr<topoSetSource>(cstrIter()(mesh, dict));
65 }
66 
67 
68 // Construct named object from Istream
70 (
71  const word& topoSetSourceType,
72  const polyMesh& mesh,
73  Istream& is
74 )
75 {
76  istreamConstructorTable::iterator cstrIter =
77  istreamConstructorTablePtr_
78  ->find(topoSetSourceType);
79 
80  if (cstrIter == istreamConstructorTablePtr_->end())
81  {
83  (
84  "topoSetSource::New(const word&, "
85  "const polyMesh&, Istream&)"
86  ) << "Unknown topoSetSource type " << topoSetSourceType
87  << endl << endl
88  << "Valid topoSetSource types : " << endl
89  << istreamConstructorTablePtr_->sortedToc()
90  << exit(FatalError);
91  }
92 
93  return autoPtr<topoSetSource>(cstrIter()(mesh, is));
94 }
95 
96 
97 } // End namespace Foam
98 
99 
101 
102 template<>
104 {
105  "clear",
106  "new",
107  "invert",
108  "add",
109  "delete",
110  "subset",
111  "list",
112  "remove"
113 };
114 
115 
117  Foam::topoSetSource::actionNames_;
118 
119 
120 const Foam::string Foam::topoSetSource::illegalSource_
121 (
122  "Illegal topoSetSource name"
123 );
124 
125 
127 {
128  if (is.good() && !is.eof())
129  {
130  return is;
131  }
132  else
133  {
134  FatalErrorIn("cellToFace::cellToFace") << "Istream not good"
135  << exit(FatalError);
136 
137  return is;
138  }
139 }
140 
141 
142 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
143 
145 (
146  topoSet& set,
147  const label cellI,
148  const bool add
149 ) const
150 {
151  if (add)
152  {
153  set.insert(cellI);
154  }
155  else
156  {
157  set.erase(cellI);
158  }
159 }
160 
161 
162 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
163 
164 // Construct from components
165 Foam::topoSetSource::topoSetSource(const polyMesh& mesh)
166 :
167  mesh_(mesh)
168 {}
169 
170 
171 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
172 
174 {}
175 
176 
177 // ************************ vim: set sw=4 sts=4 et: ************************ //