BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvsPatchFields / fvsPatchField / fvsPatchField.H
blob14c7de46f41159a1617e4000c621fe13d4b7ad6d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::fvsPatchField
27 Description
28     An abstract base class with a fat-interface to all derived classes
29     covering all possible ways in which they might be used.
31     The first level of derivation is to basic patchFields which cover
32     zero-gradient, fixed-gradient, fixed-value and mixed conditions.
34     The next level of derivation covers all the specialised typed with
35     specific evaluation proceedures, particularly with respect to specific
36     fields.
38 SourceFiles
39     fvsPatchField.C
40     fvsPatchFieldNew.C
42 \*---------------------------------------------------------------------------*/
44 #ifndef fvsPatchField_H
45 #define fvsPatchField_H
47 #include "fvPatch.H"
48 #include "DimensionedField.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 // Forward declaration of classes
57 class objectRegistry;
58 class dictionary;
59 class fvPatchFieldMapper;
60 class surfaceMesh;
63 // Forward declaration of friend functions and operators
65 template<class Type>
66 class fvsPatchField;
68 template<class Type>
69 Ostream& operator<<(Ostream&, const fvsPatchField<Type>&);
72 /*---------------------------------------------------------------------------*\
73                            Class patch Declaration
74 \*---------------------------------------------------------------------------*/
76 template<class Type>
77 class fvsPatchField
79     public Field<Type>
81     // Private data
83         //- Reference to patch
84         const fvPatch& patch_;
86         //- Reference to internal field
87         const DimensionedField<Type, surfaceMesh>& internalField_;
90 public:
92     typedef fvPatch Patch;
95     //- Runtime type information
96     TypeName("fvsPatchField");
98     //- Debug switch to disallow the use of genericFvsPatchField
99     static int disallowGenericFvsPatchField;
102     // Declare run-time constructor selection tables
104         declareRunTimeSelectionTable
105         (
106             tmp,
107             fvsPatchField,
108             patch,
109             (
110                 const fvPatch& p,
111                 const DimensionedField<Type, surfaceMesh>& iF
112             ),
113             (p, iF)
114         );
116         declareRunTimeSelectionTable
117         (
118             tmp,
119             fvsPatchField,
120             patchMapper,
121             (
122                 const fvsPatchField<Type>& ptf,
123                 const fvPatch& p,
124                 const DimensionedField<Type, surfaceMesh>& iF,
125                 const fvPatchFieldMapper& m
126             ),
127             (dynamic_cast<const fvsPatchFieldType&>(ptf), p, iF, m)
128         );
130         declareRunTimeSelectionTable
131         (
132             tmp,
133             fvsPatchField,
134             dictionary,
135             (
136                 const fvPatch& p,
137                 const DimensionedField<Type, surfaceMesh>& iF,
138                 const dictionary& dict
139             ),
140             (p, iF, dict)
141         );
144     // Constructors
146         //- Construct from patch and internal field
147         fvsPatchField
148         (
149             const fvPatch&,
150             const DimensionedField<Type, surfaceMesh>&
151         );
153         //- Construct from patch and internal field and patch field
154         fvsPatchField
155         (
156             const fvPatch&,
157             const DimensionedField<Type, surfaceMesh>&,
158             const Field<Type>&
159         );
161         //- Construct from patch, internal field and dictionary
162         fvsPatchField
163         (
164             const fvPatch&,
165             const DimensionedField<Type, surfaceMesh>&,
166             const dictionary&
167         );
169         //- Construct by mapping the given fvsPatchField onto a new patch
170         fvsPatchField
171         (
172             const fvsPatchField<Type>&,
173             const fvPatch&,
174             const DimensionedField<Type, surfaceMesh>&,
175             const fvPatchFieldMapper&
176         );
178         //- Construct as copy
179         fvsPatchField(const fvsPatchField<Type>&);
181         //- Construct and return a clone
182         virtual tmp<fvsPatchField<Type> > clone() const
183         {
184             return tmp<fvsPatchField<Type> >(new fvsPatchField<Type>(*this));
185         }
187         //- Construct as copy setting internal field reference
188         fvsPatchField
189         (
190             const fvsPatchField<Type>&,
191             const DimensionedField<Type, surfaceMesh>&
192         );
194         //- Construct and return a clone setting internal field reference
195         virtual tmp<fvsPatchField<Type> > clone
196         (
197             const DimensionedField<Type, surfaceMesh>& iF
198         ) const
199         {
200             return tmp<fvsPatchField<Type> >
201             (
202                 new fvsPatchField<Type>(*this, iF)
203             );
204         }
207     // Selectors
209         //- Return a pointer to a new patchField created on freestore given
210         //  patch and internal field
211         //  (does not set the patch field values)
212         static tmp<fvsPatchField<Type> > New
213         (
214             const word&,
215             const fvPatch&,
216             const DimensionedField<Type, surfaceMesh>&
217         );
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         //  Allows override of constraint type
223         static tmp<fvsPatchField<Type> > New
224         (
225             const word&,
226             const word& actualPatchType, 
227             const fvPatch&,
228             const DimensionedField<Type, surfaceMesh>&
229         );
231         //- Return a pointer to a new patchField created on freestore from
232         //  a given fvsPatchField mapped onto a new patch
233         static tmp<fvsPatchField<Type> > New
234         (
235             const fvsPatchField<Type>&,
236             const fvPatch&,
237             const DimensionedField<Type, surfaceMesh>&,
238             const fvPatchFieldMapper&
239         );
241         //- Return a pointer to a new patchField created on freestore
242         //  from dictionary
243         static tmp<fvsPatchField<Type> > New
244         (
245             const fvPatch&,
246             const DimensionedField<Type, surfaceMesh>&,
247             const dictionary&
248         );
250         //- Return a pointer to a new calculatedFvsPatchField created on
251         //  freestore without setting patchField values
252         template<class Type2>
253         static tmp<fvsPatchField<Type> > NewCalculatedType
254         (
255             const fvsPatchField<Type2>&
256         );
259     //- Destructor
260     virtual ~fvsPatchField<Type>()
261     {}
264     // Member functions
266         // Access
268             //- Return local objectRegistry
269             const objectRegistry& db() const;
271             //- Return patch
272             const fvPatch& patch() const
273             {
274                 return patch_;
275             }
277             //- Return dimensioned internal field reference
278             const DimensionedField<Type, surfaceMesh>&
279             dimensionedInternalField() const
280             {
281                 return internalField_;
282             }
284             //- Return internal field reference
285             const Field<Type>& internalField() const
286             {
287                 return internalField_;
288             }
290             //- Return the type of the calculated for of fvsPatchField
291             static const word& calculatedType();
293             //- Return true if this patch field fixes a value.
294             //  Needed to check if a level has to be specified while solving
295             //  Poissons equations.
296             virtual bool fixesValue() const
297             {
298                 return false;
299             }
301             //- Return true if this patch field is coupled
302             virtual bool coupled() const
303             {
304                 return false;
305             }
308         // Mapping functions
310             //- Map (and resize as needed) from self given a mapping object
311             virtual void autoMap
312             (
313                 const fvPatchFieldMapper&
314             );
316             //- Reverse map the given fvsPatchField onto this fvsPatchField
317             virtual void rmap
318             (
319                 const fvsPatchField<Type>&,
320                 const labelList&
321             );
324         //- Write
325         virtual void write(Ostream&) const;
328         // Check
330             //- Check fvsPatchField<Type> against given fvsPatchField<Type>
331             void check(const fvsPatchField<Type>&) const;
334     // Member operators
336         virtual void operator=(const UList<Type>&);
338         virtual void operator=(const fvsPatchField<Type>&);
339         virtual void operator+=(const fvsPatchField<Type>&);
340         virtual void operator-=(const fvsPatchField<Type>&);
341         virtual void operator*=(const fvsPatchField<scalar>&);
342         virtual void operator/=(const fvsPatchField<scalar>&);
344         virtual void operator+=(const Field<Type>&);
345         virtual void operator-=(const Field<Type>&);
347         virtual void operator*=(const Field<scalar>&);
348         virtual void operator/=(const Field<scalar>&);
350         virtual void operator=(const Type&);
351         virtual void operator+=(const Type&);
352         virtual void operator-=(const Type&);
353         virtual void operator*=(const scalar);
354         virtual void operator/=(const scalar);
357         // Force an assignment irrespective of form of patch
359         virtual void operator==(const fvsPatchField<Type>&);
360         virtual void operator==(const Field<Type>&);
361         virtual void operator==(const Type&);
364     // Ostream operator
366         friend Ostream& operator<< <Type>(Ostream&, const fvsPatchField<Type>&);
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
372 } // End namespace Foam
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376 #ifdef NoRepository
377 #   include "fvsPatchField.C"
378 #   include "calculatedFvsPatchField.H"
379 #endif
382 #define makeFvsPatchTypeFieldTypeName(type)                                \
383                                                                            \
384 defineNamedTemplateTypeNameAndDebug(type, 0);
386 #define makeFvsPatchFieldsTypeName(type)                                   \
387                                                                            \
388 makeFvsPatchTypeFieldTypeName(type##FvsPatchScalarField);                  \
389 makeFvsPatchTypeFieldTypeName(type##FvsPatchVectorField);                  \
390 makeFvsPatchTypeFieldTypeName(type##FvsPatchSphericalTensorField);         \
391 makeFvsPatchTypeFieldTypeName(type##FvsPatchSymmTensorField);              \
392 makeFvsPatchTypeFieldTypeName(type##FvsPatchTensorField);
394 #define makeFvsPatchTypeField(PatchTypeField, typePatchTypeField)          \
395                                                                            \
396 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                \
397                                                                            \
398 addToRunTimeSelectionTable                                                 \
399 (                                                                          \
400     PatchTypeField, typePatchTypeField, patch                              \
401 );                                                                         \
402                                                                            \
403 addToRunTimeSelectionTable                                                 \
404 (                                                                          \
405     PatchTypeField,                                                        \
406     typePatchTypeField,                                                    \
407     patchMapper                                                            \
408 );                                                                         \
409                                                                            \
410 addToRunTimeSelectionTable                                                 \
411 (                                                                          \
412     PatchTypeField, typePatchTypeField, dictionary                         \
416 #define makeFvsPatchFields(type)                                           \
417                                                                            \
418 makeFvsPatchTypeField(fvsPatchScalarField, type##FvsPatchScalarField);     \
419 makeFvsPatchTypeField(fvsPatchVectorField, type##FvsPatchVectorField);     \
420 makeFvsPatchTypeField                                                      \
421 (                                                                          \
422     fvsPatchSphericalTensorField,                                          \
423     type##FvsPatchSphericalTensorField                                     \
424 );                                                                         \
425 makeFvsPatchTypeField(fvsPatchSymmTensorField, type##FvsPatchSymmTensorField); \
426 makeFvsPatchTypeField(fvsPatchTensorField, type##FvsPatchTensorField);
429 #define makeFvsPatchTypeFieldTypedefs(type)                                \
430                                                                            \
431 typedef type##FvsPatchField<scalar> type##FvsPatchScalarField;             \
432 typedef type##FvsPatchField<vector> type##FvsPatchVectorField;             \
433 typedef type##FvsPatchField<sphericalTensor>                               \
434     type##FvsPatchSphericalTensorField;                                    \
435 typedef type##FvsPatchField<symmTensor> type##FvsPatchSymmTensorField;     \
436 typedef type##FvsPatchField<tensor> type##FvsPatchTensorField;
439 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
441 #endif
443 // ************************************************************************* //