topoSetSource.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
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 Class
25  Foam::topoSetSource
26 
27 Description
28  Base class of a source for a topoSet.
29 
30  Implementer has to modify the given set (see applyToSet) according to
31  its function and the setAction (one of add/delete/new)
32 
33 SourceFiles
34  topoSetSource.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef topoSetSource_H
39 #define topoSetSource_H
40 
41 #include "pointField.H"
42 #include "word.H"
43 #include "labelList.H"
44 #include "faceList.H"
45 #include "typeInfo.H"
46 #include "runTimeSelectionTables.H"
47 #include "autoPtr.H"
48 #include "NamedEnum.H"
49 #include "HashTable.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward declaration of classes
57 class polyMesh;
58 class topoSet;
59 
60 /*---------------------------------------------------------------------------*\
61  Class topoSetSource Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class topoSetSource
65 {
66 public:
67 
68  // Public data types
69 
70  //- Enumeration defining the types of sources
71  enum sourceType
72  {
76 
80  };
81 
82  //- Enumeration defining the valid actions
83  enum setAction
84  {
86  NEW,
88  ADD,
91  LIST,
93  };
94 
95 
96 protected:
97 
98  // Protected data
99 
100  const polyMesh& mesh_;
101 
102  //- Add (if bool) celli to set or delete celli from set.
103  void addOrDelete(topoSet& set, const label celli, const bool) const;
104 
105 
106 private:
107 
108  static const NamedEnum<setAction, 8> actionNames_;
109 
110  static const string illegalSource_;
111 
112 
113 public:
114 
115  //- Runtime type information
116  TypeName("topoSetSource");
117 
118 
119  // Static Functions
120 
121  //- Convert string to action
122  static setAction toAction(const word& actionName)
123  {
124  return actionNames_[actionName];
125  }
126 
127 
128  // Declare run-time constructor selection table
129 
130  // For the dictionary constructor
132  (
133  autoPtr,
135  word,
136  (
137  const polyMesh& mesh,
138  const dictionary& dict
139  ),
140  (mesh, dict)
141  );
142 
143 
144  //- Class used for the read-construction of
145  // PtrLists of topoSetSource
146  class iNew
147  {
148  const polyMesh& mesh_;
149 
150  public:
151 
152  iNew(const polyMesh& mesh)
153  :
154  mesh_(mesh)
155  {}
156 
158  {
159  word topoSetSourceType(is);
160  dictionary dict(is);
161  return topoSetSource::New(topoSetSourceType, mesh_, dict);
162  }
163  };
164 
165 
166  // Constructors
167 
168  //- Construct from components
169  topoSetSource(const polyMesh& mesh);
170 
171  //- Disallow default bitwise copy construction
172  topoSetSource(const topoSetSource&) = delete;
173 
174  //- Clone
176  {
178  return autoPtr<topoSetSource>(nullptr);
179  }
180 
181 
182  // Selectors
183 
184  //- Return a reference to the selected topoSetSource
186  (
187  const word& topoSetSourceType,
188  const polyMesh& mesh,
189  const dictionary& dict
190  );
191 
192 
193  //- Destructor
194  virtual ~topoSetSource();
195 
196 
197  // Member Functions
198 
199  const polyMesh& mesh() const
200  {
201  return mesh_;
202  }
203 
204 
205  // Member Functions
206 
207  virtual sourceType setType() const = 0;
208 
209  virtual void applyToSet(const setAction action, topoSet&) const = 0;
210 
211 
212  // Member Operators
213 
214  //- Disallow default bitwise assignment
215  void operator=(const topoSetSource&) = delete;
216 };
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class used for the read-construction of.
autoPtr< topoSetSource > operator()(Istream &is) const
iNew(const polyMesh &mesh)
Base class of a source for a topoSet.
Definition: topoSetSource.H:64
autoPtr< topoSetSource > clone() const
Clone.
virtual sourceType setType() const =0
void addOrDelete(topoSet &set, const label celli, const bool) const
Add (if bool) celli to set or delete celli from set.
Definition: topoSetSource.C:96
sourceType
Enumeration defining the types of sources.
Definition: topoSetSource.H:71
static setAction toAction(const word &actionName)
Convert string to action.
virtual void applyToSet(const setAction action, topoSet &) const =0
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:83
void operator=(const topoSetSource &)=delete
Disallow default bitwise assignment.
declareRunTimeSelectionTable(autoPtr, topoSetSource, word,(const polyMesh &mesh, const dictionary &dict),(mesh, dict))
topoSetSource(const polyMesh &mesh)
Construct from components.
virtual ~topoSetSource()
Destructor.
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
Definition: topoSetSource.C:70
TypeName("topoSetSource")
Runtime type information.
const polyMesh & mesh_
Definition: topoSetSource.H:99
const polyMesh & mesh() const
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:65
A class for handling words, derived from string.
Definition: word.H:62
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Macros to ease declaration of run-time selection tables.
dictionary dict