initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / fvsPatchField.H
blobe4a08be689d64eb79fd97eb2c102411b113eb9b6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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         );
170         //- Construct by mapping the given fvsPatchField onto a new patch
171         fvsPatchField
172         (
173             const fvsPatchField<Type>&,
174             const fvPatch&,
175             const DimensionedField<Type, surfaceMesh>&,
176             const fvPatchFieldMapper&
177         );
179         //- Construct as copy
180         fvsPatchField(const fvsPatchField<Type>&);
182         //- Construct and return a clone
183         virtual tmp<fvsPatchField<Type> > clone() const
184         {
185             return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
186         }
188         //- Construct as copy setting internal field reference
189         fvsPatchField
190         (
191             const fvsPatchField<Type>&,
192             const DimensionedField<Type, surfaceMesh>&
193         );
195         //- Construct and return a clone setting internal field reference
196         virtual tmp<fvsPatchField<Type> > clone
197         (
198             const DimensionedField<Type, surfaceMesh>& iF
199         ) const
200         {
201             return tmp<fvsPatchField<Type> >
202             (
203                 new fvsPatchField<Type>(*this, iF)
204             );
205         }
208     // Selectors
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         static tmp<fvsPatchField<Type> > New
214         (
215             const word&,
216             const fvPatch&,
217             const DimensionedField<Type, surfaceMesh>&
218         );
220         //- Return a pointer to a new patchField created on freestore from
221         //  a given fvsPatchField mapped onto a new patch
222         static tmp<fvsPatchField<Type> > New
223         (
224             const fvsPatchField<Type>&,
225             const fvPatch&,
226             const DimensionedField<Type, surfaceMesh>&,
227             const fvPatchFieldMapper&
228         );
230         //- Return a pointer to a new patchField created on freestore
231         //  from dictionary
232         static tmp<fvsPatchField<Type> > New
233         (
234             const fvPatch&,
235             const DimensionedField<Type, surfaceMesh>&,
236             const dictionary&
237         );
239         //- Return a pointer to a new calculatedFvsPatchField created on
240         //  freestore without setting patchField values
241         template<class Type2>
242         static tmp<fvsPatchField<Type> > NewCalculatedType
243         (
244             const fvsPatchField<Type2>&
245         );
248     // Destructor
250         virtual ~fvsPatchField<Type>()
251         {}
254     // Member functions
256         // Access
258             //- Return local objectRegistry
259             const objectRegistry& db() const;
261             //- Return patch
262             const fvPatch& patch() const
263             {
264                 return patch_;
265             }
267             //- Return dimensioned internal field reference
268             const DimensionedField<Type, surfaceMesh>&
269             dimensionedInternalField() const
270             {
271                 return internalField_;
272             }
274             //- Return internal field reference
275             const Field<Type>& internalField() const
276             {
277                 return internalField_;
278             }
280             //- Return the type of the calculated for of fvsPatchField
281             static const word& calculatedType();
283             //- Return true if this patch field fixes a value.
284             //  Needed to check if a level has to be specified while solving
285             //  Poissons equations.
286             virtual bool fixesValue() const
287             {
288                 return false;
289             }
291             //- Return true if this patch field is coupled
292             virtual bool coupled() const
293             {
294                 return false;
295             }
298         // Mapping functions
300             //- Map (and resize as needed) from self given a mapping object
301             virtual void autoMap
302             (
303                 const fvPatchFieldMapper&
304             );
306             //- Reverse map the given fvsPatchField onto this fvsPatchField
307             virtual void rmap
308             (
309                 const fvsPatchField<Type>&,
310                 const labelList&
311             );
314         //- Write
315         virtual void write(Ostream&) const;
318         // Check
320             //- Check fvsPatchField<Type> against given fvsPatchField<Type>
321             void check(const fvsPatchField<Type>&) const;
324     // Member operators
326         virtual void operator=(const UList<Type>&);
328         virtual void operator=(const fvsPatchField<Type>&);
329         virtual void operator+=(const fvsPatchField<Type>&);
330         virtual void operator-=(const fvsPatchField<Type>&);
331         virtual void operator*=(const fvsPatchField<scalar>&);
332         virtual void operator/=(const fvsPatchField<scalar>&);
334         virtual void operator+=(const Field<Type>&);
335         virtual void operator-=(const Field<Type>&);
337         virtual void operator*=(const Field<scalar>&);
338         virtual void operator/=(const Field<scalar>&);
340         virtual void operator=(const Type&);
341         virtual void operator+=(const Type&);
342         virtual void operator-=(const Type&);
343         virtual void operator*=(const scalar);
344         virtual void operator/=(const scalar);
347         // Force an assignment irrespective of form of patch
349         virtual void operator==(const fvsPatchField<Type>&);
350         virtual void operator==(const Field<Type>&);
351         virtual void operator==(const Type&);
354     // Ostream operator
356         friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 } // End namespace Foam
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
366 #ifdef NoRepository
367 #   include "fvsPatchField.C"
368 #   include "calculatedFvsPatchField.H"
369 #endif
372 #define makeFvsPatchTypeFieldTypeName(type)                                \
373                                                                            \
374 defineNamedTemplateTypeNameAndDebug(type, 0);
376 #define makeFvsPatchFieldsTypeName(type)                                   \
377                                                                            \
378 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField);                  \
379 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField);                  \
380 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField);         \
381 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField);              \
382 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
384 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField)          \
385                                                                            \
386 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                \
387                                                                            \
388 addToRunTimeSelectionTable                                                 \
389 (                                                                          \
390     PatchTypeField, typePatchTypeField, patch                              \
391 );                                                                         \
392                                                                            \
393 addToRunTimeSelectionTable                                                 \
394 (                                                                          \
395     PatchTypeField,                                                        \
396     typePatchTypeField,                                                    \
397     patchMapper                                                            \
398 );                                                                         \
399                                                                            \
400 addToRunTimeSelectionTable                                                 \
401 (                                                                          \
402     PatchTypeField, typePatchTypeField, dictionary                         \
406 #define makeFvsPatchFields(type)                                           \
407                                                                            \
408 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField);     \
409 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField);     \
410 makeFvsPatchTypeField                                                      \
411 (                                                                          \
412     fvsPatchSphericalTensorField,                                          \
413     type##FvsPatchSphericalTensorField                                     \
414 );                                                                         \
415 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
416 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
419 #define makeFvsPatchTypeFieldTypedefs(type)                                \
420                                                                            \
421 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField;             \
422 typedef type##FvsPatchField<vector> type##FvsPatchVectorField;             \
423 typedef type##FvsPatchField<sphericalTensor>                               \
424     type##FvsPatchSphericalTensorField;                                    \
425 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField;     \
426 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
429 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
431 #endif
433 // ************************************************************************* //