fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / fvsPatchField.H
blobcbe1ac81896849bab5f46c4bab7d8e3bdb1aaa6c
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 #ifndef SWIG
106         declareRunTimeSelectionTable
107         (
108             tmp,
109             fvsPatchField,
110             patch,
111             (
112                 const fvPatch& p,
113                 const DimensionedField<Type, surfaceMesh>& iF
114             ),
115             (p, iF)
116         );
118         declareRunTimeSelectionTable
119         (
120             tmp,
121             fvsPatchField,
122             patchMapper,
123             (
124                 const fvsPatchField<Type>& ptf,
125                 const fvPatch& p,
126                 const DimensionedField<Type, surfaceMesh>& iF,
127                 const fvPatchFieldMapper& m
128             ),
129             (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
130         );
132         declareRunTimeSelectionTable
133         (
134             tmp,
135             fvsPatchField,
136             dictionary,
137             (
138                 const fvPatch& p,
139                 const DimensionedField<Type, surfaceMesh>& iF,
140                 const dictionary& dict
141             ),
142             (p, iF, dict)
143         );
144 #endif
146     // Constructors
148         //- Construct from patch and internal field
149         fvsPatchField
150         (
151             const fvPatch&,
152             const DimensionedField<Type, surfaceMesh>&
153         );
155         //- Construct from patch and internal field and patch field
156         fvsPatchField
157         (
158             const fvPatch&,
159             const DimensionedField<Type, surfaceMesh>&,
160             const Field<Type>&
161         );
163         //- Construct from patch, internal field and dictionary
164         fvsPatchField
165         (
166             const fvPatch&,
167             const DimensionedField<Type, surfaceMesh>&,
168             const dictionary&,
169             const bool valueRequired = false
170         );
172         //- Construct by mapping the given fvsPatchField onto a new patch
173         fvsPatchField
174         (
175             const fvsPatchField<Type>&,
176             const fvPatch&,
177             const DimensionedField<Type, surfaceMesh>&,
178             const fvPatchFieldMapper&
179         );
181         //- Construct as copy
182         fvsPatchField(const fvsPatchField<Type>&);
184         //- Construct and return a clone
185         virtual tmp<fvsPatchField<Type> > clone() const
186         {
187             return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
188         }
190         //- Construct as copy setting internal field reference
191         fvsPatchField
192         (
193             const fvsPatchField<Type>&,
194             const DimensionedField<Type, surfaceMesh>&
195         );
197         //- Construct and return a clone setting internal field reference
198         virtual tmp<fvsPatchField<Type> > clone
199         (
200             const DimensionedField<Type, surfaceMesh>& iF
201         ) const
202         {
203             return tmp<fvsPatchField<Type> >
204             (
205                 new fvsPatchField<Type>(*this, iF)
206             );
207         }
210     // Selectors
212         //- Return a pointer to a new patchField created on freestore given
213         //  patch and internal field
214         //  (does not set the patch field values)
215         static tmp<fvsPatchField<Type> > New
216         (
217             const word&,
218             const fvPatch&,
219             const DimensionedField<Type, surfaceMesh>&
220         );
222         //- Return a pointer to a new patchField created on freestore from
223         //  a given fvsPatchField mapped onto a new patch
224         static tmp<fvsPatchField<Type> > New
225         (
226             const fvsPatchField<Type>&,
227             const fvPatch&,
228             const DimensionedField<Type, surfaceMesh>&,
229             const fvPatchFieldMapper&
230         );
232         //- Return a pointer to a new patchField created on freestore
233         //  from dictionary
234         static tmp<fvsPatchField<Type> > New
235         (
236             const fvPatch&,
237             const DimensionedField<Type, surfaceMesh>&,
238             const dictionary&
239         );
241         //- Return a pointer to a new calculatedFvsPatchField created on
242         //  freestore without setting patchField values
243         template<class Type2>
244         static tmp<fvsPatchField<Type> > NewCalculatedType
245         (
246             const fvsPatchField<Type2>&
247         );
250     // Destructor
252         virtual ~fvsPatchField<Type>()
253         {}
256     // Member functions
258         // Access
260             //- Return local objectRegistry
261             const objectRegistry& db() const;
263             //- Return patch
264             const fvPatch& patch() const
265             {
266                 return patch_;
267             }
269             //- Return dimensioned internal field reference
270             const DimensionedField<Type, surfaceMesh>&
271             dimensionedInternalField() const
272             {
273                 return internalField_;
274             }
276             //- Return internal field reference
277             const Field<Type>& internalField() const
278             {
279                 return internalField_;
280             }
282             //- Return the type of the calculated for of fvsPatchField
283             static const word& calculatedType();
285             //- Return true if this patch field fixes a value.
286             //  Needed to check if a level has to be specified while solving
287             //  Poissons equations.
288             virtual bool fixesValue() const
289             {
290                 return false;
291             }
293             //- Return true if this patch field is coupled
294             virtual bool coupled() const
295             {
296                 return false;
297             }
300         // Mapping functions
302             //- Map (and resize as needed) from self given a mapping object
303             virtual void autoMap
304             (
305                 const fvPatchFieldMapper&
306             );
308             //- Reverse map the given fvsPatchField onto this fvsPatchField
309             virtual void rmap
310             (
311                 const fvsPatchField<Type>&,
312                 const labelList&
313             );
316         //- Write
317         virtual void write(Ostream&) const;
320         // Check
322             //- Check fvsPatchField<Type> against given fvsPatchField<Type>
323             void check(const fvsPatchField<Type>&) const;
326     // Member operators
328         virtual void operator=(const UList<Type>&);
330         virtual void operator=(const fvsPatchField<Type>&);
331         virtual void operator+=(const fvsPatchField<Type>&);
332         virtual void operator-=(const fvsPatchField<Type>&);
333         virtual void operator*=(const fvsPatchField<scalar>&);
334         virtual void operator/=(const fvsPatchField<scalar>&);
336         virtual void operator+=(const Field<Type>&);
337         virtual void operator-=(const Field<Type>&);
339         virtual void operator*=(const Field<scalar>&);
340         virtual void operator/=(const Field<scalar>&);
342         virtual void operator=(const Type&);
343         virtual void operator+=(const Type&);
344         virtual void operator-=(const Type&);
345         virtual void operator*=(const scalar);
346         virtual void operator/=(const scalar);
349         // Force an assignment irrespective of form of patch
351         virtual void operator==(const fvsPatchField<Type>&);
352         virtual void operator==(const Field<Type>&);
353         virtual void operator==(const Type&);
356     // Ostream operator
358 #ifndef SWIG
359         friend Ostream& operator<< <Type>
360         (
361             Ostream&,
362             const fvsPatchField<Type>&
363         );
364 #endif
368 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
370 } // End namespace Foam
372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
374 #ifdef NoRepository
375 #   include "fvsPatchField.C"
376 #   include "calculatedFvsPatchField.H"
377 #endif
380 #define makeFvsPatchTypeFieldTypeName(type)                                \
381                                                                            \
382 defineNamedTemplateTypeNameAndDebug(type, 0);
384 #define makeFvsPatchFieldsTypeName(type)                                   \
385                                                                            \
386 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField);                  \
387 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField);                  \
388 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField);         \
389 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField);              \
390 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
392 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField)          \
393                                                                            \
394 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                \
395                                                                            \
396 addToRunTimeSelectionTable                                                 \
397 (                                                                          \
398     PatchTypeField, typePatchTypeField, patch                              \
399 );                                                                         \
400                                                                            \
401 addToRunTimeSelectionTable                                                 \
402 (                                                                          \
403     PatchTypeField,                                                        \
404     typePatchTypeField,                                                    \
405     patchMapper                                                            \
406 );                                                                         \
407                                                                            \
408 addToRunTimeSelectionTable                                                 \
409 (                                                                          \
410     PatchTypeField, typePatchTypeField, dictionary                         \
414 #define makeFvsPatchFields(type)                                           \
415                                                                            \
416 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField);     \
417 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField);     \
418 makeFvsPatchTypeField                                                      \
419 (                                                                          \
420     fvsPatchSphericalTensorField,                                          \
421     type##FvsPatchSphericalTensorField                                     \
422 );                                                                         \
423 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
424 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
427 #define makeFvsPatchTypeFieldTypedefs(type)                                \
428                                                                            \
429 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField;             \
430 typedef type##FvsPatchField<vector> type##FvsPatchVectorField;             \
431 typedef type##FvsPatchField<sphericalTensor>                               \
432     type##FvsPatchSphericalTensorField;                                    \
433 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField;     \
434 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
437 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
439 #endif
441 // ************************************************************************* //