OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

PatchToPatchInterpolation.C

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-2009 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 Description
00026     Interpolation class dealing with transfer of data between two
00027     primitivePatches
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 #include "PatchToPatchInterpolation.H"
00032 #include "demandDrivenData.H"
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00040 
00041 template<class FromPatch, class ToPatch>
00042 const scalar
00043 PatchToPatchInterpolation<FromPatch, ToPatch>::directHitTol = 1e-5;
00044 
00045 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00046 
00047 template<class FromPatch, class ToPatch>
00048 const labelList&
00049 PatchToPatchInterpolation<FromPatch, ToPatch>::pointAddr() const
00050 {
00051     if (!pointAddressingPtr_)
00052     {
00053         calcPointAddressing();
00054     }
00055 
00056     return *pointAddressingPtr_;
00057 }
00058 
00059 
00060 template<class FromPatch, class ToPatch>
00061 const FieldField<Field, scalar>&
00062 PatchToPatchInterpolation<FromPatch, ToPatch>::pointWeights() const
00063 {
00064     if (!pointWeightsPtr_)
00065     {
00066         calcPointAddressing();
00067     }
00068 
00069     return *pointWeightsPtr_;
00070 }
00071 
00072 
00073 template<class FromPatch, class ToPatch>
00074 const labelList&
00075 PatchToPatchInterpolation<FromPatch, ToPatch>::faceAddr() const
00076 {
00077     if (!faceAddressingPtr_)
00078     {
00079         calcFaceAddressing();
00080     }
00081 
00082     return *faceAddressingPtr_;
00083 }
00084 
00085 
00086 template<class FromPatch, class ToPatch>
00087 const FieldField<Field, scalar>&
00088 PatchToPatchInterpolation<FromPatch, ToPatch>::faceWeights() const
00089 {
00090     if (!faceWeightsPtr_)
00091     {
00092         calcFaceAddressing();
00093     }
00094 
00095     return *faceWeightsPtr_;
00096 }
00097 
00098 
00099 template<class FromPatch, class ToPatch>
00100 void PatchToPatchInterpolation<FromPatch, ToPatch>::clearOut()
00101 {
00102     deleteDemandDrivenData(pointAddressingPtr_);
00103     deleteDemandDrivenData(pointWeightsPtr_);
00104     deleteDemandDrivenData(pointDistancePtr_);
00105     deleteDemandDrivenData(faceAddressingPtr_);
00106     deleteDemandDrivenData(faceWeightsPtr_);
00107     deleteDemandDrivenData(faceDistancePtr_);
00108 }
00109 
00110 
00111 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00112 
00113 // Construct from components
00114 template<class FromPatch, class ToPatch>
00115 PatchToPatchInterpolation<FromPatch, ToPatch>::PatchToPatchInterpolation
00116 (
00117     const FromPatch& fromPatch,
00118     const ToPatch& toPatch,
00119     intersection::algorithm alg,
00120     const intersection::direction dir
00121 )
00122 :
00123     fromPatch_(fromPatch),
00124     toPatch_(toPatch),
00125     alg_(alg),
00126     dir_(dir),
00127     pointAddressingPtr_(NULL),
00128     pointWeightsPtr_(NULL),
00129     pointDistancePtr_(NULL),
00130     faceAddressingPtr_(NULL),
00131     faceWeightsPtr_(NULL),
00132     faceDistancePtr_(NULL)
00133 {}
00134 
00135 
00136 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
00137 
00138 template<class FromPatch, class ToPatch>
00139 PatchToPatchInterpolation<FromPatch, ToPatch>::~PatchToPatchInterpolation()
00140 {
00141     clearOut();
00142 }
00143 
00144 
00145 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00146 
00147 template<class FromPatch, class ToPatch>
00148 const scalarField&
00149 PatchToPatchInterpolation<FromPatch, ToPatch>
00150 ::pointDistanceToIntersection() const
00151 {
00152     if (!pointDistancePtr_)
00153     {
00154         calcPointAddressing();
00155     }
00156 
00157     return *pointDistancePtr_;
00158 }
00159 
00160 
00161 template<class FromPatch, class ToPatch>
00162 const scalarField&
00163 PatchToPatchInterpolation<FromPatch, ToPatch>
00164 ::faceDistanceToIntersection() const
00165 {
00166     if (!faceDistancePtr_)
00167     {
00168         calcFaceAddressing();
00169     }
00170 
00171     return *faceDistancePtr_;
00172 }
00173 
00174 
00175 template<class FromPatch, class ToPatch>
00176 bool PatchToPatchInterpolation<FromPatch, ToPatch>::movePoints()
00177 {
00178     clearOut();
00179 
00180     return true;
00181 }
00182 
00183 
00184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00185 
00186 } // End namespace Foam
00187 
00188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00189 
00190 #   include "CalcPatchToPatchWeights.C"
00191 #   include "PatchToPatchInterpolate.C"
00192 
00193 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd