FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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