Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
finiteVolume
fields
fvPatchFields
fvPatchField
fvPatchField.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::fvPatchField
26
27
Description
28
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 types with
35
specific evaluation proceedures, particularly with respect to specific
36
fields.
37
38
SourceFiles
39
fvPatchField.C
40
newFvPatchField.C
41
42
\*---------------------------------------------------------------------------*/
43
44
#ifndef fvPatchField_H
45
#define fvPatchField_H
46
47
#include <
finiteVolume/fvPatch.H
>
48
#include <
OpenFOAM/DimensionedField.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
volMesh;
61
62
63
// Forward declaration of friend functions and operators
64
65
template
<
class
Type>
66
class
fvPatchField;
67
68
template
<
class
Type>
69
class
fvMatrix;
70
71
template
<
class
Type>
72
Ostream& operator<<(Ostream&, const fvPatchField<Type>&);
73
74
75
/*---------------------------------------------------------------------------*\
76
Class patch Declaration
77
\*---------------------------------------------------------------------------*/
78
79
template
<
class
Type>
80
class
fvPatchField
81
:
82
public
Field
<Type>
83
{
84
// Private data
85
86
//- Reference to patch
87
const
fvPatch
& patch_;
88
89
//- Reference to internal field
90
const
DimensionedField<Type, volMesh>
& internalField_;
91
92
//- Update index used so that updateCoeffs is called only once during
93
// the construction of the matrix
94
bool
updated_;
95
96
//- Optional patch type, used to allow specified boundary conditions
97
// to be applied to constraint patches by providing the constraint
98
// patch type as 'patchType'
99
word
patchType_;
100
101
102
public
:
103
104
typedef
fvPatch
Patch
;
105
106
107
//- Runtime type information
108
TypeName
(
"fvPatchField"
);
109
110
//- Debug switch to disallow the use of genericFvPatchField
111
static
int
disallowGenericFvPatchField
;
112
113
114
// Declare run-time constructor selection tables
115
116
declareRunTimeSelectionTable
117
(
118
tmp
,
119
fvPatchField
,
120
patch
,
121
(
122
const
fvPatch
&
p
,
123
const
DimensionedField<Type, volMesh>
& iF
124
),
125
(p, iF)
126
);
127
128
declareRunTimeSelectionTable
129
(
130
tmp
,
131
fvPatchField
,
132
patchMapper,
133
(
134
const
fvPatchField<Type>
& ptf,
135
const
fvPatch
& p,
136
const
DimensionedField<Type, volMesh>
& iF,
137
const
fvPatchFieldMapper
& m
138
),
139
(dynamic_cast<const fvPatchFieldType&>(ptf), p, iF, m)
140
);
141
142
declareRunTimeSelectionTable
143
(
144
tmp
,
145
fvPatchField
,
146
dictionary
,
147
(
148
const
fvPatch
& p,
149
const
DimensionedField<Type, volMesh>
& iF,
150
const
dictionary
& dict
151
),
152
(p, iF, dict)
153
);
154
155
156
// Constructors
157
158
//- Construct from patch and internal field
159
fvPatchField
160
(
161
const
fvPatch
&,
162
const
DimensionedField<Type, volMesh>
&
163
);
164
165
//- Construct from patch and internal field and patch field
166
fvPatchField
167
(
168
const
fvPatch
&,
169
const
DimensionedField<Type, volMesh>
&,
170
const
Field<Type>
&
171
);
172
173
//- Construct from patch, internal field and dictionary
174
fvPatchField
175
(
176
const
fvPatch
&,
177
const
DimensionedField<Type, volMesh>
&,
178
const
dictionary
&,
179
const
bool
valueRequired=
false
180
);
181
182
//- Construct by mapping the given fvPatchField onto a new patch
183
fvPatchField
184
(
185
const
fvPatchField<Type>
&,
186
const
fvPatch
&,
187
const
DimensionedField<Type, volMesh>
&,
188
const
fvPatchFieldMapper
&
189
);
190
191
//- Construct as copy
192
fvPatchField
(
const
fvPatchField<Type>
&);
193
194
//- Construct and return a clone
195
virtual
tmp<fvPatchField<Type>
>
clone
()
const
196
{
197
return
tmp<fvPatchField<Type>
>(
new
fvPatchField<Type>
(*this));
198
}
199
200
//- Construct as copy setting internal field reference
201
fvPatchField
202
(
203
const
fvPatchField<Type>
&,
204
const
DimensionedField<Type, volMesh>
&
205
);
206
207
//- Construct and return a clone setting internal field reference
208
virtual
tmp<fvPatchField<Type>
>
clone
209
(
210
const
DimensionedField<Type, volMesh>
& iF
211
)
const
212
{
213
return
tmp<fvPatchField<Type>
>(
new
fvPatchField<Type>
(*
this
, iF));
214
}
215
216
217
// Selectors
218
219
//- Return a pointer to a new patchField created on freestore given
220
// patch and internal field
221
// (does not set the patch field values)
222
static
tmp<fvPatchField<Type>
>
New
223
(
224
const
word
&,
225
const
fvPatch
&,
226
const
DimensionedField<Type, volMesh>
&
227
);
228
229
//- Return a pointer to a new patchField created on freestore from
230
// a given fvPatchField mapped onto a new patch
231
static
tmp<fvPatchField<Type>
>
New
232
(
233
const
fvPatchField<Type>
&,
234
const
fvPatch
&,
235
const
DimensionedField<Type, volMesh>
&,
236
const
fvPatchFieldMapper
&
237
);
238
239
//- Return a pointer to a new patchField created on freestore
240
// from dictionary
241
static
tmp<fvPatchField<Type>
>
New
242
(
243
const
fvPatch
&,
244
const
DimensionedField<Type, volMesh>
&,
245
const
dictionary
&
246
);
247
248
//- Return a pointer to a new calculatedFvPatchField created on
249
// freestore without setting patchField values
250
template
<
class
Type2>
251
static
tmp<fvPatchField<Type>
>
NewCalculatedType
252
(
253
const
fvPatchField<Type2>
&
254
);
255
256
257
// Destructor
258
259
virtual
~
fvPatchField<Type>
()
260
{}
261
262
263
// Member functions
264
265
// Access
266
267
//- Return local objectRegistry
268
const
objectRegistry
&
db
()
const
;
269
270
//- Return patch
271
const
fvPatch
&
patch
()
const
272
{
273
return
patch_;
274
}
275
276
//- Return dimensioned internal field reference
277
const
DimensionedField<Type, volMesh>
&
278
dimensionedInternalField
()
const
279
{
280
return
internalField_;
281
}
282
283
//- Return internal field reference
284
const
Field<Type>
&
internalField
()
const
285
{
286
return
internalField_;
287
}
288
289
//- Return the type of the calculated for of fvPatchField
290
static
const
word
&
calculatedType
();
291
292
//- Return true if this patch field fixes a value.
293
// Needed to check if a level has to be specified while solving
294
// Poissons equations.
295
virtual
bool
fixesValue
()
const
296
{
297
return
false
;
298
}
299
300
//- Return true if this patch field is coupled
301
virtual
bool
coupled
()
const
302
{
303
return
false
;
304
}
305
306
//- Return true if the boundary condition has already been updated
307
bool
updated
()
const
308
{
309
return
updated_;
310
}
311
312
313
// Mapping functions
314
315
//- Map (and resize as needed) from self given a mapping object
316
virtual
void
autoMap
317
(
318
const
fvPatchFieldMapper
&
319
);
320
321
//- Reverse map the given fvPatchField onto this fvPatchField
322
virtual
void
rmap
323
(
324
const
fvPatchField<Type>
&,
325
const
labelList
&
326
);
327
328
329
// Evaluation functions
330
331
//- Return patch-normal gradient
332
virtual
tmp<Field<Type>
>
snGrad
()
const
;
333
334
//- Update the coefficients associated with the patch field
335
// Sets Updated to true
336
virtual
void
updateCoeffs
()
337
{
338
updated_ =
true
;
339
}
340
341
//- Return internal field next to patch as patch field
342
virtual
tmp<Field<Type>
>
patchInternalField
()
const
;
343
344
//- Return patchField on the opposite patch of a coupled patch
345
virtual
tmp<Field<Type>
>
patchNeighbourField
()
const
346
{
347
notImplemented
(
type
() +
"patchNeighbourField()"
);
348
return
*
this
;
349
}
350
351
//- Initialise the evaluation of the patch field
352
virtual
void
initEvaluate
353
(
354
const
Pstream::commsTypes
commsType=
Pstream::blocking
355
)
356
{}
357
358
//- Evaluate the patch field, sets Updated to false
359
virtual
void
evaluate
360
(
361
const
Pstream::commsTypes
commsType=
Pstream::blocking
362
);
363
364
365
//- Return the matrix diagonal coefficients corresponding to the
366
// evaluation of the value of this patchField with given weights
367
virtual
tmp<Field<Type>
>
valueInternalCoeffs
368
(
369
const
tmp
<
Field<scalar>
>&
370
)
const
371
{
372
notImplemented
373
(
374
type
()
375
+
"::valueInternalCoeffs(const tmp<Field<scalar> >&)"
376
);
377
return
*
this
;
378
}
379
380
//- Return the matrix source coefficients corresponding to the
381
// evaluation of the value of this patchField with given weights
382
virtual
tmp<Field<Type>
>
valueBoundaryCoeffs
383
(
384
const
tmp
<
Field<scalar>
>&
385
)
const
386
{
387
notImplemented
388
(
389
type
()
390
+
"::valueBoundaryCoeffs(const tmp<Field<scalar> >&)"
391
);
392
return
*
this
;
393
}
394
395
//- Return the matrix diagonal coefficients corresponding to the
396
// evaluation of the gradient of this patchField
397
virtual
tmp<Field<Type>
>
gradientInternalCoeffs
()
const
398
{
399
notImplemented
(
type
() +
"::gradientInternalCoeffs()"
);
400
return
*
this
;
401
}
402
403
//- Return the matrix source coefficients corresponding to the
404
// evaluation of the gradient of this patchField
405
virtual
tmp<Field<Type>
>
gradientBoundaryCoeffs
()
const
406
{
407
notImplemented
(
type
() +
"::gradientBoundaryCoeffs()"
);
408
return
*
this
;
409
}
410
411
412
//- Manipulate matrix
413
virtual
void
manipulateMatrix
(
fvMatrix<Type>
& matrix);
414
415
416
// I-O
417
418
//- Write
419
virtual
void
write
(
Ostream
&)
const
;
420
421
//- Helper function to write the keyword and entry only if the
422
// values are not equal. The value is then output as value2
423
template
<
class
EntryType>
424
void
writeEntryIfDifferent
425
(
426
Ostream
& os,
427
const
word
& entryName,
428
const
EntryType& value1,
429
const
EntryType& value2
430
)
const
;
431
432
433
// Check
434
435
//- Check fvPatchField<Type> against given fvPatchField<Type>
436
void
check
(
const
fvPatchField<Type>
&)
const
;
437
438
439
// Member operators
440
441
virtual
void
operator=
(
const
UList<Type>
&);
442
443
virtual
void
operator=
(
const
fvPatchField<Type>
&);
444
virtual
void
operator+=
(
const
fvPatchField<Type>
&);
445
virtual
void
operator-=
(
const
fvPatchField<Type>
&);
446
virtual
void
operator*=
(
const
fvPatchField<scalar>
&);
447
virtual
void
operator/=
(
const
fvPatchField<scalar>
&);
448
449
virtual
void
operator+=
(
const
Field<Type>
&);
450
virtual
void
operator-=
(
const
Field<Type>
&);
451
452
virtual
void
operator*=
(
const
Field<scalar>
&);
453
virtual
void
operator/=
(
const
Field<scalar>
&);
454
455
virtual
void
operator=
(
const
Type&);
456
virtual
void
operator+=
(
const
Type&);
457
virtual
void
operator-=
(
const
Type&);
458
virtual
void
operator*=
(
const
scalar);
459
virtual
void
operator/=
(
const
scalar);
460
461
462
// Force an assignment irrespective of form of patch
463
464
virtual
void
operator==
(
const
fvPatchField<Type>
&);
465
virtual
void
operator==
(
const
Field<Type>
&);
466
virtual
void
operator==
(
const
Type&);
467
468
469
// Ostream operator
470
471
friend
Ostream
& operator<< <Type>(
Ostream
&,
const
fvPatchField<Type>
&);
472
};
473
474
475
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
476
477
}
// End namespace Foam
478
479
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
480
481
#ifdef NoRepository
482
# include "
fvPatchField.C
"
483
# include <
finiteVolume/calculatedFvPatchField.H
>
484
#endif
485
486
487
#define makePatchTypeFieldTypeName(type) \
488
\
489
defineNamedTemplateTypeNameAndDebug(type, 0);
490
491
#define makePatchFieldsTypeName(type) \
492
\
493
makePatchTypeFieldTypeName(type##FvPatchScalarField); \
494
makePatchTypeFieldTypeName(type##FvPatchVectorField); \
495
makePatchTypeFieldTypeName(type##FvPatchSphericalTensorField); \
496
makePatchTypeFieldTypeName(type##FvPatchSymmTensorField); \
497
makePatchTypeFieldTypeName(type##FvPatchTensorField);
498
499
#define makePatchTypeField(PatchTypeField, typePatchTypeField) \
500
\
501
defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
502
\
503
addToRunTimeSelectionTable \
504
( \
505
PatchTypeField, typePatchTypeField, patch \
506
); \
507
\
508
addToRunTimeSelectionTable \
509
( \
510
PatchTypeField, \
511
typePatchTypeField, \
512
patchMapper \
513
); \
514
\
515
addToRunTimeSelectionTable \
516
( \
517
PatchTypeField, typePatchTypeField, dictionary \
518
);
519
520
521
#define makePatchFields(type) \
522
\
523
makePatchTypeField(fvPatchScalarField, type##FvPatchScalarField); \
524
makePatchTypeField(fvPatchVectorField, type##FvPatchVectorField); \
525
makePatchTypeField \
526
( \
527
fvPatchSphericalTensorField, \
528
type##FvPatchSphericalTensorField \
529
); \
530
makePatchTypeField(fvPatchSymmTensorField, type##FvPatchSymmTensorField); \
531
makePatchTypeField(fvPatchTensorField, type##FvPatchTensorField);
532
533
534
#define makePatchTypeFieldTypedefs(type) \
535
\
536
typedef type##FvPatchField<scalar> type##FvPatchScalarField; \
537
typedef type##FvPatchField<vector> type##FvPatchVectorField; \
538
typedef type##FvPatchField<sphericalTensor> \
539
type##FvPatchSphericalTensorField; \
540
typedef type##FvPatchField<symmTensor> type##FvPatchSymmTensorField; \
541
typedef type##FvPatchField<tensor> type##FvPatchTensorField;
542
543
544
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
545
546
#endif
547
548
// ************************ vim: set sw=4 sts=4 et: ************************ //