OpenFOAM logo
Open Source CFD Toolkit

PatchToPatchInterpolation.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     PatchToPatchInterpolation
00027 
00028 Description
00029     Interpolation class dealing with transfer of data between two
00030     primitivePatches
00031 
00032 SourceFiles
00033     PatchToPatchInterpolation.C
00034     PatchToPatchInterpolate.C
00035     CalcPatchToPatchWeights.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef PatchToPatchInterpolation_H
00040 #define PatchToPatchInterpolation_H
00041 
00042 #include "className.H"
00043 #include "labelList.H"
00044 #include "scalarField.H"
00045 #include "pointField.H"
00046 #include "FieldFields.H"
00047 #include "faceList.H"
00048 #include "intersection.H"
00049 
00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00051 
00052 namespace Foam
00053 {
00054 
00055 /*---------------------------------------------------------------------------*\
00056                 Class PatchToPatchInterpolationName Declaration
00057 \*---------------------------------------------------------------------------*/
00058 
00059 TemplateName(PatchToPatchInterpolation);
00060 
00061 
00062 /*---------------------------------------------------------------------------*\
00063                   Class PatchToPatchInterpolation Declaration
00064 \*---------------------------------------------------------------------------*/
00065 
00066 template<class FromPatch, class ToPatch>
00067 class PatchToPatchInterpolation
00068 :
00069     public PatchToPatchInterpolationName
00070 {
00071     // Private data
00072 
00073         //- Reference to the source patch
00074         const FromPatch& fromPatch_;
00075 
00076         //- Reference to the target patch
00077         const ToPatch& toPatch_;
00078 
00079         //- Type of intersection algorithm to use in projection
00080         intersection::algorithm alg_;
00081 
00082         //- Direction projection to use in projection
00083         intersection::direction dir_;
00084 
00085 
00086     // Static data
00087 
00088         //- Relative merge tolerance for projected points missing the target
00089         //  Expressed as the fraction of min involved edge size
00090         static scalar projectionTol_;
00091 
00092 
00093         // Point addressing
00094 
00095             //- Face into which each point of target patch is projected
00096             mutable labelList* pointAddressingPtr_;
00097 
00098             //- Weighting factors
00099             mutable FieldField<Field, scalar>* pointWeightsPtr_;
00100 
00101             //- Distance to intersection for patch points
00102             mutable scalarField* pointDistancePtr_;
00103 
00104         // Face addressing
00105 
00106             //- Face into which each face centre of target patch is projected
00107             mutable labelList* faceAddressingPtr_;
00108 
00109             //- Weighting factors
00110             mutable FieldField<Field, scalar>* faceWeightsPtr_;
00111 
00112             //- Distance to intersection for patch face centres
00113             mutable scalarField* faceDistancePtr_;
00114 
00115 
00116     // Private Member Functions
00117 
00118         //- Disallow default bitwise copy construct
00119         PatchToPatchInterpolation(const PatchToPatchInterpolation&);
00120 
00121         //- Disallow default bitwise assignment
00122         void operator=(const PatchToPatchInterpolation&);
00123 
00124         //- Calculate point weights
00125         void calcPointAddressing() const;
00126 
00127         //- Calculate face weights
00128         void calcFaceAddressing() const;
00129 
00130         //- Clear all geometry and addressing
00131         void clearOut();
00132 
00133 
00134         //- Return reference to point addressing
00135         const labelList& pointAddr() const;
00136 
00137         //- Return reference to point weights
00138         const FieldField<Field, scalar>& pointWeights() const;
00139 
00140         //- Return reference to face addressing
00141         const labelList& faceAddr() const;
00142 
00143         //- Return reference to face weights
00144         const FieldField<Field, scalar>& faceWeights() const;
00145 
00146 
00147     // Private static data members
00148 
00149         //- Direct hit tolerance
00150         static const scalar directHitTol;
00151 
00152 
00153 public:
00154 
00155     // Constructors
00156 
00157         //- Construct from components
00158         PatchToPatchInterpolation
00159         (
00160             const FromPatch& fromPatch,
00161             const ToPatch& toPatch,
00162             const intersection::algorithm alg = intersection::FULL_RAY,
00163             const intersection::direction dir = intersection::VECTOR
00164         );
00165 
00166 
00167     // Destructor
00168 
00169         ~PatchToPatchInterpolation();
00170 
00171 
00172     // Member Functions
00173 
00174         //- Set the projection tolerance, returning the previous value
00175         static scalar setProjectionTol(const scalar t)
00176         {
00177             if (t < -VSMALL)
00178             {
00179                 FatalErrorIn
00180                 (
00181                     "scalar PatchToPatchInterpolation::"
00182                     "setProjectionTol(const scalar t)"
00183                 )   << "Negative projection tolerance.  This is not allowed."
00184                     << abort(FatalError);
00185             }
00186 
00187             scalar oldTol = projectionTol_;
00188             projectionTol_ = t;
00189 
00190             return oldTol;
00191         }
00192 
00193         //- Return ype of intersection algorithm to use in projection
00194         intersection::algorithm projectionAlgo() const
00195         {
00196             return alg_;
00197         }
00198 
00199         //- Return direction projection to use in projection
00200         intersection::direction projectionDir() const
00201         {
00202             return dir_;
00203         }
00204 
00205         //- Return distance to intersection for patch points
00206         const scalarField& pointDistanceToIntersection() const;
00207 
00208         //- Return distance to intersection for patch face centres
00209         const scalarField& faceDistanceToIntersection() const;
00210 
00211         //- Correct weighting factors for moving mesh.
00212         bool movePoints();
00213 
00214 
00215         //- Interpolate point field
00216         template<class Type>
00217         tmp<Field<Type> > pointInterpolate(const Field<Type>& pf) const;
00218 
00219         template<class Type>
00220         tmp<Field<Type> > pointInterpolate(const tmp<Field<Type> >& tpf) const;
00221 
00222         //- Interpolate face field
00223         template<class Type>
00224         tmp<Field<Type> > faceInterpolate(const Field<Type>& pf) const;
00225 
00226         template<class Type>
00227         tmp<Field<Type> > faceInterpolate(const tmp<Field<Type> >& tpf) const;
00228 
00229 };
00230 
00231 
00232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00233 
00234 } // End namespace Foam
00235 
00236 #ifdef NoRepository
00237 #   include "PatchToPatchInterpolation.C"
00238 #endif
00239 
00240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00241 
00242 #endif
00243 
00244 // ************************************************************************* //
For further information go to www.openfoam.org