1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Patch to patch interpolation functions
27 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 //- Interpolate point field
37 template<class FromPatch, class ToPatch>
40 PatchToPatchInterpolation<FromPatch, ToPatch>::pointInterpolate
45 if (pf.size() != fromPatch_.nPoints())
49 "PatchToPatchInterpolation::pointInterpolate"
50 "(const Field<Type> pf)"
51 ) << "given field does not correspond to patch. Patch size: "
52 << fromPatch_.nPoints() << " field size: " << pf.size()
56 tmp<Field<Type> > tresult
65 Field<Type>& result = tresult();
67 const List<typename FromPatch::FaceType>& fromPatchLocalFaces =
68 fromPatch_.localFaces();
70 const FieldField<Field, scalar>& weights = pointWeights();
72 const labelList& addr = pointAddr();
74 forAll (result, pointI)
76 const scalarField& curWeights = weights[pointI];
78 if (addr[pointI] > -1)
80 const labelList& hitFacePoints =
81 fromPatchLocalFaces[addr[pointI]];
83 forAll (curWeights, wI)
85 result[pointI] += curWeights[wI]*pf[hitFacePoints[wI]];
94 template<class FromPatch, class ToPatch>
97 PatchToPatchInterpolation<FromPatch, ToPatch>::pointInterpolate
99 const tmp<Field<Type> >& tpf
102 tmp<Field<Type> > tint = pointInterpolate<Type>(tpf());
108 //- Interpolate face field
109 template<class FromPatch, class ToPatch>
112 PatchToPatchInterpolation<FromPatch, ToPatch>::faceInterpolate
114 const Field<Type>& ff
117 if (ff.size() != fromPatch_.size())
121 "PatchToPatchInterpolation::faceInterpolate"
122 "(const Field<Type> ff)"
123 ) << "given field does not correspond to patch. Patch size: "
124 << fromPatch_.size() << " field size: " << ff.size()
125 << abort(FatalError);
128 tmp<Field<Type> > tresult
137 Field<Type>& result = tresult();
139 const labelListList& fromPatchFaceFaces = fromPatch_.faceFaces();
141 const FieldField<Field, scalar>& weights = faceWeights();
143 const labelList& addr = faceAddr();
145 forAll (result, faceI)
147 const scalarField& curWeights = weights[faceI];
149 if (addr[faceI] > -1)
151 const labelList& hitFaceFaces =
152 fromPatchFaceFaces[addr[faceI]];
154 // first add the hit face
155 result[faceI] += ff[addr[faceI]]*curWeights[0];
157 for (label wI = 1; wI < curWeights.size(); wI++)
159 result[faceI] += ff[hitFaceFaces[wI - 1]]*curWeights[wI];
168 template<class FromPatch, class ToPatch>
171 PatchToPatchInterpolation<FromPatch, ToPatch>::faceInterpolate
173 const tmp<Field<Type> >& tff
176 tmp<Field<Type> > tint = faceInterpolate(tff());
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 } // End namespace Foam
186 // ************************************************************************* //