Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / finiteArea / fields / faPatchFields / faPatchField / faPatchField.H
bloba51592584002b9e8cb60deed7e70cb7492a03fe2
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     faPatchField
28 Description
29     faPatchField<Type> abstract base class.  This class gives a fat-interface
30     to all derived classes covering all possible ways in which they might be
31     used.  The first level of derivation is to basic patchFields which cover
32     zero-gradient, fixed-gradient, fixed-value and mixed conditions.  The next
33     level of derivation covers all the specialised typed with specific
34     evaluation proceedures, particularly with respect to specific fields.
36 SourceFiles
37     faPatchField.C
38     newPatchField.C
40 \*---------------------------------------------------------------------------*/
42 #ifndef faPatchField_H
43 #define faPatchField_H
45 #include "faPatch.H"
46 #include "DimensionedField.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 namespace Foam
53 // Class forward declarations
55 class objectRegistry;
56 class dictionary;
57 class faPatchFieldMapper;
58 class areaMesh;
61 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
63 template<class Type>
64 class faPatchField;
66 template<class Type>
67 Ostream& operator<<(Ostream&, const faPatchField<Type>&);
69 /*---------------------------------------------------------------------------*\
70                          Class faPatchField Declaration
71 \*---------------------------------------------------------------------------*/
73 template<class Type>
74 class faPatchField
76     public Field<Type>
78     // Private data
80         //- Reference to a patch
81         const faPatch& patch_;
83         //- Reference to internal field
84         const DimensionedField<Type, areaMesh>& internalField_;
86         //- Update index used so that updateCoeffs is called only once during
87         //  the construction of the matrix
88         bool updated_;
91 public:
93     typedef faPatch Patch;
96     //- Runtime type information
97     TypeName("faPatchField");
99     //- Debug switch to disallow the use of 
100     static int disallowDefaultFaPatchField;
103     // Declare run-time constructor selection tables
105         declareRunTimeSelectionTable
106         (
107             tmp,
108             faPatchField,
109             patch,
110             (
111                 const faPatch& p,
112                 const DimensionedField<Type, areaMesh>& iF
113             ),
114             (p, iF)
115         );
117         declareRunTimeSelectionTable
118         (
119             tmp,
120             faPatchField,
121             patchMapper,
122             (
123                 const faPatchField<Type>& ptf,
124                 const faPatch& p,
125                 const DimensionedField<Type, areaMesh>& iF,
126                 const faPatchFieldMapper& m
127             ),
128             (dynamic_cast<const faPatchFieldType&>(ptf), p, iF, m)
129         );
131         declareRunTimeSelectionTable
132         (
133             tmp,
134             faPatchField,
135             dictionary,
136             (
137                 const faPatch& p,
138                 const DimensionedField<Type, areaMesh>& iF,
139                 const dictionary& dict
140             ),
141             (p, iF, dict)
142         );
145     // Constructors
147         //- Construct from patch and internal field
148         faPatchField
149         (
150             const faPatch&,
151             const DimensionedField<Type, areaMesh>&
152         );
154         //- Construct from patch and internal field and patch field
155         faPatchField
156         (
157             const faPatch&,
158             const DimensionedField<Type, areaMesh>&,
159             const Field<Type>&
160         );
162         //- Construct from patch, internal field and dictionary
163         faPatchField
164         (
165             const faPatch&,
166             const DimensionedField<Type, areaMesh>&,
167             const dictionary&
168         );
170         //- Construct by mapping the given faPatchField onto a new patch
171         faPatchField
172         (
173             const faPatchField<Type>&,
174             const faPatch&,
175             const DimensionedField<Type, areaMesh>&,
176             const faPatchFieldMapper&
177         );
179         //- Construct as copy
180         faPatchField(const faPatchField<Type>&);
182         //- Construct and return a clone
183         virtual tmp<faPatchField<Type> > clone() const
184         {
185             return tmp<faPatchField<Type> >(new faPatchField<Type>(*this));
186         }
188         //- Construct as copy setting internal field reference
189         faPatchField
190         (
191             const faPatchField<Type>&,
192             const DimensionedField<Type, areaMesh>&
193         );
195         //- Construct and return a clone setting internal field reference
196         virtual tmp<faPatchField<Type> > clone
197         (
198             const DimensionedField<Type, areaMesh>& iF
199         ) const
200         {
201             return tmp<faPatchField<Type> >(new faPatchField<Type>(*this, iF));
202         }
205     // Selectors
207         //- Return a pointer to a new patchField created on freestore given
208         //  patch and internal field
209         //  (does not set the patch field values)
210         static tmp<faPatchField<Type> > New
211         (
212             const word&,
213             const faPatch&,
214             const DimensionedField<Type, areaMesh>&
215         );
217         //- Return a pointer to a new patchField created on freestore from
218         //  a given faPatchField mapped onto a new patch
219         static tmp<faPatchField<Type> > New
220         (
221             const faPatchField<Type>&,
222             const faPatch&,
223             const DimensionedField<Type, areaMesh>&,
224             const faPatchFieldMapper&
225         );
227         //- Return a pointer to a new patchField created on freestore
228         //  from dictionary
229         static tmp<faPatchField<Type> > New
230         (
231             const faPatch&,
232             const DimensionedField<Type, areaMesh>&,
233             const dictionary&
234         );
236         //- Return a pointer to a new calculatedFaPatchField created on
237         //  freestore without setting patchField values
238         template<class Type2>
239         static tmp<faPatchField<Type> > NewCalculatedType
240         (
241             const faPatchField<Type2>&
242         );
245     // Destructor
247         virtual ~faPatchField<Type>()
248         {}
251     // Member functions
253         // Access
255             //- Return local objectRegistry
256             const objectRegistry& db() const;
258             //- Return patch
259             const faPatch& patch() const
260             {
261                 return patch_;
262             }
264             //- Return dimensioned internal field reference
265             const DimensionedField<Type, areaMesh>&
266             dimensionedInternalField() const
267             {
268                 return internalField_;
269             }
271             //- Return internal field reference
272             const Field<Type>& internalField() const
273             {
274                 return internalField_;
275             }
277             //- Return the type of the calculated for of faPatchField
278             static const word& calculatedType();
280             //- Return true if this patch field fixes a value.
281             //  Needed to check if a level has to be specified while solving
282             //  Poissons equations.
283             virtual bool fixesValue() const
284             {
285                 return false;
286             }
288             //- Return true if this patch field is coupled
289             virtual bool coupled() const
290             {
291                 return false;
292             }
294             //- Return true if the boundary condition has already been updated
295             bool updated() const
296             {
297                 return updated_;
298             }
301         // Mapping functions
303             //- Map (and resize as needed) from self given a mapping object
304             virtual void autoMap
305             (
306                 const faPatchFieldMapper&
307             );
309             //- Reverse map the given faPatchField onto this faPatchField
310             virtual void rmap
311             (
312                 const faPatchField<Type>&,
313                 const labelList&
314             );
317         // Evaluation functions
319             //- Return patch-normal gradient
320             virtual tmp<Field<Type> > snGrad() const;
322             //- Update the coefficients associated with the patch field
323             //  Sets Updated to true
324             virtual void updateCoeffs()
325             {
326                 updated_ = true;
327             }
329             //- Return internal field next to patch as patch field
330             virtual tmp<Field<Type> > patchInternalField() const;
332             //- Return patchField on the opposite patch of a coupled patch
333             virtual tmp<Field<Type> > patchNeighbourField() const
334             {
335                 notImplemented(type() + "patchNeighbourField()");
336                 return *this;
337             }
339             //- Initialise the evaluation of the patch field
340             virtual void initEvaluate
341             (
342                 const Pstream::commsTypes commsType=Pstream::blocking
343             )
344             {}
346             //- Evaluate the patch field, sets Updated to false
347             virtual void evaluate
348             (
349                 const Pstream::commsTypes commsType=Pstream::blocking
350             );
353             //- Return the matrix diagonal coefficients corresponding to the
354             //  evaluation of the value of this patchField with given weights
355             virtual tmp<Field<Type> > valueInternalCoeffs
356             (
357                 const tmp<Field<scalar> >&
358             ) const
359             {
360                 notImplemented
361                 (
362                     type()
363                   + "::valueInternalCoeffs(const tmp<Field<scalar> >&)"
364                 );
365                 return *this;
366             }
368             //- Return the matrix source coefficients corresponding to the
369             //  evaluation of the value of this patchField with given weights
370             virtual tmp<Field<Type> > valueBoundaryCoeffs
371             (
372                 const tmp<Field<scalar> >&
373             ) const
374             {
375                 notImplemented
376                 (
377                     type()
378                   + "::valueBoundaryCoeffs(const tmp<Field<scalar> >&)"
379                 );
380                 return *this;
381             }
383             //- Return the matrix diagonal coefficients corresponding to the
384             //  evaluation of the gradient of this patchField
385             virtual tmp<Field<Type> > gradientInternalCoeffs() const
386             {
387                 notImplemented(type() + "::gradientInternalCoeffs()");
388                 return *this;
389             }
391             //- Return the matrix source coefficients corresponding to the
392             //  evaluation of the gradient of this patchField
393             virtual tmp<Field<Type> > gradientBoundaryCoeffs() const
394             {
395                 notImplemented(type() + "::gradientBoundaryCoeffs()");
396                 return *this;
397             }
400         //- Write
401         virtual void write(Ostream&) const;
404         // Check
406             //- Check faPatchField<Type> against given faPatchField<Type>
407             void check(const faPatchField<Type>&) const;
410     // Member operators
412         virtual void operator=(const UList<Type>&);
414         virtual void operator=(const faPatchField<Type>&);
415         virtual void operator+=(const faPatchField<Type>&);
416         virtual void operator-=(const faPatchField<Type>&);
417         virtual void operator*=(const faPatchField<scalar>&);
418         virtual void operator/=(const faPatchField<scalar>&);
420         virtual void operator+=(const Field<Type>&);
421         virtual void operator-=(const Field<Type>&);
423         virtual void operator*=(const Field<scalar>&);
424         virtual void operator/=(const Field<scalar>&);
426         virtual void operator=(const Type&);
427         virtual void operator+=(const Type&);
428         virtual void operator-=(const Type&);
429         virtual void operator*=(const scalar);
430         virtual void operator/=(const scalar);
433         // Force an assignment irrespective of form of patch
435         virtual void operator==(const faPatchField<Type>&);
436         virtual void operator==(const Field<Type>&);
437         virtual void operator==(const Type&);
440     // Ostream operator
442         friend Ostream& operator<< <Type>(Ostream&, const faPatchField<Type>&);
446 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
448 } // End namespace Foam
450 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
452 #ifdef NoRepository
453 #   include "faPatchField.C"
454 #   include "calculatedFaPatchField.H"
455 #endif
458 #define makeFaPatchTypeFieldTypeName(typePatchTypeField)                   \
459                                                                            \
460 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
462 #define makeFaPatchFieldsTypeName(typePatchField)                          \
463                                                                            \
464 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchScalarField);          \
465 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchVectorField);          \
466 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSphericalTensorField); \
467 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchSymmTensorField);      \
468 makeFaPatchTypeFieldTypeName(typePatchField##FaPatchTensorField);
470 #define makeFaPatchTypeField(PatchTypeField, typePatchTypeField)           \
471                                                                            \
472 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                \
473                                                                            \
474 addToRunTimeSelectionTable                                                 \
475 (                                                                          \
476     PatchTypeField, typePatchTypeField, patch                              \
477 );                                                                         \
478                                                                            \
479 addToRunTimeSelectionTable                                                 \
480 (                                                                          \
481     PatchTypeField,                                                        \
482     typePatchTypeField,                                                    \
483     patchMapper                                                            \
484 );                                                                         \
485                                                                            \
486 addToRunTimeSelectionTable                                                 \
487 (                                                                          \
488     PatchTypeField, typePatchTypeField, dictionary                         \
492 #define makeFaPatchFields(type)                                            \
493                                                                            \
494 makeFaPatchTypeField(faPatchScalarField, type##FaPatchScalarField);        \
495 makeFaPatchTypeField(faPatchVectorField, type##FaPatchVectorField);        \
496 makeFaPatchTypeField                                                       \
497 (                                                                          \
498     faPatchSphericalTensorField,                                           \
499     type##FaPatchSphericalTensorField                                      \
500 );                                                                         \
501 makeFaPatchTypeField(faPatchSymmTensorField, type##FaPatchSymmTensorField);\
502 makeFaPatchTypeField(faPatchTensorField, type##FaPatchTensorField);
505 #define makeFaPatchTypeFieldTypedefs(type)                                   \
506                                                                              \
507 typedef type##FaPatchField<scalar> type##FaPatchScalarField;                 \
508 typedef type##FaPatchField<vector> type##FaPatchVectorField;                 \
509 typedef type##FaPatchField<sphericalTensor>                                  \
510      type##FaPatchSphericalTensorField;                                      \
511 typedef type##FaPatchField<symmTensor> type##FaPatchSymmTensorField;         \
512 typedef type##FaPatchField<tensor> type##FaPatchTensorField;
515 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
517 #endif
519 // ************************************************************************* //