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) 2011-2013 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::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 "pointPatch.H"
46 #include "DimensionedField.H"
47 #include "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>
79 class pointPatchField
80 {
81  // Private data
82 
83  //- Reference to patch
84  const pointPatch& patch_;
85 
86  //- Reference to internal field
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'
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 by mapping given patchField<Type> onto a new patch
172  (
173  const pointPatchField<Type>&,
174  const pointPatch&,
176  const pointPatchFieldMapper&
177  );
178 
179  //- Construct as copy
181 
182  //- Construct and return a clone
183  virtual autoPtr<pointPatchField<Type> > clone() const = 0;
184 
185  //- Construct as copy setting internal field reference
187  (
188  const pointPatchField<Type>&,
190  );
191 
192  //- Construct and return a clone setting internal field reference
194  (
196  ) const = 0;
197 
198 
199  // Selectors
200 
201  //- Return a pointer to a new patchField created on freestore given
202  // patch and internal field
203  // (does not set the patch field values)
205  (
206  const word&,
207  const pointPatch&,
209  );
210 
211  //- Return a pointer to a new patchField created on freestore given
212  // patch and internal field
213  // (does not set the patch field values).
214  // Allows override of constraint type
216  (
217  const word&,
218  const word& actualPatchType,
219  const pointPatch&,
221  );
222 
223  //- Return a pointer to a new patchField created on freestore from
224  // a given pointPatchField mapped onto a new patch
226  (
227  const pointPatchField<Type>&,
228  const pointPatch&,
230  const pointPatchFieldMapper&
231  );
232 
233  //- Return a pointer to a new patchField created on freestore
234  // from dictionary
236  (
237  const pointPatch&,
239  const dictionary&
240  );
241 
242 
243  //- Return a pointer to a new CalculatedpointPatchField created on
244  // freestore without setting patchField values
245  template<class Type2>
248  (
250  );
251 
252 
253  //- Destructor
254  virtual ~pointPatchField<Type>()
255  {}
256 
257 
258  // Member functions
259 
260  // Access
261 
262  //- Return local objectRegistry
263  const objectRegistry& db() const;
264 
265  //- Return size
266  label size() const
267  {
268  return patch().size();
269  }
270 
271  //- Return patch
272  const pointPatch& patch() const
273  {
274  return patch_;
275  }
276 
277  //- Return dimensioned internal field reference
280  {
281  return internalField_;
282  }
283 
284  //- Return internal field reference
285  const Field<Type>& internalField() const
286  {
287  return internalField_;
288  }
289 
290  //- Optional patch type
291  const word& patchType() const
292  {
293  return patchType_;
294  }
295 
296  //- Optional patch type
297  word& patchType()
298  {
299  return patchType_;
300  }
301 
302  //- Return true if this patch field fixes a value
303  virtual bool fixesValue() const
304  {
305  return false;
306  }
307 
308  //- Return true if this patch field is coupled
309  virtual bool coupled() const
310  {
311  return false;
312  }
313 
314  //- Return true if the boundary condition has already been updated
315  bool updated() const
316  {
317  return updated_;
318  }
319 
320  //- Return field created from appropriate internal field values
322 
323  //- Return field created from appropriate internal field values
324  // given internal field reference
325  template<class Type1>
327  (
328  const Field<Type1>& iF
329  ) const;
330 
331  //- Return field created from selected internal field values
332  // given internal field reference
333  template<class Type1>
335  (
336  const Field<Type1>& iF,
337  const labelList& meshPoints
338  ) const;
339 
340  //- Given the internal field and a patch field,
341  // add the patch field to the internal field
342  template<class Type1>
343  void addToInternalField
344  (
345  Field<Type1>& iF,
346  const Field<Type1>& pF
347  ) const;
348 
349  //- Given the internal field and a patch field,
350  // add selected elements of the patch field to the internal field
351  template<class Type1>
352  void addToInternalField
353  (
354  Field<Type1>& iF,
355  const Field<Type1>& pF,
356  const labelList& points
357  ) const;
358 
359  //- Given the internal field and a patch field,
360  // set the patch field in the internal field
361  template<class Type1>
362  void setInInternalField
363  (
364  Field<Type1>& iF,
365  const Field<Type1>& pF,
366  const labelList& meshPoints
367  ) const;
368 
369  //- Given the internal field and a patch field,
370  // set the patch field in the internal field
371  template<class Type1>
372  void setInInternalField
373  (
374  Field<Type1>& iF,
375  const Field<Type1>& pF
376  ) const;
377 
378  //- Return the type of the calculated form of pointPatchField
379  static const word& calculatedType();
380 
381  //- Return the constraint type this pointPatchField implements.
382  virtual const word& constraintType() const
383  {
384  return word::null;
385  }
386 
387 
388  // Mapping functions
389 
390  //- Map (and resize as needed) from self given a mapping object
391  virtual void autoMap
392  (
393  const pointPatchFieldMapper&
394  )
395  {}
396 
397  //- Reverse map the given pointPatchField onto this pointPatchField
398  virtual void rmap
399  (
400  const pointPatchField<Type>&,
401  const labelList&
402  )
403  {}
404 
405 
406  // Evaluation functions
407 
408  //- Update the coefficients associated with the patch field
409  // Sets Updated to true
410  virtual void updateCoeffs()
411  {
412  updated_ = true;
413  }
414 
415  //- Initialise evaluation of the patch field (do nothing)
416  virtual void initEvaluate
417  (
418  const Pstream::commsTypes commsType=Pstream::blocking
419  )
420  {}
421 
422  //- Evaluate the patch field
423  virtual void evaluate
424  (
425  const Pstream::commsTypes commsType=Pstream::blocking
426  );
427 
428 
429  //- Write
430  virtual void write(Ostream&) const;
431 
432 
433  // Member operators
434 
435  virtual void operator=
436  (
437  const pointPatchField<Type>&
438  )
439  {}
440 
441  virtual void operator+=
442  (
443  const pointPatchField<Type>&
444  )
445  {}
446 
447  virtual void operator-=
448  (
449  const pointPatchField<Type>&
450  )
451  {}
452 
453  virtual void operator*=
454  (
456  )
457  {}
458 
459  virtual void operator/=
460  (
462  )
463  {}
464 
465  virtual void operator=(const Field<Type>&){}
466  virtual void operator+=(const Field<Type>&){}
467  virtual void operator-=(const Field<Type>&){}
468 
469  virtual void operator*=(const Field<scalar>&){}
470  virtual void operator/=(const Field<scalar>&){}
471 
472  virtual void operator=(const Type&){}
473  virtual void operator+=(const Type&){}
474  virtual void operator-=(const Type&){}
475  virtual void operator*=(const scalar){}
476  virtual void operator/=(const scalar){}
477 
478 
479  // Force an assignment irrespective of form of patch
480  // By generic these do nothing unless the patch actually has boundary
481  // values
482 
483  virtual void operator==
484  (
485  const pointPatchField<Type>&
486  )
487  {}
488 
489  virtual void operator==(const Field<Type>&){}
490  virtual void operator==(const Type&){}
491 
492 
493  // Ostream operator
494 
495  friend Ostream& operator<< <Type>
496  (
497  Ostream&,
498  const pointPatchField<Type>&
499  );
500 };
501 
502 
503 // This function is added as a hack to enable simple backward compatability
504 // with verions using referenceLevel in GeometicField
505 template<class Type>
506 const pointPatchField<Type>& operator+
507 (
508  const pointPatchField<Type>& ppf,
509  const Type&
510 )
511 {
512  return ppf;
513 }
514 
515 
516 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
517 
518 } // End namespace Foam
519 
520 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
521 
523 
524 #ifdef NoRepository
525 # include "pointPatchField.C"
526 # include "calculatedPointPatchField.H"
527 #endif
528 
529 
530 #define addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
531  addToRunTimeSelectionTable \
532  ( \
533  PatchTypeField, \
534  typePatchTypeField, \
535  pointPatch \
536  ); \
537  addToRunTimeSelectionTable \
538  ( \
539  PatchTypeField, \
540  typePatchTypeField, \
541  patchMapper \
542  ); \
543  addToRunTimeSelectionTable \
544  ( \
545  PatchTypeField, \
546  typePatchTypeField, \
547  dictionary \
548  );
549 
550 
551 // for non-templated patch fields
552 #define makePointPatchTypeField(PatchTypeField,typePatchTypeField) \
553  defineTypeNameAndDebug(typePatchTypeField, 0); \
554  addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
555 
556 
557 // for templated patch fields
558 #define makeTemplatePointPatchTypeField(PatchTypeField, typePatchTypeField) \
559  defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
560  addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
561 
562 
563 #define makePointPatchFields(type) \
564  makeTemplatePointPatchTypeField \
565  ( \
566  pointPatchScalarField, \
567  type##PointPatchScalarField \
568  ); \
569  makeTemplatePointPatchTypeField \
570  ( \
571  pointPatchVectorField, \
572  type##PointPatchVectorField \
573  ); \
574  makeTemplatePointPatchTypeField \
575  ( \
576  pointPatchSphericalTensorField, \
577  type##PointPatchSphericalTensorField \
578  ); \
579  makeTemplatePointPatchTypeField \
580  ( \
581  pointPatchSymmTensorField, \
582  type##PointPatchSymmTensorField \
583  ); \
584  makeTemplatePointPatchTypeField \
585  ( \
586  pointPatchTensorField, \
587  type##PointPatchTensorField \
588 );
589 
590 
591 #define makePointPatchFieldsTypeName(type) \
592  defineNamedTemplateTypeNameAndDebug(type##PointPatchScalarField, 0); \
593  defineNamedTemplateTypeNameAndDebug(type##PointPatchVectorField, 0); \
594  defineNamedTemplateTypeNameAndDebug \
595  ( \
596  type##PointPatchSphericalTensorField, 0 \
597  ); \
598  defineNamedTemplateTypeNameAndDebug(type##PointPatchSymmTensorField, 0); \
599  defineNamedTemplateTypeNameAndDebug(type##PointPatchTensorField, 0)
600 
601 
602 #define makePointPatchFieldTypedefs(type) \
603  typedef type##PointPatchField<scalar> type##PointPatchScalarField; \
604  typedef type##PointPatchField<vector> type##PointPatchVectorField; \
605  typedef type##PointPatchField<sphericalTensor> \
606  type##PointPatchSphericalTensorField; \
607  typedef type##PointPatchField<symmTensor> type##PointPatchSymmTensorField;\
608  typedef type##PointPatchField<tensor> type##PointPatchTensorField;
609 
610 
611 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
612 
613 #endif
614 
615 // ************************************************************************* //
Foam::pointPatchField::calculatedType
static const word & calculatedType()
Return the type of the calculated form of pointPatchField.
Definition: calculatedPointPatchField.C:34
Foam::pointPatchField::patchType
word & patchType()
Optional patch type.
Definition: pointPatchField.H:296
Foam::pointPatchField::addToInternalField
void addToInternalField(Field< Type1 > &iF, const Field< Type1 > &pF) const
Given the internal field and a patch field,.
Definition: pointPatchField.C:174
Foam::pointPatchField::operator+=
virtual void operator+=(const pointPatchField< Type > &)
Definition: pointPatchField.H:441
Foam::pointPatchField::operator*=
virtual void operator*=(const Field< scalar > &)
Definition: pointPatchField.H:468
Foam::pointPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
Definition: pointPatchField.C:295
Foam::pointPatchField::operator/=
virtual void operator/=(const pointPatchField< scalar > &)
Definition: pointPatchField.H:459
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::pointPatchField::operator-=
virtual void operator-=(const Field< Type > &)
Definition: pointPatchField.H:466
Foam::pointPatchField::operator==
virtual void operator==(const pointPatchField< Type > &)
Definition: pointPatchField.H:483
Foam::pointPatchField::operator+=
virtual void operator+=(const Field< Type > &)
Definition: pointPatchField.H:465
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
DimensionedField.H
Foam::pointPatchField::New
static autoPtr< pointPatchField< Type > > New(const word &, const pointPatch &, const DimensionedField< Type, pointMesh > &)
Return a pointer to a new patchField created on freestore given.
Foam::pointPatchField::operator/=
virtual void operator/=(const Field< scalar > &)
Definition: pointPatchField.H:469
Foam::pointPatchField::operator=
virtual void operator=(const Type &)
Definition: pointPatchField.H:471
Foam::pointPatchField::pointPatchField
pointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Foam::pointPatchField::patchInternalField
tmp< Field< Type > > patchInternalField() const
Return field created from appropriate internal field values.
Foam::pointPatchField::patch_
const pointPatch & patch_
Reference to patch.
Definition: pointPatchField.H:83
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:56
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:58
Foam::pointPatchField::setInInternalField
void setInInternalField(Field< Type1 > &iF, const Field< Type1 > &pF, const labelList &meshPoints) const
Given the internal field and a patch field,.
Definition: pointPatchField.C:250
Foam::pointPatchField::patch
const pointPatch & patch() const
Return patch.
Definition: pointPatchField.H:271
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:46
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::pointPatchField::operator+=
virtual void operator+=(const Type &)
Definition: pointPatchField.H:472
Foam::pointPatchField::operator=
virtual void operator=(const pointPatchField< Type > &)
Definition: pointPatchField.H:435
Foam::pointPatchField::operator-=
virtual void operator-=(const Type &)
Definition: pointPatchField.H:473
Foam::UPstream::blocking
@ blocking
Definition: UPstream.H:66
Foam::pointPatchField::rmap
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given pointPatchField onto this pointPatchField.
Definition: pointPatchField.H:398
Foam::pointPatchField::operator/=
virtual void operator/=(const scalar)
Definition: pointPatchField.H:475
Foam::pointPatchField::operator=
virtual void operator=(const Field< Type > &)
Definition: pointPatchField.H:464
Foam::pointPatchField::constraintType
virtual const word & constraintType() const
Return the constraint type this pointPatchField implements.
Definition: pointPatchField.H:381
Foam::label
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
Foam::Field< Type >
Foam::pointPatchField::operator-=
virtual void operator-=(const pointPatchField< Type > &)
Definition: pointPatchField.H:447
Foam::pointPatchField::Patch
pointPatch Patch
Definition: pointPatchField.H:100
Foam::pointPatchField::patchType
const word & patchType() const
Optional patch type.
Definition: pointPatchField.H:290
Foam::pointPatchField::write
virtual void write(Ostream &) const
Write.
Definition: pointPatchField.C:119
Foam::pointPatchField::patchType_
word patchType_
Optional patch type, used to allow specified boundary conditions.
Definition: pointPatchField.H:95
Foam::pointPatchField::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, pointPatchField, pointPatch,(const pointPatch &p, const DimensionedField< Type, pointMesh > &iF),(p, iF))
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::pointPatchField::size
label size() const
Return size.
Definition: pointPatchField.H:265
Foam::pointPatchField::disallowGenericPointPatchField
static int disallowGenericPointPatchField
Debug switch to disallow the use of genericPointPatchField.
Definition: pointPatchField.H:107
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::pointPatchField::db
const objectRegistry & db() const
Return local objectRegistry.
Definition: pointPatchField.C:112
Foam::pointPatchField::NewCalculatedType
static autoPtr< pointPatchField< Type > > NewCalculatedType(const pointPatchField< Type2 > &)
Return a pointer to a new CalculatedpointPatchField created on.
Definition: calculatedPointPatchField.C:93
Foam::pointPatch::size
virtual label size() const =0
Return size.
Foam::pointPatchField::updated
bool updated() const
Return true if the boundary condition has already been updated.
Definition: pointPatchField.H:314
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::pointPatchField::internalField
const Field< Type > & internalField() const
Return internal field reference.
Definition: pointPatchField.H:284
Foam::pointPatchField::clone
virtual autoPtr< pointPatchField< Type > > clone() const =0
Construct and return a clone.
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:64
calculatedPointPatchField.H
Foam::pointPatchField::operator*=
virtual void operator*=(const pointPatchField< scalar > &)
Definition: pointPatchField.H:453
Foam::pointPatchField::updated_
bool updated_
Update index used so that updateCoeffs is called only once during.
Definition: pointPatchField.H:90
Foam::pointPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: pointPatchField.H:308
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
points
const pointField & points
Definition: gmvOutputHeader.H:1
pointPatchField.C
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::pointPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: pointPatchField.H:409
Foam::pointPatchField::operator*=
virtual void operator*=(const scalar)
Definition: pointPatchField.H:474
Foam::pointPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: pointPatchField.H:302
Foam::pointPatchField::dimensionedInternalField
const DimensionedField< Type, pointMesh > & dimensionedInternalField() const
Return dimensioned internal field reference.
Definition: pointPatchField.H:278
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::pointPatchField::internalField_
const DimensionedField< Type, pointMesh > & internalField_
Reference to internal field.
Definition: pointPatchField.H:86
Foam::pointPatchField::operator==
virtual void operator==(const Field< Type > &)
Definition: pointPatchField.H:488
pointPatchFieldFunctions.H
Foam::pointPatchField::initEvaluate
virtual void initEvaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Initialise evaluation of the patch field (do nothing)
Definition: pointPatchField.H:416
Foam::pointPatchField::operator==
virtual void operator==(const Type &)
Definition: pointPatchField.H:489
Foam::pointPatchField::TypeName
TypeName("pointPatchField")
Runtime type information.
pointPatch.H
Foam::pointPatchField::autoMap
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: pointPatchField.H:391
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
autoPtr.H