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-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::pointPatchField
29
30Description
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
39SourceFiles
40 pointPatchField.C
41 pointPatchFieldNew.C
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef Foam_pointPatchField_H
46#define Foam_pointPatchField_H
47
48#include "pointPatch.H"
49#include "DimensionedField.H"
50#include "autoPtr.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56
57// Forward Declarations
58
59class objectRegistry;
60class dictionary;
61class pointPatchFieldMapper;
62class pointMesh;
63
64template<class Type> class pointPatchField;
65template<class Type> class calculatedPointPatchField;
66
67template<class Type>
69
70
71/*---------------------------------------------------------------------------*\
72 Class pointPatchField Declaration
73\*---------------------------------------------------------------------------*/
74
75template<class Type>
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
96public:
97
98 //- The Field value_type
99 typedef Type value_type;
100
101 //- The internal field type associated with the patch field
103
104 //- The patch type for the patch field
105 typedef pointPatch Patch;
106
107 //- Type for a \em calculated patch
109
110
111 //- Runtime type information
112 TypeName("pointPatchField");
113
114 //- Debug switch to disallow the use of genericPointPatchField
116
117
118 // Declare run-time constructor selection tables
121 (
122 autoPtr,
125 (
126 const pointPatch& p,
128 ),
129 (p, iF)
130 );
133 (
134 autoPtr,
136 patchMapper,
137 (
138 const pointPatchField<Type>& ptf,
139 const pointPatch& p,
141 const pointPatchFieldMapper& m
142 ),
143 (dynamic_cast<const pointPatchFieldType&>(ptf), p, iF, m)
144 );
147 (
148 autoPtr,
151 (
152 const pointPatch& p,
154 const dictionary& dict
155 ),
156 (p, iF, dict)
157 );
158
159
160 // Constructors
161
162 //- Construct from patch and internal field
164 (
165 const pointPatch&,
167 );
168
169 //- Construct from patch, internal field and dictionary
171 (
172 const pointPatch&,
174 const dictionary&
175 );
176
177 //- Construct by mapping given patchField<Type> onto a new patch
179 (
181 const pointPatch&,
184 );
185
186 //- Construct as copy
188
189 //- Construct and return a clone
190 virtual autoPtr<pointPatchField<Type>> clone() const = 0;
191
192 //- Construct as copy setting internal field reference
194 (
197 );
198
199 //- Construct and return a clone setting internal field reference
201 (
203 ) const = 0;
204
205
206 // Selectors
207
208 //- Return a pointer to a new patchField created on freestore given
209 // patch and internal field
210 // (does not set the patch field values)
212 (
213 const word& patchFieldType,
214 const pointPatch& p,
216 );
217
218 //- Return a pointer to a new patchField created on freestore given
219 // patch and internal field
220 // (does not set the patch field values).
221 // Allows override of constraint type
223 (
224 const word& patchFieldType,
225 const word& actualPatchType,
226 const pointPatch& p,
228 );
229
230 //- Return a pointer to a new patchField created on freestore from
231 // a given pointPatchField mapped onto a new patch
233 (
235 const pointPatch&,
238 );
239
240 //- Return a pointer to a new patchField created on freestore
241 // from dictionary
243 (
244 const pointPatch&,
246 const dictionary&
247 );
248
249 //- Return a pointer to a new calculatedPointPatchField created on
250 // freestore without setting patchField values
251 template<class Type2>
254 (
256 );
257
258
259 //- Destructor
260 virtual ~pointPatchField<Type>() = default;
261
262
263 // Member functions
264
265 // Access
266
267 //- Return local objectRegistry
268 const objectRegistry& db() const;
269
270 //- Return size
271 label size() const
272 {
273 return patch().size();
274 }
275
276 //- Return patch
277 const pointPatch& patch() const
278 {
279 return patch_;
280 }
281
282 //- Return dimensioned internal field reference
284 internalField() const
285 {
286 return internalField_;
287 }
288
289 //- Return internal field reference
290 const Field<Type>& primitiveField() const
291 {
292 return internalField_;
293 }
294
295 //- Optional patch type
296 const word& patchType() const
297 {
298 return patchType_;
299 }
300
301 //- Optional patch type
302 word& patchType()
303 {
304 return patchType_;
305 }
306
307 //- Return true if this patch field fixes a value
308 virtual bool fixesValue() const
309 {
310 return false;
311 }
312
313 //- Return true if this patch field is coupled
314 virtual bool coupled() const
315 {
316 return false;
317 }
318
319 //- Return true if the boundary condition has already been updated
320 bool updated() const
321 {
322 return updated_;
323 }
324
325 //- Return field created from appropriate internal field values
327
328 //- Return field created from appropriate internal field values
329 // given internal field reference
330 template<class Type1>
332 (
333 const Field<Type1>& iF
334 ) const;
335
336 //- Return field created from selected internal field values
337 // given internal field reference
338 template<class Type1>
340 (
341 const Field<Type1>& iF,
342 const labelList& meshPoints
343 ) const;
344
345 //- Given the internal field and a patch field,
346 // add the patch field to the internal field
347 template<class Type1>
349 (
350 Field<Type1>& iF,
351 const Field<Type1>& pF
352 ) const;
353
354 //- Given the internal field and a patch field,
355 // add selected elements of the patch field to the internal field
356 template<class Type1>
358 (
359 Field<Type1>& iF,
360 const Field<Type1>& pF,
361 const labelList& points
362 ) const;
363
364 //- Given the internal field and a patch field,
365 // set the patch field in the internal field
366 template<class Type1>
368 (
369 Field<Type1>& iF,
370 const Field<Type1>& pF,
371 const labelList& meshPoints
372 ) const;
373
374 //- Given the internal field and a patch field,
375 // set the patch field in the internal field
376 template<class Type1>
378 (
379 Field<Type1>& iF,
380 const Field<Type1>& pF
381 ) const;
382
383 //- Return the type of the calculated form of pointPatchField
384 static const word& calculatedType();
385
386 //- Return the constraint type this pointPatchField implements.
387 virtual const word& constraintType() const
388 {
389 return word::null;
390 }
391
392
393 // Mapping functions
394
395 //- Map (and resize as needed) from self given a mapping object
396 virtual void autoMap
397 (
399 )
400 {}
401
402 //- Reverse map the given pointPatchField onto this pointPatchField
403 virtual void rmap
404 (
406 const labelList&
407 )
408 {}
409
410
411 // Evaluation functions
412
413 //- Update the coefficients associated with the patch field
414 // Sets Updated to true
415 virtual void updateCoeffs()
416 {
417 updated_ = true;
418 }
419
420 //- Initialise evaluation of the patch field (do nothing)
421 virtual void initEvaluate
422 (
423 const Pstream::commsTypes commsType =
425 )
426 {}
427
428 //- Evaluate the patch field
429 virtual void evaluate
430 (
431 const Pstream::commsTypes commsType =
433 );
434
435
436 // I-O
437
438 //- Write
439 virtual void write(Ostream&) const;
440
441
442 // Member Operators
444 virtual void operator=(const pointPatchField<Type>&){}
445 virtual void operator+=(const pointPatchField<Type>&){}
446 virtual void operator-=(const pointPatchField<Type>&){}
447 virtual void operator*=(const pointPatchField<scalar>&){}
448 virtual void operator/=(const pointPatchField<scalar>&){}
450 virtual void operator=(const Field<Type>&){}
451 virtual void operator+=(const Field<Type>&){}
452 virtual void operator-=(const Field<Type>&){}
454 virtual void operator*=(const Field<scalar>&){}
455 virtual void operator/=(const Field<scalar>&){}
457 virtual void operator=(const Type&){}
458 virtual void operator+=(const Type&){}
459 virtual void operator-=(const Type&){}
460 virtual void operator*=(const scalar){}
461 virtual void operator/=(const scalar){}
462
463
464 // Force an assignment irrespective of form of patch
465 // By generic these do nothing unless the patch actually has boundary
466 // values
468 virtual void operator==(const pointPatchField<Type>&){}
469 virtual void operator==(const Field<Type>&){}
470 virtual void operator==(const Type&){}
471
472
473 // Ostream operator
475 friend Ostream& operator<< <Type>
476 (
477 Ostream&,
479 );
480
481
482 // Other Methods
483
484 //- Negate the field inplace. Dummy placeholder for FieldField
485 void negate() {}
486
487 //- Normalise the field inplace. Dummy placeholder for FieldField
488 void normalise() {}
489};
490
491
492// This function is added as a hack to enable simple backward compatibility
493// with versions using referenceLevel in GeometricField
494template<class Type>
495const pointPatchField<Type>& operator+
496(
497 const pointPatchField<Type>& ppf,
498 const Type&
499)
500{
501 return ppf;
502}
503
504
505// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
506
507} // End namespace Foam
508
509// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
510
512
513#ifdef NoRepository
514 #include "pointPatchField.C"
516#endif
517
519#define addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
520 addToRunTimeSelectionTable \
521 ( \
522 PatchTypeField, \
523 typePatchTypeField, \
524 pointPatch \
525 ); \
526 addToRunTimeSelectionTable \
527 ( \
528 PatchTypeField, \
529 typePatchTypeField, \
530 patchMapper \
531 ); \
532 addToRunTimeSelectionTable \
533 ( \
534 PatchTypeField, \
535 typePatchTypeField, \
536 dictionary \
537 );
538
539
540// for non-templated patch fields
541#define makePointPatchTypeField(PatchTypeField,typePatchTypeField) \
542 defineTypeNameAndDebug(typePatchTypeField, 0); \
543 addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
544
545
546// for templated patch fields
547#define makeTemplatePointPatchTypeField(PatchTypeField, typePatchTypeField) \
548 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
549 addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
550
552#define makePointPatchFields(type) \
553 makeTemplatePointPatchTypeField \
554 ( \
555 pointPatchScalarField, \
556 type##PointPatchScalarField \
557 ); \
558 makeTemplatePointPatchTypeField \
559 ( \
560 pointPatchVectorField, \
561 type##PointPatchVectorField \
562 ); \
563 makeTemplatePointPatchTypeField \
564 ( \
565 pointPatchSphericalTensorField, \
566 type##PointPatchSphericalTensorField \
567 ); \
568 makeTemplatePointPatchTypeField \
569 ( \
570 pointPatchSymmTensorField, \
571 type##PointPatchSymmTensorField \
572 ); \
573 makeTemplatePointPatchTypeField \
574 ( \
575 pointPatchTensorField, \
576 type##PointPatchTensorField \
577);
578
580#define makePointPatchFieldsTypeName(type) \
581 defineNamedTemplateTypeNameAndDebug(type##PointPatchScalarField, 0); \
582 defineNamedTemplateTypeNameAndDebug(type##PointPatchVectorField, 0); \
583 defineNamedTemplateTypeNameAndDebug \
584 ( \
585 type##PointPatchSphericalTensorField, 0 \
586 ); \
587 defineNamedTemplateTypeNameAndDebug(type##PointPatchSymmTensorField, 0); \
588 defineNamedTemplateTypeNameAndDebug(type##PointPatchTensorField, 0)
589
591#define makePointPatchFieldTypedefs(type) \
592 typedef type##PointPatchField<scalar> type##PointPatchScalarField; \
593 typedef type##PointPatchField<vector> type##PointPatchVectorField; \
594 typedef type##PointPatchField<sphericalTensor> \
595 type##PointPatchSphericalTensorField; \
596 typedef type##PointPatchField<symmTensor> type##PointPatchSymmTensorField;\
597 typedef type##PointPatchField<tensor> type##PointPatchTensorField;
598
599
600// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
601
602#endif
603
604// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Definition: Field.H:82
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
commsTypes
Types of communications.
Definition: UPstream.H:67
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A calculated boundary condition for pointField.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Registry of regIOobjects.
Foam::pointPatchFieldMapper.
Abstract base class for point-mesh patch fields.
tmp< Field< Type1 > > patchInternalField(const Field< Type1 > &iF, const labelList &meshPoints) const
Return field created from selected internal field values.
pointPatch Patch
The patch type for the patch field.
virtual void initEvaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Initialise evaluation of the patch field (do nothing)
virtual void operator/=(const Field< scalar > &)
virtual bool fixesValue() const
Return true if this patch field fixes a value.
TypeName("pointPatchField")
Runtime type information.
virtual void operator==(const pointPatchField< Type > &)
static int disallowGenericPointPatchField
Debug switch to disallow the use of genericPointPatchField.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual autoPtr< pointPatchField< Type > > clone(const DimensionedField< Type, pointMesh > &iF) const =0
Construct and return a clone setting internal field reference.
Type value_type
The Field value_type.
virtual void operator==(const Type &)
virtual void operator=(const pointPatchField< Type > &)
virtual bool coupled() const
Return true if this patch field is coupled.
tmp< Field< Type > > patchInternalField() const
Return field created from appropriate internal field values.
virtual void operator+=(const Field< Type > &)
virtual void operator/=(const pointPatchField< scalar > &)
virtual void operator=(const Type &)
virtual void operator*=(const Field< scalar > &)
calculatedPointPatchField< Type > Calculated
Type for a calculated patch.
declareRunTimeSelectionTable(autoPtr, pointPatchField, patchMapper,(const pointPatchField< Type > &ptf, const pointPatch &p, const DimensionedField< Type, pointMesh > &iF, const pointPatchFieldMapper &m),(dynamic_cast< const pointPatchFieldType & >(ptf), p, iF, m))
const pointPatch & patch() const
Return patch.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual const word & constraintType() const
Return the constraint type this pointPatchField implements.
virtual void operator+=(const pointPatchField< Type > &)
virtual autoPtr< pointPatchField< Type > > clone() const =0
Construct and return a clone.
const objectRegistry & db() const
Return local objectRegistry.
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given pointPatchField onto this pointPatchField.
const Field< Type > & primitiveField() const
Return internal field reference.
void addToInternalField(Field< Type1 > &iF, const Field< Type1 > &pF) const
Given the internal field and a patch field,.
virtual void operator-=(const pointPatchField< Type > &)
virtual void operator/=(const scalar)
void setInInternalField(Field< Type1 > &iF, const Field< Type1 > &pF, const labelList &meshPoints) const
Given the internal field and a patch field,.
virtual void operator==(const Field< Type > &)
virtual void operator*=(const pointPatchField< scalar > &)
const DimensionedField< Type, pointMesh > & internalField() const
Return dimensioned internal field reference.
label size() const
Return size.
static autoPtr< pointPatchField< Type > > New(const word &patchFieldType, const pointPatch &p, const DimensionedField< Type, pointMesh > &iF)
Return a pointer to a new patchField created on freestore given.
virtual void operator-=(const Type &)
declareRunTimeSelectionTable(autoPtr, pointPatchField, dictionary,(const pointPatch &p, const DimensionedField< Type, pointMesh > &iF, const dictionary &dict),(p, iF, dict))
const word & patchType() const
Optional patch type.
void negate()
Negate the field inplace. Dummy placeholder for FieldField.
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
declareRunTimeSelectionTable(autoPtr, pointPatchField, pointPatch,(const pointPatch &p, const DimensionedField< Type, pointMesh > &iF),(p, iF))
word & patchType()
Optional patch type.
void normalise()
Normalise the field inplace. Dummy placeholder for FieldField.
static autoPtr< pointPatchField< Type > > NewCalculatedType(const pointPatchField< Type2 > &)
Return a pointer to a new calculatedPointPatchField created on.
bool updated() const
Return true if the boundary condition has already been updated.
virtual void operator=(const Field< Type > &)
DimensionedField< Type, pointMesh > Internal
The internal field type associated with the patch field.
virtual void operator*=(const scalar)
virtual void operator-=(const Field< Type > &)
virtual void operator+=(const Type &)
static const word & calculatedType()
Return the type of the calculated form of pointPatchField.
tmp< Field< Type1 > > patchInternalField(const Field< Type1 > &iF) const
Return field created from appropriate internal field values.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
virtual label size() const =0
Return size.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
static const word null
An empty word.
Definition: word.H:80
volScalarField & p
const pointField & points
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
runTime write()
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73