Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 namespace Foam
00032 {
00033 
00034 
00035 
00036 
00037 template<class FromPatch, class ToPatch>
00038 template<class Type>
00039 tmp<Field<Type> >
00040 PatchToPatchInterpolation<FromPatch, ToPatch>::pointInterpolate
00041 (
00042     const Field<Type>& pf
00043 ) const
00044 {
00045     if (pf.size() != fromPatch_.nPoints())
00046     {
00047         FatalErrorIn
00048         (
00049             "PatchToPatchInterpolation::pointInterpolate"
00050             "(const Field<Type> pf)"
00051         )   << "given field does not correspond to patch. Patch size: "
00052             << fromPatch_.nPoints() << " field size: " << pf.size()
00053             << abort(FatalError);
00054     }
00055 
00056     tmp<Field<Type> > tresult
00057     (
00058         new Field<Type>
00059         (
00060             toPatch_.nPoints(),
00061             pTraits<Type>::zero
00062         )
00063     );
00064 
00065     Field<Type>& result = tresult();
00066 
00067     const List<typename FromPatch::FaceType>& fromPatchLocalFaces =
00068         fromPatch_.localFaces();
00069 
00070     const FieldField<Field, scalar>& weights = pointWeights();
00071 
00072     const labelList& addr = pointAddr();
00073 
00074     forAll (result, pointI)
00075     {
00076         const scalarField& curWeights = weights[pointI];
00077 
00078         if (addr[pointI] > -1)
00079         {
00080             const labelList& hitFacePoints =
00081                 fromPatchLocalFaces[addr[pointI]];
00082 
00083             forAll (curWeights, wI)
00084             {
00085                 result[pointI] += curWeights[wI]*pf[hitFacePoints[wI]];
00086             }
00087         }
00088     }
00089 
00090     return tresult;
00091 }
00092 
00093 
00094 template<class FromPatch, class ToPatch>
00095 template<class Type>
00096 tmp<Field<Type> >
00097 PatchToPatchInterpolation<FromPatch, ToPatch>::pointInterpolate
00098 (
00099     const tmp<Field<Type> >& tpf
00100 ) const
00101 {
00102     tmp<Field<Type> > tint = pointInterpolate<Type>(tpf());
00103     tpf.clear();
00104     return tint;
00105 }
00106 
00107 
00108 
00109 template<class FromPatch, class ToPatch>
00110 template<class Type>
00111 tmp<Field<Type> >
00112 PatchToPatchInterpolation<FromPatch, ToPatch>::faceInterpolate
00113 (
00114     const Field<Type>& ff
00115 ) const
00116 {
00117     if (ff.size() != fromPatch_.size())
00118     {
00119         FatalErrorIn
00120         (
00121             "PatchToPatchInterpolation::faceInterpolate"
00122             "(const Field<Type> ff)"
00123         )   << "given field does not correspond to patch. Patch size: "
00124             << fromPatch_.size() << " field size: " << ff.size()
00125             << abort(FatalError);
00126     }
00127 
00128     tmp<Field<Type> > tresult
00129     (
00130         new Field<Type>
00131         (
00132             toPatch_.size(),
00133             pTraits<Type>::zero
00134         )
00135     );
00136 
00137     Field<Type>& result = tresult();
00138 
00139     const labelListList& fromPatchFaceFaces = fromPatch_.faceFaces();
00140 
00141     const FieldField<Field, scalar>& weights = faceWeights();
00142 
00143     const labelList& addr = faceAddr();
00144 
00145     forAll (result, faceI)
00146     {
00147         const scalarField& curWeights = weights[faceI];
00148 
00149         if (addr[faceI] > -1)
00150         {
00151             const labelList& hitFaceFaces =
00152                 fromPatchFaceFaces[addr[faceI]];
00153 
00154             
00155             result[faceI] += ff[addr[faceI]]*curWeights[0];
00156 
00157             for (label wI = 1; wI < curWeights.size(); wI++)
00158             {
00159                 result[faceI] += ff[hitFaceFaces[wI - 1]]*curWeights[wI];
00160             }
00161         }
00162     }
00163 
00164     return tresult;
00165 }
00166 
00167 
00168 template<class FromPatch, class ToPatch>
00169 template<class Type>
00170 tmp<Field<Type> >
00171 PatchToPatchInterpolation<FromPatch, ToPatch>::faceInterpolate
00172 (
00173     const tmp<Field<Type> >& tff
00174 ) const
00175 {
00176     tmp<Field<Type> > tint = faceInterpolate(tff());
00177     tff.clear();
00178     return tint;
00179 }
00180 
00181 
00182 
00183 
00184 } 
00185 
00186