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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::pointPatchField
29 
30 Description
31  Abstract base class for point-mesh patch fields.
32 
33  The base-field does not store values as they are part of the
34  "internal field". There are derived classes to store constraint values
35  e.g. fixedValuePointPatchField derived from the generic
36  valuePointPatchField which ensures the values in the "internal field"
37  are reset to the fixed-values by applying the stored values.
38 
39 SourceFiles
40  pointPatchField.C
41  pointPatchFieldNew.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef pointPatchField_H
46 #define pointPatchField_H
47 
48 #include "pointPatch.H"
49 #include "DimensionedField.H"
50 #include "autoPtr.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // Forward declarations
58 
59 class objectRegistry;
60 class dictionary;
61 class pointPatchFieldMapper;
62 class pointMesh;
63 
64 template<class Type> class pointPatchField;
65 template<class Type> class calculatedPointPatchField;
66 
67 template<class Type>
68 Ostream& operator<<(Ostream&, const pointPatchField<Type>&);
69 
70 
71 /*---------------------------------------------------------------------------*\
72  Class pointPatchField Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 template<class Type>
76 class pointPatchField
77 {
78  // Private data
79 
80  //- Reference to patch
81  const pointPatch& patch_;
82 
83  //- Reference to internal field
84  const DimensionedField<Type, pointMesh>& internalField_;
85 
86  //- Update index used so that updateCoeffs is called only once during
87  // the construction of the matrix
88  bool updated_;
89 
90  //- Optional patch type, used to allow specified boundary conditions
91  // to be applied to constraint patches by providing the constraint
92  // patch type as 'patchType'
93  word patchType_;
94 
95 
96 public:
97 
98  typedef Type value_type;
99  typedef pointPatch Patch;
101 
102 
103  //- Runtime type information
104  TypeName("pointPatchField");
105 
106  //- Debug switch to disallow the use of genericPointPatchField
108 
109 
110  // Declare run-time constructor selection tables
111 
113  (
114  autoPtr,
116  pointPatch,
117  (
118  const pointPatch& p,
120  ),
121  (p, iF)
122  );
123 
125  (
126  autoPtr,
128  patchMapper,
129  (
130  const pointPatchField<Type>& ptf,
131  const pointPatch& p,
133  const pointPatchFieldMapper& m
134  ),
135  (dynamic_cast<const pointPatchFieldType&>(ptf), p, iF, m)
136  );
137 
139  (
140  autoPtr,
142  dictionary,
143  (
144  const pointPatch& p,
146  const dictionary& dict
147  ),
148  (p, iF, dict)
149  );
150 
151 
152  // Constructors
153 
154  //- Construct from patch and internal field
156  (
157  const pointPatch&,
159  );
160 
161  //- Construct from patch, internal field and dictionary
163  (
164  const pointPatch&,
166  const dictionary&
167  );
168 
169  //- Construct by mapping given patchField<Type> onto a new patch
171  (
172  const pointPatchField<Type>&,
173  const pointPatch&,
175  const pointPatchFieldMapper&
176  );
177 
178  //- Construct as copy
180 
181  //- Construct and return a clone
182  virtual autoPtr<pointPatchField<Type>> clone() const = 0;
183 
184  //- Construct as copy setting internal field reference
186  (
187  const pointPatchField<Type>&,
189  );
190 
191  //- Construct and return a clone setting internal field reference
193  (
195  ) const = 0;
196 
197 
198  // Selectors
199 
200  //- Return a pointer to a new patchField created on freestore given
201  // patch and internal field
202  // (does not set the patch field values)
204  (
205  const word&,
206  const pointPatch&,
208  );
209 
210  //- Return a pointer to a new patchField created on freestore given
211  // patch and internal field
212  // (does not set the patch field values).
213  // Allows override of constraint type
215  (
216  const word&,
217  const word& actualPatchType,
218  const pointPatch&,
220  );
221 
222  //- Return a pointer to a new patchField created on freestore from
223  // a given pointPatchField mapped onto a new patch
225  (
226  const pointPatchField<Type>&,
227  const pointPatch&,
229  const pointPatchFieldMapper&
230  );
231 
232  //- Return a pointer to a new patchField created on freestore
233  // from dictionary
235  (
236  const pointPatch&,
238  const dictionary&
239  );
240 
241  //- Return a pointer to a new calculatedPointPatchField created on
242  // freestore without setting patchField values
243  template<class Type2>
246  (
248  );
249 
250 
251  //- Destructor
252  virtual ~pointPatchField<Type>() = default;
253 
254 
255  // Member functions
256 
257  // Access
258 
259  //- Return local objectRegistry
260  const objectRegistry& db() const;
261 
262  //- Return size
263  label size() const
264  {
265  return patch().size();
266  }
267 
268  //- Return patch
269  const pointPatch& patch() const
270  {
271  return patch_;
272  }
273 
274  //- Return dimensioned internal field reference
276  internalField() const
277  {
278  return internalField_;
279  }
280 
281  //- Return internal field reference
282  const Field<Type>& primitiveField() const
283  {
284  return internalField_;
285  }
286 
287  //- Optional patch type
288  const word& patchType() const
289  {
290  return patchType_;
291  }
292 
293  //- Optional patch type
294  word& patchType()
295  {
296  return patchType_;
297  }
298 
299  //- Return true if this patch field fixes a value
300  virtual bool fixesValue() const
301  {
302  return false;
303  }
304 
305  //- Return true if this patch field is coupled
306  virtual bool coupled() const
307  {
308  return false;
309  }
310 
311  //- Return true if the boundary condition has already been updated
312  bool updated() const
313  {
314  return updated_;
315  }
316 
317  //- Return field created from appropriate internal field values
319 
320  //- Return field created from appropriate internal field values
321  // given internal field reference
322  template<class Type1>
324  (
325  const Field<Type1>& iF
326  ) const;
327 
328  //- Return field created from selected internal field values
329  // given internal field reference
330  template<class Type1>
332  (
333  const Field<Type1>& iF,
334  const labelList& meshPoints
335  ) const;
336 
337  //- Given the internal field and a patch field,
338  // add the patch field to the internal field
339  template<class Type1>
340  void addToInternalField
341  (
342  Field<Type1>& iF,
343  const Field<Type1>& pF
344  ) const;
345 
346  //- Given the internal field and a patch field,
347  // add selected elements of the patch field to the internal field
348  template<class Type1>
349  void addToInternalField
350  (
351  Field<Type1>& iF,
352  const Field<Type1>& pF,
353  const labelList& points
354  ) const;
355 
356  //- Given the internal field and a patch field,
357  // set the patch field in the internal field
358  template<class Type1>
359  void setInInternalField
360  (
361  Field<Type1>& iF,
362  const Field<Type1>& pF,
363  const labelList& meshPoints
364  ) const;
365 
366  //- Given the internal field and a patch field,
367  // set the patch field in the internal field
368  template<class Type1>
369  void setInInternalField
370  (
371  Field<Type1>& iF,
372  const Field<Type1>& pF
373  ) const;
374 
375  //- Return the type of the calculated form of pointPatchField
376  static const word& calculatedType();
377 
378  //- Return the constraint type this pointPatchField implements.
379  virtual const word& constraintType() const
380  {
381  return word::null;
382  }
383 
384 
385  // Mapping functions
386 
387  //- Map (and resize as needed) from self given a mapping object
388  virtual void autoMap
389  (
390  const pointPatchFieldMapper&
391  )
392  {}
393 
394  //- Reverse map the given pointPatchField onto this pointPatchField
395  virtual void rmap
396  (
397  const pointPatchField<Type>&,
398  const labelList&
399  )
400  {}
401 
402 
403  // Evaluation functions
404 
405  //- Update the coefficients associated with the patch field
406  // Sets Updated to true
407  virtual void updateCoeffs()
408  {
409  updated_ = true;
410  }
411 
412  //- Initialise evaluation of the patch field (do nothing)
413  virtual void initEvaluate
414  (
415  const Pstream::commsTypes commsType =
417  )
418  {}
419 
420  //- Evaluate the patch field
421  virtual void evaluate
422  (
423  const Pstream::commsTypes commsType =
425  );
426 
427 
428  // I-O
429 
430  //- Write
431  virtual void write(Ostream&) const;
432 
433 
434  // Member Operators
435 
436  virtual void operator=(const pointPatchField<Type>&){}
437  virtual void operator+=(const pointPatchField<Type>&){}
438  virtual void operator-=(const pointPatchField<Type>&){}
439  virtual void operator*=(const pointPatchField<scalar>&){}
440  virtual void operator/=(const pointPatchField<scalar>&){}
441 
442  virtual void operator=(const Field<Type>&){}
443  virtual void operator+=(const Field<Type>&){}
444  virtual void operator-=(const Field<Type>&){}
445 
446  virtual void operator*=(const Field<scalar>&){}
447  virtual void operator/=(const Field<scalar>&){}
448 
449  virtual void operator=(const Type&){}
450  virtual void operator+=(const Type&){}
451  virtual void operator-=(const Type&){}
452  virtual void operator*=(const scalar){}
453  virtual void operator/=(const scalar){}
454 
455 
456  // Force an assignment irrespective of form of patch
457  // By generic these do nothing unless the patch actually has boundary
458  // values
459 
460  virtual void operator==(const pointPatchField<Type>&){}
461  virtual void operator==(const Field<Type>&){}
462  virtual void operator==(const Type&){}
463 
464 
465  // Ostream operator
466 
467  friend Ostream& operator<< <Type>
468  (
469  Ostream&,
470  const pointPatchField<Type>&
471  );
472 
473 
474  // Housekeeping
475 
476  // Includes some dummy methods to ensure that various
477  // FieldFieldFunctions will be definable.
478 
479  //- Negate the field inplace
480  // [dummy placeholder for FieldField] (2019-11)
481  void negate() {}
482 };
483 
484 
485 // This function is added as a hack to enable simple backward compatibility
486 // with versions using referenceLevel in GeometricField
487 template<class Type>
488 const pointPatchField<Type>& operator+
489 (
490  const pointPatchField<Type>& ppf,
491  const Type&
492 )
493 {
494  return ppf;
495 }
496 
497 
498 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
499 
500 } // End namespace Foam
501 
502 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
503 
505 
506 #ifdef NoRepository
507  #include "pointPatchField.C"
508  #include "calculatedPointPatchField.H"
509 #endif
510 
511 
512 #define addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
513  addToRunTimeSelectionTable \
514  ( \
515  PatchTypeField, \
516  typePatchTypeField, \
517  pointPatch \
518  ); \
519  addToRunTimeSelectionTable \
520  ( \
521  PatchTypeField, \
522  typePatchTypeField, \
523  patchMapper \
524  ); \
525  addToRunTimeSelectionTable \
526  ( \
527  PatchTypeField, \
528  typePatchTypeField, \
529  dictionary \
530  );
531 
532 
533 // for non-templated patch fields
534 #define makePointPatchTypeField(PatchTypeField,typePatchTypeField) \
535  defineTypeNameAndDebug(typePatchTypeField, 0); \
536  addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
537 
538 
539 // for templated patch fields
540 #define makeTemplatePointPatchTypeField(PatchTypeField, typePatchTypeField) \
541  defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
542  addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
543 
544 
545 #define makePointPatchFields(type) \
546  makeTemplatePointPatchTypeField \
547  ( \
548  pointPatchScalarField, \
549  type##PointPatchScalarField \
550  ); \
551  makeTemplatePointPatchTypeField \
552  ( \
553  pointPatchVectorField, \
554  type##PointPatchVectorField \
555  ); \
556  makeTemplatePointPatchTypeField \
557  ( \
558  pointPatchSphericalTensorField, \
559  type##PointPatchSphericalTensorField \
560  ); \
561  makeTemplatePointPatchTypeField \
562  ( \
563  pointPatchSymmTensorField, \
564  type##PointPatchSymmTensorField \
565  ); \
566  makeTemplatePointPatchTypeField \
567  ( \
568  pointPatchTensorField, \
569  type##PointPatchTensorField \
570 );
571 
572 
573 #define makePointPatchFieldsTypeName(type) \
574  defineNamedTemplateTypeNameAndDebug(type##PointPatchScalarField, 0); \
575  defineNamedTemplateTypeNameAndDebug(type##PointPatchVectorField, 0); \
576  defineNamedTemplateTypeNameAndDebug \
577  ( \
578  type##PointPatchSphericalTensorField, 0 \
579  ); \
580  defineNamedTemplateTypeNameAndDebug(type##PointPatchSymmTensorField, 0); \
581  defineNamedTemplateTypeNameAndDebug(type##PointPatchTensorField, 0)
582 
583 
584 #define makePointPatchFieldTypedefs(type) \
585  typedef type##PointPatchField<scalar> type##PointPatchScalarField; \
586  typedef type##PointPatchField<vector> type##PointPatchVectorField; \
587  typedef type##PointPatchField<sphericalTensor> \
588  type##PointPatchSphericalTensorField; \
589  typedef type##PointPatchField<symmTensor> type##PointPatchSymmTensorField;\
590  typedef type##PointPatchField<tensor> type##PointPatchTensorField;
591 
592 
593 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
594 
595 #endif
596 
597 // ************************************************************************* //
Foam::pointPatchField::patchType
word & patchType()
Optional patch type.
Definition: pointPatchField.H:293
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:436
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::pointPatchField::operator*=
virtual void operator*=(const Field< scalar > &)
Definition: pointPatchField.H:445
Foam::pointPatchField::operator/=
virtual void operator/=(const pointPatchField< scalar > &)
Definition: pointPatchField.H:439
Foam::pointPatchField::primitiveField
const Field< Type > & primitiveField() const
Return internal field reference.
Definition: pointPatchField.H:281
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::pointPatchField::operator-=
virtual void operator-=(const Field< Type > &)
Definition: pointPatchField.H:443
Foam::pointPatchField::operator==
virtual void operator==(const pointPatchField< Type > &)
Definition: pointPatchField.H:459
Foam::pointPatchField::operator+=
virtual void operator+=(const Field< Type > &)
Definition: pointPatchField.H:442
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
DimensionedField.H
Foam::pointPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Definition: pointPatchField.C:295
Foam::pointPatchField::NewCalculatedType
static autoPtr< pointPatchField< Type > > NewCalculatedType(const pointPatchField< Type2 > &)
Return a pointer to a new calculatedPointPatchField created on.
Foam::pointPatchField::db
const objectRegistry & db() const
Return local objectRegistry.
Definition: pointPatchField.C:110
Foam::pointPatchField::operator/=
virtual void operator/=(const Field< scalar > &)
Definition: pointPatchField.H:446
Foam::pointPatchField::operator=
virtual void operator=(const Type &)
Definition: pointPatchField.H:448
Foam::pointPatchField::pointPatchField
pointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Definition: pointPatchField.C:37
Foam::pointPatchField::calculatedType
static const word & calculatedType()
Return the type of the calculated form of pointPatchField.
Definition: calculatedPointPatchField.C:34
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:60
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:268
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:48
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::pointPatchField::operator+=
virtual void operator+=(const Type &)
Definition: pointPatchField.H:449
Foam::pointPatchField::operator=
virtual void operator=(const pointPatchField< Type > &)
Definition: pointPatchField.H:435
Foam::pointPatchField::operator-=
virtual void operator-=(const Type &)
Definition: pointPatchField.H:450
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::pointPatchField::rmap
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given pointPatchField onto this pointPatchField.
Definition: pointPatchField.H:395
Foam::pointPatchField::operator/=
virtual void operator/=(const scalar)
Definition: pointPatchField.H:452
Foam::pointPatchField::operator=
virtual void operator=(const Field< Type > &)
Definition: pointPatchField.H:441
Foam::pointPatchField::constraintType
virtual const word & constraintType() const
Return the constraint type this pointPatchField implements.
Definition: pointPatchField.H:378
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::pointPatchField::operator-=
virtual void operator-=(const pointPatchField< Type > &)
Definition: pointPatchField.H:437
Foam::pointPatchField::Patch
pointPatch Patch
Definition: pointPatchField.H:98
Foam::pointPatchField::patchType
const word & patchType() const
Optional patch type.
Definition: pointPatchField.H:287
Foam::pointPatchField::Calculated
calculatedPointPatchField< Type > Calculated
Definition: pointPatchField.H:99
Foam::pointPatchField::internalField
const DimensionedField< Type, pointMesh > & internalField() const
Return dimensioned internal field reference.
Definition: pointPatchField.H:275
Foam::calculatedPointPatchField
A calculated boundary condition for pointField.
Definition: calculatedPointPatchField.H:51
Foam::pointPatchField::write
virtual void write(Ostream &) const
Write.
Definition: pointPatchField.C:117
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 a number of values (eg,...
Definition: dictionary.H:123
Foam::pointPatchField::size
label size() const
Return size.
Definition: pointPatchField.H:262
Foam::pointPatchField::initEvaluate
virtual void initEvaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Initialise evaluation of the patch field (do nothing)
Definition: pointPatchField.H:413
Foam::pointPatchField::disallowGenericPointPatchField
static int disallowGenericPointPatchField
Debug switch to disallow the use of genericPointPatchField.
Definition: pointPatchField.H:106
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.
Definition: pointPatchFieldNew.C:95
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
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:311
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::pointPatchField::clone
virtual autoPtr< pointPatchField< Type > > clone() const =0
Construct and return a clone.
calculatedPointPatchField.H
Foam::pointPatchField::operator*=
virtual void operator*=(const pointPatchField< scalar > &)
Definition: pointPatchField.H:438
Foam::pointPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: pointPatchField.H:305
Foam::List< label >
points
const pointField & points
Definition: gmvOutputHeader.H:1
pointPatchField.C
Foam::word::null
static const word null
An empty word.
Definition: word.H:80
Foam::pointPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: pointPatchField.H:406
Foam::pointPatchField::patchInternalField
tmp< Field< Type > > patchInternalField() const
Return field created from appropriate internal field values.
Definition: pointPatchField.C:130
Foam::pointPatchField::negate
void negate()
Negate the field inplace.
Definition: pointPatchField.H:480
Foam::pointPatchField::operator*=
virtual void operator*=(const scalar)
Definition: pointPatchField.H:451
Foam::pointPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: pointPatchField.H:299
Foam::pointPatchField::value_type
Type value_type
Definition: pointPatchField.H:97
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::pointPatchField::operator==
virtual void operator==(const Field< Type > &)
Definition: pointPatchField.H:460
pointPatchFieldFunctions.H
Foam::pointPatchField::operator==
virtual void operator==(const Type &)
Definition: pointPatchField.H:461
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:388
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::UPstream::commsTypes::blocking
autoPtr.H