FreeFOAM The Cross-Platform CFD Toolkit
pointPatchField.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::pointPatchField
26 
27 Description
28  Abstract base class for point-mesh patch fields.
29 
30  The base-field does not store values as they are part of the
31  "internal field". There are derived classes to store constraint values
32  e.g. fixedValuePointPatchField derived from the generic
33  valuePointPatchField which ensures the values in the "internal field"
34  are reset to the fixed-values by applying the stored values.
35 
36 SourceFiles
37  pointPatchField.C
38  newpointPatchField.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef pointPatchField_H
43 #define pointPatchField_H
44 
45 #include <OpenFOAM/pointPatch.H>
47 #include <OpenFOAM/autoPtr.H>
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward declaration of classes
55 
56 class objectRegistry;
57 class dictionary;
58 class pointPatchFieldMapper;
59 class pointMesh;
60 
61 // Forward declaration of friend functions and operators
62 
63 template<class Type>
64 class pointPatchField;
65 
66 template<class Type>
67 Ostream& operator<<
68 (
69  Ostream&,
70  const pointPatchField<Type>&
71 );
72 
73 
74 /*---------------------------------------------------------------------------*\
75  Class pointPatchField Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 template<class Type>
80 {
81  // Private data
82 
83  //- Reference to patch
84  const pointPatch& patch_;
85 
86  //- Reference to internal field
87  const DimensionedField<Type, pointMesh>& internalField_;
88 
89  //- Update index used so that updateCoeffs is called only once during
90  // the construction of the matrix
91  bool updated_;
92 
93  //- Optional patch type, used to allow specified boundary conditions
94  // to be applied to constraint patches by providing the constraint
95  // patch type as 'patchType'
96  word patchType_;
97 
98 
99 public:
100 
101  typedef pointPatch Patch;
102 
103 
104  //- Runtime type information
105  TypeName("pointPatchField");
106 
107  //- Debug switch to disallow the use of genericPointPatchField
109 
110 
111  // Declare run-time constructor selection tables
112 
114  (
115  autoPtr,
117  pointPatch,
118  (
119  const pointPatch& p,
121  ),
122  (p, iF)
123  );
124 
126  (
127  autoPtr,
129  patchMapper,
130  (
131  const pointPatchField<Type>& ptf,
132  const pointPatch& p,
134  const pointPatchFieldMapper& m
135  ),
136  (dynamic_cast<const pointPatchFieldType&>(ptf), p, iF, m)
137  );
138 
140  (
141  autoPtr,
143  dictionary,
144  (
145  const pointPatch& p,
147  const dictionary& dict
148  ),
149  (p, iF, dict)
150  );
151 
152 
153  // Constructors
154 
155  //- Construct from patch and internal field
157  (
158  const pointPatch&,
160  );
161 
162  //- Construct from patch, internal field and dictionary
164  (
165  const pointPatch&,
167  const dictionary&
168  );
169 
170  //- Construct as copy
172 
173  //- Construct and return a clone
174  virtual autoPtr<pointPatchField<Type> > clone() const = 0;
175 
176  //- Construct as copy setting internal field reference
178  (
179  const pointPatchField<Type>&,
181  );
182 
183  //- Construct and return a clone setting internal field reference
185  (
187  ) const = 0;
188 
189 
190  // Selectors
191 
192  //- Return a pointer to a new patchField created on freestore given
193  // patch and internal field
194  // (does not set the patch field values)
196  (
197  const word&,
198  const pointPatch&,
200  );
201 
202  //- Return a pointer to a new patchField created on freestore from
203  // a given pointPatchField mapped onto a new patch
205  (
206  const pointPatchField<Type>&,
207  const pointPatch&,
209  const pointPatchFieldMapper&
210  );
211 
212  //- Return a pointer to a new patchField created on freestore
213  // from dictionary
215  (
216  const pointPatch&,
218  const dictionary&
219  );
220 
221 
222  //- Return a pointer to a new CalculatedpointPatchField created on
223  // freestore without setting patchField values
224  template<class Type2>
227  (
229  );
230 
231 
232  // Destructor
233 
235  {}
236 
237 
238  // Member functions
239 
240  // Access
241 
242  //- Return local objectRegistry
243  const objectRegistry& db() const;
244 
245  //- Return size
246  label size() const
247  {
248  return patch().size();
249  }
250 
251  //- Return patch
252  const pointPatch& patch() const
253  {
254  return patch_;
255  }
256 
257  //- Return dimensioned internal field reference
260  {
261  return internalField_;
262  }
263 
264  //- Return internal field reference
265  const Field<Type>& internalField() const
266  {
267  return internalField_;
268  }
269 
270  //- Return true if this patch field is coupled
271  virtual bool coupled() const
272  {
273  return false;
274  }
275 
276  //- Return true if the boundary condition has already been updated
277  bool updated() const
278  {
279  return updated_;
280  }
281 
282  //- Return field created from appropriate internal field values
284 
285  //- Return field created from appropriate internal field values
286  // given internal field reference
287  template<class Type1>
289  (
290  const Field<Type1>& iF
291  ) const;
292 
293  //- Given the internal field and a patch field,
294  // add the patch field to the internal field
295  template<class Type1>
296  void addToInternalField
297  (
298  Field<Type1>& iF,
299  const Field<Type1>& pF
300  ) const;
301 
302  //- Given the internal field and a patch field,
303  // set the patch field in the internal field
304  template<class Type1>
305  void setInInternalField
306  (
307  Field<Type1>& iF,
308  const Field<Type1>& pF,
309  const labelList& meshPoints
310  ) const;
311 
312  //- Given the internal field and a patch field,
313  // set the patch field in the internal field
314  template<class Type1>
315  void setInInternalField
316  (
317  Field<Type1>& iF,
318  const Field<Type1>& pF
319  ) const;
320 
321  //- Return the type of the calculated for of pointPatchField
322  static const word& calculatedType();
323 
324 
325  // Mapping functions
326 
327  //- Map (and resize as needed) from self given a mapping object
328  virtual void autoMap
329  (
330  const pointPatchFieldMapper&
331  )
332  {}
333 
334  //- Reverse map the given pointPatchField onto this pointPatchField
335  virtual void rmap
336  (
337  const pointPatchField<Type>&,
338  const labelList&
339  )
340  {}
341 
342 
343  // Evaluation functions
344 
345  //- Update the coefficients associated with the patch field
346  // Sets Updated to true
347  virtual void updateCoeffs()
348  {
349  updated_ = true;
350  }
351 
352  //- Initialise evaluation of the patch field (do nothing)
353  virtual void initEvaluate
354  (
355  const Pstream::commsTypes commsType=Pstream::blocking
356  )
357  {}
358 
359  //- Evaluate the patch field
360  virtual void evaluate
361  (
362  const Pstream::commsTypes commsType=Pstream::blocking
363  );
364 
365 
366  //- Write
367  virtual void write(Ostream&) const;
368 
369 
370  // Member operators
371 
372  virtual void operator=
373  (
374  const pointPatchField<Type>&
375  )
376  {}
377 
378  virtual void operator+=
379  (
380  const pointPatchField<Type>&
381  )
382  {}
383 
384  virtual void operator-=
385  (
386  const pointPatchField<Type>&
387  )
388  {}
389 
390  virtual void operator*=
391  (
393  )
394  {}
395 
396  virtual void operator/=
397  (
399  )
400  {}
401 
402  virtual void operator=(const Field<Type>&){}
403  virtual void operator+=(const Field<Type>&){}
404  virtual void operator-=(const Field<Type>&){}
405 
406  virtual void operator*=(const Field<scalar>&){}
407  virtual void operator/=(const Field<scalar>&){}
408 
409  virtual void operator=(const Type&){}
410  virtual void operator+=(const Type&){}
411  virtual void operator-=(const Type&){}
412  virtual void operator*=(const scalar){}
413  virtual void operator/=(const scalar){}
414 
415 
416  // Force an assignment irrespective of form of patch
417  // By generic these do nothing unless the patch actually has boundary
418  // values
419 
420  virtual void operator==
421  (
422  const pointPatchField<Type>&
423  )
424  {}
425 
426  virtual void operator==(const Field<Type>&){}
427  virtual void operator==(const Type&){}
428 
429 
430  // Ostream operator
431 
432  friend Ostream& operator<< <Type>
433  (
434  Ostream&,
435  const pointPatchField<Type>&
436  );
437 };
438 
439 
440 // This function is added as a hack to enable simple backward compatability
441 // with verions using referenceLevel in GeometicField
442 template<class Type>
443 const pointPatchField<Type>& operator+
444 (
445  const pointPatchField<Type>& ppf,
446  const Type&
447 )
448 {
449  return ppf;
450 }
451 
452 
453 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
454 
455 } // End namespace Foam
456 
457 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
458 
460 
461 #ifdef NoRepository
462 # include "pointPatchField.C"
464 #endif
465 
466 
467 #define makePointPatchTypeFieldTypeName(type) \
468  \
469 defineNamedTemplateTypeNameAndDebug(type, 0);
470 
471 #define makePointPatchFieldsTypeName(type) \
472  \
473 makePointPatchTypeFieldTypeName(type##PointPatchScalarField); \
474 makePointPatchTypeFieldTypeName(type##PointPatchVectorField); \
475 makePointPatchTypeFieldTypeName(type##PointPatchSphericalTensorField); \
476 makePointPatchTypeFieldTypeName(type##PointPatchSymmTensorField); \
477 makePointPatchTypeFieldTypeName(type##PointPatchTensorField);
478 
479 #define makePointPatchTypeField(PatchTypeField, typePatchTypeField) \
480  \
481 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
482  \
483 addToRunTimeSelectionTable \
484 ( \
485  PatchTypeField, typePatchTypeField, pointPatch \
486 ); \
487  \
488 addToRunTimeSelectionTable \
489 ( \
490  PatchTypeField, \
491  typePatchTypeField, \
492  patchMapper \
493 ); \
494  \
495 addToRunTimeSelectionTable \
496 ( \
497  PatchTypeField, typePatchTypeField, dictionary \
498 );
499 
500 
501 #define makePointPatchFields(type) \
502  \
503 makePointPatchTypeField \
504 ( \
505  pointPatchScalarField, \
506  type##PointPatchScalarField \
507 ); \
508  \
509 makePointPatchTypeField \
510 ( \
511  pointPatchVectorField, \
512  type##PointPatchVectorField \
513 ); \
514  \
515 makePointPatchTypeField \
516 ( \
517  pointPatchSphericalTensorField, \
518  type##PointPatchSphericalTensorField \
519 ); \
520  \
521 makePointPatchTypeField \
522 ( \
523  pointPatchSymmTensorField, \
524  type##PointPatchSymmTensorField \
525 ); \
526  \
527 makePointPatchTypeField \
528 ( \
529  pointPatchTensorField, \
530  type##PointPatchTensorField \
531 );
532 
533 
534 #define makePointPatchFieldTypedefs(type) \
535  \
536 typedef type##PointPatchField<scalar> type##PointPatchScalarField; \
537 typedef type##PointPatchField<vector> type##PointPatchVectorField; \
538 typedef type##PointPatchField<sphericalTensor> \
539  type##PointPatchSphericalTensorField; \
540 typedef type##PointPatchField<symmTensor> type##PointPatchSymmTensorField; \
541 typedef type##PointPatchField<tensor> type##PointPatchTensorField;
542 
543 
544 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
545 
546 #endif
547 
548 // ************************ vim: set sw=4 sts=4 et: ************************ //