FreeFOAM The Cross-Platform CFD Toolkit
fvsPatchField.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) 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 Class
25  Foam::fvsPatchField
26 
27 Description
28  An abstract base class with a fat-interface to all derived classes
29  covering all possible ways in which they might be used.
30 
31  The first level of derivation is to basic patchFields which cover
32  zero-gradient, fixed-gradient, fixed-value and mixed conditions.
33 
34  The next level of derivation covers all the specialised typed with
35  specific evaluation proceedures, particularly with respect to specific
36  fields.
37 
38 SourceFiles
39  fvsPatchField.C
40  newFvsPatchField.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef fvsPatchField_H
45 #define fvsPatchField_H
46 
47 #include <finiteVolume/fvPatch.H>
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of classes
56 
57 class objectRegistry;
58 class dictionary;
59 class fvPatchFieldMapper;
60 class surfaceMesh;
61 
62 
63 // Forward declaration of friend functions and operators
64 
65 template<class Type>
66 class fvsPatchField;
67 
68 template<class Type>
69 Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
70 
71 
72 /*---------------------------------------------------------------------------*\
73  Class patch Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 template<class Type>
78 :
79  public Field<Type>
80 {
81  // Private data
82 
83  //- Reference to patch
84  const fvPatch& patch_;
85 
86  //- Reference to internal field
87  const DimensionedField<Type, surfaceMesh>& internalField_;
88 
89 
90 public:
91 
92  typedef fvPatch Patch;
93 
94 
95  //- Runtime type information
96  TypeName("fvsPatchField");
97 
98  //- Debug switch to disallow the use of
100 
101 
102  // Declare run-time constructor selection tables
103 
105  (
106  tmp,
108  patch,
109  (
110  const fvPatch& p,
112  ),
113  (p, iF)
114  );
115 
117  (
118  tmp,
120  patchMapper,
121  (
122  const fvsPatchField<Type>& ptf,
123  const fvPatch& p,
125  const fvPatchFieldMapper& m
126  ),
127  (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
128  );
129 
131  (
132  tmp,
134  dictionary,
135  (
136  const fvPatch& p,
138  const dictionary& dict
139  ),
140  (p, iF, dict)
141  );
142 
143 
144  // Constructors
145 
146  //- Construct from patch and internal field
148  (
149  const fvPatch&,
151  );
152 
153  //- Construct from patch and internal field and patch field
155  (
156  const fvPatch&,
158  const Field<Type>&
159  );
160 
161  //- Construct from patch, internal field and dictionary
163  (
164  const fvPatch&,
166  const dictionary&
167  );
168 
169  //- Construct by mapping the given fvsPatchField onto a new patch
171  (
172  const fvsPatchField<Type>&,
173  const fvPatch&,
175  const fvPatchFieldMapper&
176  );
177 
178  //- Construct as copy
180 
181  //- Construct and return a clone
182  virtual tmp<fvsPatchField<Type> > clone() const
183  {
184  return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
185  }
186 
187  //- Construct as copy setting internal field reference
189  (
190  const fvsPatchField<Type>&,
192  );
193 
194  //- Construct and return a clone setting internal field reference
196  (
198  ) const
199  {
200  return tmp<fvsPatchField<Type> >
201  (
202  new fvsPatchField<Type>(*this, iF)
203  );
204  }
205 
206 
207  // Selectors
208 
209  //- Return a pointer to a new patchField created on freestore given
210  // patch and internal field
211  // (does not set the patch field values)
213  (
214  const word&,
215  const fvPatch&,
217  );
218 
219  //- Return a pointer to a new patchField created on freestore from
220  // a given fvsPatchField mapped onto a new patch
222  (
223  const fvsPatchField<Type>&,
224  const fvPatch&,
226  const fvPatchFieldMapper&
227  );
228 
229  //- Return a pointer to a new patchField created on freestore
230  // from dictionary
232  (
233  const fvPatch&,
235  const dictionary&
236  );
237 
238  //- Return a pointer to a new calculatedFvsPatchField created on
239  // freestore without setting patchField values
240  template<class Type2>
242  (
243  const fvsPatchField<Type2>&
244  );
245 
246 
247  // Destructor
248 
250  {}
251 
252 
253  // Member functions
254 
255  // Access
256 
257  //- Return local objectRegistry
258  const objectRegistry& db() const;
259 
260  //- Return patch
261  const fvPatch& patch() const
262  {
263  return patch_;
264  }
265 
266  //- Return dimensioned internal field reference
269  {
270  return internalField_;
271  }
272 
273  //- Return internal field reference
274  const Field<Type>& internalField() const
275  {
276  return internalField_;
277  }
278 
279  //- Return the type of the calculated for of fvsPatchField
280  static const word& calculatedType();
281 
282  //- Return true if this patch field fixes a value.
283  // Needed to check if a level has to be specified while solving
284  // Poissons equations.
285  virtual bool fixesValue() const
286  {
287  return false;
288  }
289 
290  //- Return true if this patch field is coupled
291  virtual bool coupled() const
292  {
293  return false;
294  }
295 
296 
297  // Mapping functions
298 
299  //- Map (and resize as needed) from self given a mapping object
300  virtual void autoMap
301  (
302  const fvPatchFieldMapper&
303  );
304 
305  //- Reverse map the given fvsPatchField onto this fvsPatchField
306  virtual void rmap
307  (
308  const fvsPatchField<Type>&,
309  const labelList&
310  );
311 
312 
313  //- Write
314  virtual void write(Ostream&) const;
315 
316 
317  // Check
318 
319  //- Check fvsPatchField<Type> against given fvsPatchField<Type>
320  void check(const fvsPatchField<Type>&) const;
321 
322 
323  // Member operators
324 
325  virtual void operator=(const UList<Type>&);
326 
327  virtual void operator=(const fvsPatchField<Type>&);
328  virtual void operator+=(const fvsPatchField<Type>&);
329  virtual void operator-=(const fvsPatchField<Type>&);
330  virtual void operator*=(const fvsPatchField<scalar>&);
331  virtual void operator/=(const fvsPatchField<scalar>&);
332 
333  virtual void operator+=(const Field<Type>&);
334  virtual void operator-=(const Field<Type>&);
335 
336  virtual void operator*=(const Field<scalar>&);
337  virtual void operator/=(const Field<scalar>&);
338 
339  virtual void operator=(const Type&);
340  virtual void operator+=(const Type&);
341  virtual void operator-=(const Type&);
342  virtual void operator*=(const scalar);
343  virtual void operator/=(const scalar);
344 
345 
346  // Force an assignment irrespective of form of patch
347 
348  virtual void operator==(const fvsPatchField<Type>&);
349  virtual void operator==(const Field<Type>&);
350  virtual void operator==(const Type&);
351 
352 
353  // Ostream operator
354 
355  friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
356 };
357 
358 
359 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360 
361 } // End namespace Foam
362 
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 
365 #ifdef NoRepository
366 # include "fvsPatchField.C"
368 #endif
369 
370 
371 #define makeFvsPatchTypeFieldTypeName(type) \
372  \
373 defineNamedTemplateTypeNameAndDebug(type, 0);
374 
375 #define makeFvsPatchFieldsTypeName(type) \
376  \
377 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField); \
378 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField); \
379 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField); \
380 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField); \
381 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
382 
383 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField) \
384  \
385 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
386  \
387 addToRunTimeSelectionTable \
388 ( \
389  PatchTypeField, typePatchTypeField, patch \
390 ); \
391  \
392 addToRunTimeSelectionTable \
393 ( \
394  PatchTypeField, \
395  typePatchTypeField, \
396  patchMapper \
397 ); \
398  \
399 addToRunTimeSelectionTable \
400 ( \
401  PatchTypeField, typePatchTypeField, dictionary \
402 );
403 
404 
405 #define makeFvsPatchFields(type) \
406  \
407 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField); \
408 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField); \
409 makeFvsPatchTypeField \
410 ( \
411  fvsPatchSphericalTensorField, \
412  type##FvsPatchSphericalTensorField \
413 ); \
414 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
415 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
416 
417 
418 #define makeFvsPatchTypeFieldTypedefs(type) \
419  \
420 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField; \
421 typedef type##FvsPatchField<vector> type##FvsPatchVectorField; \
422 typedef type##FvsPatchField<sphericalTensor> \
423  type##FvsPatchSphericalTensorField; \
424 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField; \
425 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
426 
427 
428 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
429 
430 #endif
431 
432 // ************************ vim: set sw=4 sts=4 et: ************************ //