Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / fvsPatchField.H
blobe3f6f7e97f980f73b09e566f1476f2165c135181
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::fvsPatchField
28 Description
29     An abstract base class with a fat-interface to all derived classes
30     covering all possible ways in which they might be used.
32     The first level of derivation is to basic patchFields which cover
33     zero-gradient, fixed-gradient, fixed-value and mixed conditions.
35     The next level of derivation covers all the specialised typed with
36     specific evaluation proceedures, particularly with respect to specific
37     fields.
39 SourceFiles
40     fvsPatchField.C
41     newFvsPatchField.C
43 \*---------------------------------------------------------------------------*/
45 #ifndef fvsPatchField_H
46 #define fvsPatchField_H
48 #include "fvPatch.H"
49 #include "DimensionedField.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 namespace Foam
56 // Forward declaration of classes
58 class objectRegistry;
59 class dictionary;
60 class fvPatchFieldMapper;
61 class surfaceMesh;
64 // Forward declaration of friend functions and operators
66 template<class Type>
67 class fvsPatchField;
69 template<class Type>
70 Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
73 /*---------------------------------------------------------------------------*\
74                            Class patch Declaration
75 \*---------------------------------------------------------------------------*/
77 template<class Type>
78 class fvsPatchField
80     public Field<Type>
82     // Private data
84         //- Reference to patch
85         const fvPatch& patch_;
87         //- Reference to internal field
88         const DimensionedField<Type, surfaceMesh>& internalField_;
91 public:
93     typedef fvPatch Patch;
96     //- Runtime type information
97     TypeName("fvsPatchField");
99     //- Debug switch to disallow the use of
100     static int disallowDefaultFvsPatchField;
103     // Declare run-time constructor selection tables
105         declareRunTimeSelectionTable
106         (
107             tmp,
108             fvsPatchField,
109             patch,
110             (
111                 const fvPatch& p,
112                 const DimensionedField<Type, surfaceMesh>& iF
113             ),
114             (p, iF)
115         );
117         declareRunTimeSelectionTable
118         (
119             tmp,
120             fvsPatchField,
121             patchMapper,
122             (
123                 const fvsPatchField<Type>& ptf,
124                 const fvPatch& p,
125                 const DimensionedField<Type, surfaceMesh>& iF,
126                 const fvPatchFieldMapper& m
127             ),
128             (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
129         );
131         declareRunTimeSelectionTable
132         (
133             tmp,
134             fvsPatchField,
135             dictionary,
136             (
137                 const fvPatch& p,
138                 const DimensionedField<Type, surfaceMesh>& iF,
139                 const dictionary& dict
140             ),
141             (p, iF, dict)
142         );
145     // Constructors
147         //- Construct from patch and internal field
148         fvsPatchField
149         (
150             const fvPatch&,
151             const DimensionedField<Type, surfaceMesh>&
152         );
154         //- Construct from patch and internal field and patch field
155         fvsPatchField
156         (
157             const fvPatch&,
158             const DimensionedField<Type, surfaceMesh>&,
159             const Field<Type>&
160         );
162         //- Construct from patch, internal field and dictionary
163         fvsPatchField
164         (
165             const fvPatch&,
166             const DimensionedField<Type, surfaceMesh>&,
167             const dictionary&,
168             const bool valueRequired = false
169         );
171         //- Construct by mapping the given fvsPatchField onto a new patch
172         fvsPatchField
173         (
174             const fvsPatchField<Type>&,
175             const fvPatch&,
176             const DimensionedField<Type, surfaceMesh>&,
177             const fvPatchFieldMapper&
178         );
180         //- Construct as copy
181         fvsPatchField(const fvsPatchField<Type>&);
183         //- Construct and return a clone
184         virtual tmp<fvsPatchField<Type> > clone() const
185         {
186             return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
187         }
189         //- Construct as copy setting internal field reference
190         fvsPatchField
191         (
192             const fvsPatchField<Type>&,
193             const DimensionedField<Type, surfaceMesh>&
194         );
196         //- Construct and return a clone setting internal field reference
197         virtual tmp<fvsPatchField<Type> > clone
198         (
199             const DimensionedField<Type, surfaceMesh>& iF
200         ) const
201         {
202             return tmp<fvsPatchField<Type> >
203             (
204                 new fvsPatchField<Type>(*this, iF)
205             );
206         }
209     // Selectors
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         static tmp<fvsPatchField<Type> > New
215         (
216             const word&,
217             const fvPatch&,
218             const DimensionedField<Type, surfaceMesh>&
219         );
221         //- Return a pointer to a new patchField created on freestore from
222         //  a given fvsPatchField mapped onto a new patch
223         static tmp<fvsPatchField<Type> > New
224         (
225             const fvsPatchField<Type>&,
226             const fvPatch&,
227             const DimensionedField<Type, surfaceMesh>&,
228             const fvPatchFieldMapper&
229         );
231         //- Return a pointer to a new patchField created on freestore
232         //  from dictionary
233         static tmp<fvsPatchField<Type> > New
234         (
235             const fvPatch&,
236             const DimensionedField<Type, surfaceMesh>&,
237             const dictionary&
238         );
240         //- Return a pointer to a new calculatedFvsPatchField created on
241         //  freestore without setting patchField values
242         template<class Type2>
243         static tmp<fvsPatchField<Type> > NewCalculatedType
244         (
245             const fvsPatchField<Type2>&
246         );
249     // Destructor
251         virtual ~fvsPatchField<Type>()
252         {}
255     // Member functions
257         // Access
259             //- Return local objectRegistry
260             const objectRegistry& db() const;
262             //- Return patch
263             const fvPatch& patch() const
264             {
265                 return patch_;
266             }
268             //- Return dimensioned internal field reference
269             const DimensionedField<Type, surfaceMesh>&
270             dimensionedInternalField() const
271             {
272                 return internalField_;
273             }
275             //- Return internal field reference
276             const Field<Type>& internalField() const
277             {
278                 return internalField_;
279             }
281             //- Return the type of the calculated for of fvsPatchField
282             static const word& calculatedType();
284             //- Return true if this patch field fixes a value.
285             //  Needed to check if a level has to be specified while solving
286             //  Poissons equations.
287             virtual bool fixesValue() const
288             {
289                 return false;
290             }
292             //- Return true if this patch field is coupled
293             virtual bool coupled() const
294             {
295                 return false;
296             }
299         // Mapping functions
301             //- Map (and resize as needed) from self given a mapping object
302             virtual void autoMap
303             (
304                 const fvPatchFieldMapper&
305             );
307             //- Reverse map the given fvsPatchField onto this fvsPatchField
308             virtual void rmap
309             (
310                 const fvsPatchField<Type>&,
311                 const labelList&
312             );
315         //- Write
316         virtual void write(Ostream&) const;
319         // Check
321             //- Check fvsPatchField<Type> against given fvsPatchField<Type>
322             void check(const fvsPatchField<Type>&) const;
325     // Member operators
327         virtual void operator=(const UList<Type>&);
329         virtual void operator=(const fvsPatchField<Type>&);
330         virtual void operator+=(const fvsPatchField<Type>&);
331         virtual void operator-=(const fvsPatchField<Type>&);
332         virtual void operator*=(const fvsPatchField<scalar>&);
333         virtual void operator/=(const fvsPatchField<scalar>&);
335         virtual void operator+=(const Field<Type>&);
336         virtual void operator-=(const Field<Type>&);
338         virtual void operator*=(const Field<scalar>&);
339         virtual void operator/=(const Field<scalar>&);
341         virtual void operator=(const Type&);
342         virtual void operator+=(const Type&);
343         virtual void operator-=(const Type&);
344         virtual void operator*=(const scalar);
345         virtual void operator/=(const scalar);
348         // Force an assignment irrespective of form of patch
350         virtual void operator==(const fvsPatchField<Type>&);
351         virtual void operator==(const Field<Type>&);
352         virtual void operator==(const Type&);
355     // Ostream operator
357         friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
361 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363 } // End namespace Foam
365 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367 #ifdef NoRepository
368 #   include "fvsPatchField.C"
369 #   include "calculatedFvsPatchField.H"
370 #endif
373 #define makeFvsPatchTypeFieldTypeName(type)                                \
374                                                                            \
375 defineNamedTemplateTypeNameAndDebug(type, 0);
377 #define makeFvsPatchFieldsTypeName(type)                                   \
378                                                                            \
379 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField);                  \
380 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField);                  \
381 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField);         \
382 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField);              \
383 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
385 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField)          \
386                                                                            \
387 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                \
388                                                                            \
389 addToRunTimeSelectionTable                                                 \
390 (                                                                          \
391     PatchTypeField, typePatchTypeField, patch                              \
392 );                                                                         \
393                                                                            \
394 addToRunTimeSelectionTable                                                 \
395 (                                                                          \
396     PatchTypeField,                                                        \
397     typePatchTypeField,                                                    \
398     patchMapper                                                            \
399 );                                                                         \
400                                                                            \
401 addToRunTimeSelectionTable                                                 \
402 (                                                                          \
403     PatchTypeField, typePatchTypeField, dictionary                         \
407 #define makeFvsPatchFields(type)                                           \
408                                                                            \
409 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField);     \
410 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField);     \
411 makeFvsPatchTypeField                                                      \
412 (                                                                          \
413     fvsPatchSphericalTensorField,                                          \
414     type##FvsPatchSphericalTensorField                                     \
415 );                                                                         \
416 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
417 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
420 #define makeFvsPatchTypeFieldTypedefs(type)                                \
421                                                                            \
422 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField;             \
423 typedef type##FvsPatchField<vector> type##FvsPatchVectorField;             \
424 typedef type##FvsPatchField<sphericalTensor>                               \
425     type##FvsPatchSphericalTensorField;                                    \
426 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField;     \
427 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
430 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
432 #endif
434 // ************************************************************************* //