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