FreeFOAM The Cross-Platform CFD Toolkit
basicSource.H
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) 2010-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 Class
25  Foam::basicSource
26 
27 Description
28  Basic source abtract class
29 
30  Sources described by:
31 
32  source1
33  {
34  typeModel actuationDiskSource; // explicitSource
35  active on; // on/off switch
36  timeStart 0.0; // start time
37  duration 1000.0; // duration
38  selectionMode cellSet; // cellSet // points //cellZone
39  cellSet c0; // cellSet name
40 
41  actuationDiskSourceCoeffs
42  {
43  diskDir (-1 0 0); // orientation of the disk
44  Cp 0.53; // Cp
45  Ct 0.58; // Ct
46  diskArea 40; // disk area
47  }
48  }
49 
50  source2
51  {
52  typeModel explicitSource;
53  active on;
54  timeStart 0.0;
55  duration 1000.0;
56  selectionMode points;
57  cellSet c0;
58 
59  explicitSourceCoeffs
60  {
61  points // list of points when selectionMode = points
62  (
63  (-0.088 0.007 -0.02)
64  (-0.028 0.007 -0.02)
65  );
66  volumeMode specific; //absolute
67  fieldData //field data
68  {
69  k 30.7;
70  epsilon 1.5;
71  }
72  }
73  }
74 
75 SourceFiles
76  basicSource.C
77  basicSourceIO.C
78 
79 \*---------------------------------------------------------------------------*/
80 
81 #ifndef basicSource_H
82 #define basicSource_H
83 
85 #include <meshTools/cellSet.H>
88 #include <OpenFOAM/autoPtr.H>
90 
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93 namespace Foam
94 {
95 
96 class fvMesh;
97 
98 /*---------------------------------------------------------------------------*\
99  Class basicSource Declaration
100 \*---------------------------------------------------------------------------*/
101 
103 {
104 public:
105 
106  // Public data
107 
108  //- Enumeration for selection mode types
110  {
115  };
116 
117  //- Word list of selection mode type names
119 
120 
121 protected:
122 
123  // Protected data
124 
125  //- Source name
127 
128  //- Reference to the mesh database
129  const fvMesh& mesh_;
130 
131  //- Dictionary containing the data of the source
133 
134  //- Source active flag
135  bool active_;
136 
137  //- Time start
138  scalar timeStart_;
139 
140  //- Duration
141  scalar duration_;
142 
143  //- Cell selection mode
145 
146  //- Name of cell set for "cellSet" and "cellZone" selectionMode
148 
149  //- Set of cells to apply source to
151 
152  //- Sum of cell volumes
153  scalar V_;
154 
155 
156  // Protected functions
157 
158  //- Helper function to convert from a word to a selectionModeType
159  selectionModeType wordToSelectionModeType(const word& smtName) const;
160 
161  //- Helper function to convert from a selectionModeType to a word
162  word selectionModeTypeToWord(const selectionModeType& smtType) const;
163 
164  //- Set the cellSet or points selection
165  void setSelection(const dictionary& dict);
166 
167  //- Set the cell set based on the user input selection mode
168  void setCellSet();
169 
170 
171 public:
172 
173  //- Runtime type information
174  TypeName("basicSource");
175 
176 
177  // Declare run-time constructor selection table
178 
180  (
181  autoPtr,
182  basicSource,
183  dictionary,
184  (
185  const word& name,
186  const dictionary& dict,
187  const fvMesh& mesh
188  ),
189  (name, dict, mesh)
190  );
191 
192 
193  // Constructors
194 
195  //- Construct from components
197  (
198  const word& name,
199  const dictionary& dict,
200  const fvMesh& mesh
201  );
202 
203  //- Return clone
205  {
207  (
208  "autoPtr<basicSource> clone() const"
209  );
210  return autoPtr<basicSource>(NULL);
211  }
212 
213  //- Return pointer to new basicSource object created
214  // on the freestore from an Istream
215  class iNew
216  {
217  //- Reference to the mesh database
218  const fvMesh& mesh_;
219  const word& name_;
220 
221  public:
222 
223  iNew
224  (
225  const fvMesh& mesh,
226  const word& name
227  )
228  :
229  mesh_(mesh),
230  name_(name)
231  {}
232 
234  {
235  //const word name(is);
236  const dictionary dict(is);
237 
238  return autoPtr<basicSource>
239  (
241  (
242  name_,
243  dict,
244  mesh_
245  )
246  );
247  }
248  };
249 
250 
251  // Selectors
252 
253  //- Return a reference to the selected basicSource model
255  (
256  const word& name,
257  const dictionary& dict,
258  const fvMesh& mesh
259  );
260 
261 
262  //- Destructor
263  virtual ~basicSource()
264  {}
265 
266 
267  // Member Functions
268 
269  // Access
270 
271  //- Return const access to the source name
272  inline const word& name() const;
273 
274  //- Return const access to the mesh database
275  inline const fvMesh& mesh() const;
276 
277  //- Return dictionay
278  inline const dictionary& dictCoeffs() const;
279 
280  //- Return const access to the source active flag
281  inline bool active() const;
282 
283  //- Return const access to the time start
284  inline scalar timeStart() const;
285 
286  //- Return const access to the duration
287  inline scalar duration() const;
288 
289  //- Return const access to the time end
290  inline scalar timeEnd() const;
291 
292  //- Return const access to the cell selection mode
293  inline const selectionModeType& selectionMode() const;
294 
295  //- Return const access to the name of cell set for "cellSet"
296  // selectionMode
297  inline const word& cellSetName() const;
298 
299  //- Return const access to the total cell volume
300  inline scalar V() const;
301 
302  //- Return const access to the cell set
303  inline const labelList& cells() const;
304 
305 
306  // Edit
307 
308  //- Return access to the source name
309  inline word& name();
310 
311  //- Return access to the source active flag
312  inline bool& active();
313 
314  //- Return access to the time start
315  inline scalar& timeStart();
316 
317  //- Return access to the duration
318  inline scalar& duration();
319 
320  //- Return access to the cell selection mode
322 
323  //- Return access to the list of points for "points" selectionMode
324  inline List<point>& points();
325 
326  //- Return access to the name of cell set for "cellSet"
327  // selectionMode
328  inline word& cellSetName();
329 
330  //- Return access to the total cell volume
331  inline scalar& V();
332 
333  //- Return access to the cell set
334  inline labelList& cells();
335 
336 
337  // Checks
338 
339  //- Is the source active?
340  bool isActive();
341 
342 
343  // Evaluation
344 
345  //- Add all explicit sources
346  virtual void addExplicitSources() = 0;
347 
348  //- Add source to scalar field
349  virtual void addSu(DimensionedField<scalar, volMesh>& field) = 0;
350 
351  //- Add source to vector field
352  virtual void addSu(DimensionedField<vector, volMesh>& field) = 0;
353 
354  //- Add source term to vector fvMatrix
355  virtual void addSu(fvMatrix<vector>& Eqn) = 0;
356 
357  //- Add source term to scalar fvMatrix
358  virtual void addSu(fvMatrix<scalar>& Eqn) = 0;
359 
360 
361  // I-O
362 
363  //- Write the source properties
364  virtual void writeData(Ostream&) const = 0;
365 
366  //- Read source dictionary
367  virtual bool read(const dictionary& dict) = 0;
368 
369 };
370 
371 
372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
373 
374 } // End namespace Foam
375 
376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
377 
378 #include "basicSourceI.H"
379 
380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
381 
382 #endif
383 
384 // ************************************************************************* //