OpenFOAM logo
Open Source CFD Toolkit

PointPatchField.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     PointPatchField
00027 
00028 Description
00029     Abstract base class for tetrahedral mesh patch fields. Note the special
00030     mechanism at work here: the field itself holds no values, as the point
00031     values belong to the internal field. However, the field will create a
00032     list of values if required.
00033 
00034 SourceFiles
00035     PointPatchField.C
00036     newPointPatchField.C
00037 
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef PointPatchField_H
00041 #define PointPatchField_H
00042 
00043 #include "primitiveFields.H"
00044 #include "lduCoupledInterface.H"
00045 #include "autoPtr.H"
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 // Class forward declarations
00053 
00054 template<template<class> class PatchField, class PointPatch, class Type>
00055 class PointPatchField;
00056 
00057 class objectRegistry;
00058 class dictionary;
00059 class PointPatchFieldMapper;
00060 class lduMatrix;
00061 
00062 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00063 
00064 template<template<class> class PatchField, class PointPatch, class Type>
00065 Ostream& operator<<
00066 (
00067     Ostream&,
00068     const PointPatchField<PatchField, PointPatch, Type>&
00069 );
00070 
00071 
00072 /*---------------------------------------------------------------------------*\
00073                        Class PointPatchField Declaration
00074 \*---------------------------------------------------------------------------*/
00075 
00076 template<template<class> class PatchField, class PointPatch, class Type>
00077 class PointPatchField
00078 :
00079     public lduCoupledInterface
00080 {
00081     // Private data
00082 
00083         //- Reference to patch
00084         const PointPatch& patch_;
00085 
00086         //- Reference to internal field
00087         const Field<Type>& internalField_;
00088 
00089 
00090     // Private member functions
00091 
00092         void checkInternalField() const;
00093 
00094 
00095 public:
00096 
00097     typedef PointPatch Patch;
00098     typedef PatchField<Type> pointPatchTypeField;
00099 
00100     //- Runtime type information
00101     TypeName("PointPatchField");
00102 
00103 
00104     // Declare run-time constructor selection tables
00105 
00106         declareRunTimeSelectionTable
00107         (
00108             autoPtr,
00109             pointPatchTypeField,
00110             PointPatch,
00111             (const PointPatch& p, const Field<Type>& iF),
00112             (p, iF)
00113         );
00114 
00115         declareRunTimeSelectionTable
00116         (
00117             autoPtr,
00118             pointPatchTypeField,
00119             patchMapper,
00120             (
00121                 const PointPatchField<PatchField, PointPatch, Type>& ptf,
00122                 const PointPatch& p,
00123                 const Field<Type>& iF,
00124                 const PointPatchFieldMapper& m
00125             ),
00126             (dynamic_cast<const pointPatchTypeFieldType&>(ptf), p, iF, m)
00127         );
00128 
00129         declareRunTimeSelectionTable
00130         (
00131             autoPtr,
00132             pointPatchTypeField,
00133             dictionary,
00134             (
00135                 const PointPatch& p,
00136                 const Field<Type>& iF,
00137                 const dictionary& dict
00138             ),
00139             (p, iF, dict)
00140         );
00141 
00142 
00143     // Constructors
00144 
00145         //- Construct from patch and internal field
00146         PointPatchField
00147         (
00148             const PointPatch&,
00149             const Field<Type>&
00150         );
00151 
00152         //- Construct as copy
00153         PointPatchField(const PointPatchField<PatchField, PointPatch, Type>&);
00154 
00155         //- Construct and return a clone
00156         virtual autoPtr<PatchField<Type> > clone() const = 0;
00157 
00158         //- Construct as copy setting internal field reference
00159         PointPatchField
00160         (
00161             const PointPatchField<PatchField, PointPatch, Type>&,
00162             const Field<Type>&
00163         );
00164 
00165         //- Construct and return a clone setting internal field reference
00166         virtual autoPtr<PatchField<Type> > clone
00167         (
00168             const Field<Type>& iF
00169         ) const = 0;
00170 
00171 
00172     // Selectors
00173 
00174         //- Return a pointer to a new patchField created on freestore given
00175         //  patch and internal field
00176         //  (does not set the patch field values)
00177         static autoPtr<PatchField<Type> > New
00178         (
00179             const word&,
00180             const PointPatch&,
00181             const Field<Type>&
00182         );
00183 
00184         //- Return a pointer to a new patchField created on freestore from
00185         //  a given PointPatchField mapped onto a new patch
00186         static autoPtr<PatchField<Type> > New
00187         (
00188             const PointPatchField<PatchField, PointPatch, Type>&,
00189             const PointPatch&,
00190             const Field<Type>&,
00191             const PointPatchFieldMapper&
00192         );
00193 
00194         //- Return a pointer to a new patchField created on freestore
00195         //  from dictionary
00196         static autoPtr<PatchField<Type> > New
00197         (
00198             const PointPatch&,
00199             const Field<Type>&,
00200             const dictionary&
00201         );
00202 
00203 
00204         //- Return a pointer to a new CalculatedPointPatchField created on
00205         //  freestore without setting patchField values
00206         template<class Type2>
00207         static autoPtr<PointPatchField<PatchField, PointPatch, Type> >
00208         NewCalculatedType
00209         (
00210             const PointPatchField<PatchField, PointPatch, Type2>&
00211         );
00212 
00213 
00214     // Destructor
00215 
00216         virtual ~PointPatchField<PatchField, PointPatch, Type>()
00217         {}
00218 
00219 
00220     // Member functions
00221 
00222         // Access
00223 
00224             //- Return local objectRegistry
00225             const objectRegistry& db() const;
00226 
00227             //- Return size
00228             label size() const
00229             {
00230                 return patch().size();
00231             }
00232 
00233             //- Return patch
00234             const PointPatch& patch() const
00235             {
00236                 return patch_;
00237             }
00238 
00239             //- Return internal field reference
00240             const Field<Type>& internalField() const
00241             {
00242                 return internalField_;
00243             }
00244 
00245             //- Return field created from appropriate internal field values
00246             tmp<Field<Type> > patchInternalField() const;
00247 
00248             //- Return field created from appropriate internal field values
00249             // given internal field reference
00250             template<class Type1>
00251             tmp<Field<Type1> > patchInternalField
00252             (
00253                 const Field<Type1>& iF
00254             ) const;
00255 
00256             //- Given the internal field and a patch field,
00257             //  add the patch field to the internal field
00258             template<class Type1> void addToInternalField
00259             (
00260                 Field<Type1>& iF,
00261                 const Field<Type1>& pF
00262             ) const;
00263 
00264             //- Given the internal field and a patch field,
00265             //  set the patch field in the internal field
00266             template<class Type1> void setInInternalField
00267             (
00268                 Field<Type1>& iF,
00269                 const Field<Type1>& pF
00270             ) const;
00271 
00272             //- Return the type of the calculated for of PointPatchField
00273             static const word& calculatedType();
00274 
00275 
00276         // Mapping functions
00277 
00278             //- Map (and resize as needed) from self given a mapping object
00279             virtual void autoMap
00280             (
00281                 const PointPatchFieldMapper&
00282             )
00283             {}
00284 
00285             //- Reverse map the given PointPatchField onto
00286             //  this PointPatchField
00287             virtual void rmap
00288             (
00289                 const PointPatchField<PatchField, PointPatch, Type>&,
00290                 const labelList&
00291             )
00292             {}
00293 
00294 
00295         // Evaluation functions
00296 
00297             //- Does it store field data
00298             virtual bool storesFieldData() const
00299             {
00300                 return false;
00301             }
00302 
00303             //- Does this patchField correspond to a pointTypeField
00304             bool isPointField() const;
00305 
00306             //- Check that this patchField corresponds to a pointTypeField,
00307             // if not abort!
00308             void checkPointField() const;
00309 
00310             //- Initialise evaluation of the patch field (do nothing)
00311             virtual void initEvaluate(const bool=false)
00312             {}
00313 
00314             //- Evaluate the patch field
00315             virtual void evaluate()
00316             {}
00317 
00318             //- Update boundary value
00319             virtual void updateBoundaryField()
00320             {}
00321 
00322             //- Init add field to internal field
00323             virtual void initAddField() const
00324             {}
00325 
00326             //- Add field to internal field
00327             virtual void addField(Field<Type>&) const
00328             {
00329                 notImplemented(type() + "::addField(Field<Type>&) const");
00330             }
00331 
00332             //- Return neighbour colouring
00333             virtual tmp<labelField> nbrColour(const labelField& cField) const
00334             {
00335                 notImplemented(type() + "::nbrColour(const labelField&) const");
00336 
00337                 return tmp<labelField>(labelField::null());
00338             }
00339 
00340 
00341         //- Write
00342         virtual void write(Ostream&) const;
00343 
00344 
00345     // Member operators
00346 
00347         virtual void operator=
00348         (
00349             const PointPatchField<PatchField, PointPatch, Type>&
00350         )
00351         {}
00352 
00353         virtual void operator+=
00354         (
00355             const PointPatchField<PatchField, PointPatch, Type>&
00356         )
00357         {}
00358 
00359         virtual void operator-=
00360         (
00361             const PointPatchField<PatchField, PointPatch, Type>&
00362         )
00363         {}
00364 
00365         virtual void operator*=
00366         (
00367             const PointPatchField<PatchField, PointPatch, scalar>&
00368         )
00369         {}
00370 
00371         virtual void operator/=
00372         (
00373             const PointPatchField<PatchField, PointPatch, scalar>&
00374         )
00375         {}
00376 
00377         virtual void operator=(const Field<Type>&){}
00378         virtual void operator+=(const Field<Type>&){}
00379         virtual void operator-=(const Field<Type>&){}
00380 
00381         virtual void operator*=(const Field<scalar>&){}
00382         virtual void operator/=(const Field<scalar>&){}
00383 
00384         virtual void operator=(const Type&){}
00385         virtual void operator+=(const Type&){}
00386         virtual void operator-=(const Type&){}
00387         virtual void operator*=(const scalar){}
00388         virtual void operator/=(const scalar){}
00389 
00390 
00391         // Force an assignment irrespective of form of patch
00392 
00393         virtual void operator==
00394         (
00395             const PointPatchField<PatchField, PointPatch, Type>&
00396         )
00397         {}
00398 
00399         virtual void operator==(const Field<Type>&){}
00400         virtual void operator==(const Type&){}
00401 
00402 
00403     // Ostream operator
00404 
00405         friend Ostream& operator<< <PatchField, PointPatch, Type>
00406         (
00407             Ostream&,
00408             const PointPatchField<PatchField, PointPatch, Type>&
00409         );
00410 };
00411 
00412 
00413 // This function is added as a hack to enable simple backward compatability
00414 // with verions using referenceLevel in GeometicField
00415 template<template<class> class PatchField, class PointPatch, class Type>
00416 const PointPatchField<PatchField, PointPatch, Type>& operator+
00417 (
00418     const PointPatchField<PatchField, PointPatch, Type>& ppf,
00419     const Type&
00420 )
00421 {
00422     return ppf;
00423 }
00424 
00425 
00426 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00427 
00428 } // End namespace Foam
00429 
00430 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00431 
00432 #include "PointPatchFieldFunctions.H"
00433 
00434 #ifdef NoRepository
00435 #   include "PointPatchField.C"
00436 #   include "CalculatedPointPatchField.H"
00437 #endif
00438 
00439 
00440 #define makePointPatchTypeFieldTypeName(typePatchTypeField)                \
00441                                                                            \
00442 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
00443 
00444 #define makePointPatchFieldsTypeName(typePatchField, pointPatchType)       \
00445                                                                            \
00446 makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##ScalarField); \
00447 makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##VectorField); \
00448 makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##TensorField);
00449 
00450 
00451 #define makePointPatchTypeField(PatchTypeField, typePatchTypeField)        \
00452                                                                            \
00453 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                \
00454                                                                            \
00455 addToRunTimeSelectionTable                                                 \
00456 (                                                                          \
00457     PatchTypeField, typePatchTypeField, PointPatch                         \
00458 );                                                                         \
00459                                                                            \
00460 addToRunTimeSelectionTable                                                 \
00461 (                                                                          \
00462     PatchTypeField,                                                        \
00463     typePatchTypeField,                                                    \
00464     patchMapper                                                            \
00465 );                                                                         \
00466                                                                            \
00467 addToRunTimeSelectionTable                                                 \
00468 (                                                                          \
00469     PatchTypeField, typePatchTypeField, dictionary                         \
00470 );
00471 
00472 
00473 #define makePointPatchFields(typePatchField, pointPatch, pointPatchType)   \
00474                                                                            \
00475 makePointPatchTypeField                                                    \
00476 (                                                                          \
00477     pointPatch##ScalarField,                                               \
00478     typePatchField##pointPatchType##ScalarField                            \
00479 );                                                                         \
00480                                                                            \
00481 makePointPatchTypeField                                                    \
00482 (                                                                          \
00483     pointPatch##VectorField,                                               \
00484     typePatchField##pointPatchType##VectorField                            \
00485 );                                                                         \
00486                                                                            \
00487 makePointPatchTypeField                                                    \
00488 (                                                                          \
00489     pointPatch##TensorField,                                               \
00490     typePatchField##pointPatchType##TensorField                            \
00491 );
00492 
00493 
00494 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00495 
00496 #endif
00497 
00498 // ************************************************************************* //
For further information go to www.openfoam.org