1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Patch to patch interpolation functions
28 \*---------------------------------------------------------------------------*/
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 //- Interpolate point field
38 template<class FromPatch, class ToPatch>
41 PatchToPatchInterpolation<FromPatch, ToPatch>::pointInterpolate
46 if (pf.size() != fromPatch_.nPoints())
50 "PatchToPatchInterpolation::pointInterpolate"
51 "(const Field<Type> pf)"
52 ) << "given field does not correspond to patch. Patch size: "
53 << fromPatch_.nPoints() << " field size: " << pf.size()
57 tmp<Field<Type> > tresult
66 Field<Type>& result = tresult();
68 const List<typename FromPatch::FaceType>& fromPatchLocalFaces =
69 fromPatch_.localFaces();
71 const FieldField<Field, scalar>& weights = pointWeights();
73 const labelList& addr = pointAddr();
75 forAll (result, pointI)
77 const scalarField& curWeights = weights[pointI];
79 if (addr[pointI] > -1)
81 const labelList& hitFacePoints =
82 fromPatchLocalFaces[addr[pointI]];
84 forAll (curWeights, wI)
86 result[pointI] += curWeights[wI]*pf[hitFacePoints[wI]];
95 template<class FromPatch, class ToPatch>
98 PatchToPatchInterpolation<FromPatch, ToPatch>::pointInterpolate
100 const tmp<Field<Type> >& tpf
103 tmp<Field<Type> > tint = pointInterpolate<Type>(tpf());
109 //- Interpolate face field
110 template<class FromPatch, class ToPatch>
113 PatchToPatchInterpolation<FromPatch, ToPatch>::faceInterpolate
115 const Field<Type>& ff
118 if (ff.size() != fromPatch_.size())
122 "PatchToPatchInterpolation::faceInterpolate"
123 "(const Field<Type> ff)"
124 ) << "given field does not correspond to patch. Patch size: "
125 << fromPatch_.size() << " field size: " << ff.size()
126 << abort(FatalError);
129 tmp<Field<Type> > tresult
138 Field<Type>& result = tresult();
140 const labelListList& fromPatchFaceFaces = fromPatch_.faceFaces();
142 const FieldField<Field, scalar>& weights = faceWeights();
144 const labelList& addr = faceAddr();
146 forAll (result, faceI)
148 const scalarField& curWeights = weights[faceI];
150 if (addr[faceI] > -1)
152 const labelList& hitFaceFaces =
153 fromPatchFaceFaces[addr[faceI]];
155 // first add the hit face
156 result[faceI] += ff[addr[faceI]]*curWeights[0];
158 for (label wI = 1; wI < curWeights.size(); wI++)
160 result[faceI] += ff[hitFaceFaces[wI - 1]]*curWeights[wI];
169 template<class FromPatch, class ToPatch>
172 PatchToPatchInterpolation<FromPatch, ToPatch>::faceInterpolate
174 const tmp<Field<Type> >& tff
177 tmp<Field<Type> > tint = faceInterpolate(tff());
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 } // End namespace Foam
187 // ************************************************************************* //