OpenFOAM logo
Open Source CFD Toolkit

TetPointPatchField.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     TetPointPatchField
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     TetPointPatchField.C
00036     newTetPointPatchField.C
00037 
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef TetPointPatchField_H
00041 #define TetPointPatchField_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 TetPointPatchField;
00056 
00057 template<class T> class Map;
00058 template<class Type> class constraint;
00059 
00060 class objectRegistry;
00061 class dictionary;
00062 class TetPointPatchFieldMapper;
00063 class lduMatrix;
00064 
00065 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00066 
00067 template<template<class> class PatchField, class PointPatch, class Type>
00068 Ostream& operator<<
00069 (
00070     Ostream&,
00071     const TetPointPatchField<PatchField, PointPatch, Type>&
00072 );
00073 
00074 
00075 /*---------------------------------------------------------------------------*\
00076                        Class TetPointPatchField Declaration
00077 \*---------------------------------------------------------------------------*/
00078 
00079 template<template<class> class PatchField, class PointPatch, class Type>
00080 class TetPointPatchField
00081 :
00082     public lduCoupledInterface
00083 {
00084     // Private data
00085 
00086         //- Reference to patch
00087         const PointPatch& patch_;
00088 
00089         //- Reference to internal field
00090         const Field<Type>& internalField_;
00091 
00092 
00093     // Private member functions
00094 
00095         void checkInternalField() const;
00096 
00097 
00098 public:
00099 
00100     typedef PointPatch Patch;
00101     typedef PatchField<Type> pointPatchTypeField;
00102 
00103     //- Runtime type information
00104     TypeName("TetPointPatchField");
00105 
00106 
00107     // Declare run-time constructor selection tables
00108 
00109         declareRunTimeSelectionTable
00110         (
00111             autoPtr,
00112             pointPatchTypeField,
00113             PointPatch,
00114             (const PointPatch& p, const Field<Type>& iF),
00115             (p, iF)
00116         );
00117 
00118         declareRunTimeSelectionTable
00119         (
00120             autoPtr,
00121             pointPatchTypeField,
00122             patchMapper,
00123             (
00124                 const TetPointPatchField<PatchField, PointPatch, Type>& ptf,
00125                 const PointPatch& p,
00126                 const Field<Type>& iF,
00127                 const TetPointPatchFieldMapper& m
00128             ),
00129             (dynamic_cast<const pointPatchTypeFieldType&>(ptf), p, iF, m)
00130         );
00131 
00132         declareRunTimeSelectionTable
00133         (
00134             autoPtr,
00135             pointPatchTypeField,
00136             dictionary,
00137             (
00138                 const PointPatch& p,
00139                 const Field<Type>& iF,
00140                 const dictionary& dict
00141             ),
00142             (p, iF, dict)
00143         );
00144 
00145 
00146     // Constructors
00147 
00148         //- Construct from patch and internal field
00149         TetPointPatchField
00150         (
00151             const PointPatch&,
00152             const Field<Type>&
00153         );
00154 
00155         //- Construct as copy
00156         TetPointPatchField(const TetPointPatchField<PatchField, PointPatch, Type>&);
00157 
00158         //- Construct and return a clone
00159         virtual autoPtr<PatchField<Type> > clone() const = 0;
00160 
00161         //- Construct as copy setting internal field reference
00162         TetPointPatchField
00163         (
00164             const TetPointPatchField<PatchField, PointPatch, Type>&,
00165             const Field<Type>&
00166         );
00167 
00168         //- Construct and return a clone setting internal field reference
00169         virtual autoPtr<PatchField<Type> > clone
00170         (
00171             const Field<Type>& iF
00172         ) const = 0;
00173 
00174 
00175     // Selectors
00176 
00177         //- Return a pointer to a new patchField created on freestore given
00178         //  patch and internal field
00179         //  (does not set the patch field values)
00180         static autoPtr<PatchField<Type> > New
00181         (
00182             const word&,
00183             const PointPatch&,
00184             const Field<Type>&
00185         );
00186 
00187         //- Return a pointer to a new patchField created on freestore from
00188         //  a given TetPointPatchField mapped onto a new patch
00189         static autoPtr<PatchField<Type> > New
00190         (
00191             const TetPointPatchField<PatchField, PointPatch, Type>&,
00192             const PointPatch&,
00193             const Field<Type>&,
00194             const TetPointPatchFieldMapper&
00195         );
00196 
00197         //- Return a pointer to a new patchField created on freestore
00198         //  from dictionary
00199         static autoPtr<PatchField<Type> > New
00200         (
00201             const PointPatch&,
00202             const Field<Type>&,
00203             const dictionary&
00204         );
00205 
00206 
00207         //- Return a pointer to a new CalculatedTetPointPatchField created on
00208         //  freestore without setting patchField values
00209         template<class Type2>
00210         static autoPtr<TetPointPatchField<PatchField, PointPatch, Type> >
00211         NewCalculatedType
00212         (
00213             const TetPointPatchField<PatchField, PointPatch, Type2>&
00214         );
00215 
00216 
00217     // Destructor
00218 
00219         virtual ~TetPointPatchField<PatchField, PointPatch, Type>()
00220         {}
00221 
00222 
00223     // Member functions
00224 
00225         // Access
00226 
00227             //- Return local objectRegistry
00228             const objectRegistry& db() const;
00229 
00230             //- Return size
00231             label size() const
00232             {
00233                 return patch().size();
00234             }
00235 
00236             //- Return patch
00237             const PointPatch& patch() const
00238             {
00239                 return patch_;
00240             }
00241 
00242             //- Return internal field reference
00243             const Field<Type>& internalField() const
00244             {
00245                 return internalField_;
00246             }
00247 
00248             //- Return field created from appropriate internal field values
00249             tmp<Field<Type> > patchInternalField() const;
00250 
00251             //- Return field created from appropriate internal field values
00252             // given internal field reference
00253             template<class Type1>
00254             tmp<Field<Type1> > patchInternalField
00255             (
00256                 const Field<Type1>& iF
00257             ) const;
00258 
00259             //- Given the internal field and a patch field,
00260             //  add the patch field to the internal field
00261             template<class Type1> void addToInternalField
00262             (
00263                 Field<Type1>& iF,
00264                 const Field<Type1>& pF
00265             ) const;
00266 
00267             //- Given the internal field and a patch field,
00268             //  set the patch field in the internal field
00269             template<class Type1> void setInInternalField
00270             (
00271                 Field<Type1>& iF,
00272                 const Field<Type1>& pF
00273             ) const;
00274 
00275             //- Return the type of the calculated for of TetPointPatchField
00276             static const word& calculatedType();
00277 
00278 
00279         // Mapping functions
00280 
00281             //- Map (and resize as needed) from self given a mapping object
00282             virtual void autoMap
00283             (
00284                 const TetPointPatchFieldMapper&
00285             )
00286             {}
00287 
00288             //- Reverse map the given TetPointPatchField onto
00289             //  this TetPointPatchField
00290             virtual void rmap
00291             (
00292                 const TetPointPatchField<PatchField, PointPatch, Type>&,
00293                 const labelList&
00294             )
00295             {}
00296 
00297 
00298         // Evaluation functions
00299 
00300             //- Does it store field data
00301             virtual bool storesFieldData() const
00302             {
00303                 return false;
00304             }
00305 
00306             //- Does this patchField correspond to a pointTypeField
00307             bool isPointField() const;
00308 
00309             //- Check that this patchField corresponds to a pointTypeField,
00310             // if not abort!
00311             void checkPointField() const;
00312 
00313             //- Initialise evaluation of the patch field (do nothing)
00314             virtual void initEvaluate(const bool=false)
00315             {}
00316 
00317             //- Evaluate the patch field
00318             virtual void evaluate()
00319             {}
00320 
00321             //- Update boundary value
00322             virtual void updateBoundaryField()
00323             {}
00324 
00325             //- Init add field to internal field
00326             virtual void initAddField() const
00327             {}
00328 
00329             //- Add field to internal field
00330             virtual void addField(Field<Type>&) const
00331             {
00332                 notImplemented(type() + "::addField(Field<Type>&) const");
00333             }
00334 
00335             //- Set boundary condition to matrix
00336             virtual void setBoundaryCondition
00337             (
00338                 Map<constraint<Type> > &
00339             ) const
00340             {}
00341 
00342 
00343         // Matrix construction (completion) functionality
00344 
00345             //- Add diagonal/source contributions
00346             virtual void initAddDiag(const scalarField&) const
00347             {}
00348 
00349             virtual void initAddSource(const scalarField&) const
00350             {}
00351 
00352             virtual void addDiag(scalarField&) const
00353             {
00354                 notImplemented(type() + "::addDiag(scalarField&) const");
00355             }
00356 
00357             virtual void addSource(scalarField&) const
00358             {
00359                 notImplemented(type() + "::addSource(scalarField&) const");
00360             }
00361 
00362             //- Get the cut edge coefficients in Amul order
00363             virtual tmp<scalarField> cutBouCoeffs(const lduMatrix&) const
00364             {
00365                 return tmp<scalarField>(new scalarField(size(), 0));
00366             }
00367 
00368             //- Get the cut edge coefficients in Tmul order
00369             virtual tmp<scalarField> cutIntCoeffs(const lduMatrix&) const
00370             {
00371                 return tmp<scalarField>(new scalarField(size(), 0));
00372             }
00373 
00374             //- Add upper/lower contributions
00375             virtual void initAddUpperLower(const scalarField&) const
00376             {}
00377 
00378             virtual void addUpperLower(scalarField&) const
00379             {
00380                 notImplemented(type() + "::addUpperLower(scalarField&) const");
00381             }
00382 
00383             virtual void eliminateUpperLower(scalarField&) const
00384             {
00385                 notImplemented
00386                 (
00387                     type()
00388                   + "::eliminateUpperLower(scalarField&) const"
00389                 );
00390             }
00391 
00392             //- Return neighbour colouring
00393             virtual tmp<labelField> nbrColour(const labelField& cField) const
00394             {
00395                 return patchInternalField(cField);
00396             }
00397 
00398 
00399         //- Write
00400         virtual void write(Ostream&) const;
00401 
00402 
00403     // Member operators
00404 
00405         virtual void operator=
00406         (
00407             const TetPointPatchField<PatchField, PointPatch, Type>&
00408         )
00409         {}
00410 
00411         virtual void operator+=
00412         (
00413             const TetPointPatchField<PatchField, PointPatch, Type>&
00414         )
00415         {}
00416 
00417         virtual void operator-=
00418         (
00419             const TetPointPatchField<PatchField, PointPatch, Type>&
00420         )
00421         {}
00422 
00423         virtual void operator*=
00424         (
00425             const TetPointPatchField<PatchField, PointPatch, scalar>&
00426         )
00427         {}
00428 
00429         virtual void operator/=
00430         (
00431             const TetPointPatchField<PatchField, PointPatch, scalar>&
00432         )
00433         {}
00434 
00435         virtual void operator=(const Field<Type>&){}
00436         virtual void operator+=(const Field<Type>&){}
00437         virtual void operator-=(const Field<Type>&){}
00438 
00439         virtual void operator*=(const Field<scalar>&){}
00440         virtual void operator/=(const Field<scalar>&){}
00441 
00442         virtual void operator=(const Type&){}
00443         virtual void operator+=(const Type&){}
00444         virtual void operator-=(const Type&){}
00445         virtual void operator*=(const scalar){}
00446         virtual void operator/=(const scalar){}
00447 
00448 
00449         // Force an assignment irrespective of form of patch
00450 
00451         virtual void operator==
00452         (
00453             const TetPointPatchField<PatchField, PointPatch, Type>&
00454         )
00455         {}
00456 
00457         virtual void operator==(const Field<Type>&){}
00458         virtual void operator==(const Type&){}
00459 
00460 
00461     // Ostream operator
00462 
00463         friend Ostream& operator<< <PatchField, PointPatch, Type>
00464         (
00465             Ostream&,
00466             const TetPointPatchField<PatchField, PointPatch, Type>&
00467         );
00468 };
00469 
00470 
00471 // This function is added as a hack to enable simple backward compatability
00472 // with verions using referenceLevel in GeometicField
00473 template<template<class> class PatchField, class PointPatch, class Type>
00474 const TetPointPatchField<PatchField, PointPatch, Type>& operator+
00475 (
00476     const TetPointPatchField<PatchField, PointPatch, Type>& ppf,
00477     const Type&
00478 )
00479 {
00480     return ppf;
00481 }
00482 
00483 
00484 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00485 
00486 } // End namespace Foam
00487 
00488 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00489 
00490 #include "TetPointPatchFieldFunctions.H"
00491 
00492 #ifdef NoRepository
00493 #   include "TetPointPatchField.C"
00494 #   include "CalculatedTetPointPatchField.H"
00495 #endif
00496 
00497 
00498 #define makePointPatchTypeFieldTypeName(typePatchTypeField)                \
00499                                                                            \
00500 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
00501 
00502 #define makeTetPointPatchFieldsTypeName(typePatchField, pointPatchType)       \
00503                                                                            \
00504 makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##ScalarField); \
00505 makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##VectorField); \
00506 makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##TensorField);
00507 
00508 
00509 #define makePointPatchTypeField(PatchTypeField, typePatchTypeField)        \
00510                                                                            \
00511 defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);                \
00512                                                                            \
00513 addToRunTimeSelectionTable                                                 \
00514 (                                                                          \
00515     PatchTypeField, typePatchTypeField, PointPatch                         \
00516 );                                                                         \
00517                                                                            \
00518 addToRunTimeSelectionTable                                                 \
00519 (                                                                          \
00520     PatchTypeField,                                                        \
00521     typePatchTypeField,                                                    \
00522     patchMapper                                                            \
00523 );                                                                         \
00524                                                                            \
00525 addToRunTimeSelectionTable                                                 \
00526 (                                                                          \
00527     PatchTypeField, typePatchTypeField, dictionary                         \
00528 );
00529 
00530 
00531 #define makeTetPointPatchFields(typePatchField, pointPatch, pointPatchType)   \
00532                                                                            \
00533 makePointPatchTypeField                                                    \
00534 (                                                                          \
00535     pointPatch##ScalarField,                                               \
00536     typePatchField##pointPatchType##ScalarField                            \
00537 );                                                                         \
00538                                                                            \
00539 makePointPatchTypeField                                                    \
00540 (                                                                          \
00541     pointPatch##VectorField,                                               \
00542     typePatchField##pointPatchType##VectorField                            \
00543 );                                                                         \
00544                                                                            \
00545 makePointPatchTypeField                                                    \
00546 (                                                                          \
00547     pointPatch##TensorField,                                               \
00548     typePatchField##pointPatchType##TensorField                            \
00549 );
00550 
00551 
00552 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00553 
00554 #endif
00555 
00556 // ************************************************************************* //
For further information go to www.openfoam.org