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 #include "volPointInterpolation.H"
00028 #include "volFields.H"
00029 #include "pointFields.H"
00030 #include "globalPointPatch.H"
00031
00032
00033
00034 namespace Foam
00035 {
00036
00037
00038
00039 template<class Type>
00040 void volPointInterpolation::interpolateInternalField
00041 (
00042 const GeometricField<Type, fvPatchField, volMesh>& vf,
00043 GeometricField<Type, pointPatchField, pointMesh>& pf
00044 ) const
00045 {
00046 if (debug)
00047 {
00048 Info<< "volPointInterpolation::interpolateInternalField("
00049 << "const GeometricField<Type, fvPatchField, volMesh>&, "
00050 << "GeometricField<Type, pointPatchField, pointMesh>&) : "
00051 << "interpolating field from cells to points"
00052 << endl;
00053 }
00054
00055 const labelListList& pointCells = vf.mesh().pointCells();
00056
00057
00058 forAll(pointCells, pointi)
00059 {
00060 const scalarList& pw = pointWeights_[pointi];
00061 const labelList& ppc = pointCells[pointi];
00062
00063 pf[pointi] = pTraits<Type>::zero;
00064
00065 forAll(ppc, pointCelli)
00066 {
00067 pf[pointi] += pw[pointCelli]*vf[ppc[pointCelli]];
00068 }
00069 }
00070 }
00071
00072
00073 template<class Type>
00074 void volPointInterpolation::interpolate
00075 (
00076 const GeometricField<Type, fvPatchField, volMesh>& vf,
00077 GeometricField<Type, pointPatchField, pointMesh>& pf
00078 ) const
00079 {
00080 if (debug)
00081 {
00082 Info<< "volPointInterpolation::interpolate("
00083 << "const GeometricField<Type, fvPatchField, volMesh>&, "
00084 << "GeometricField<Type, pointPatchField, pointMesh>&) : "
00085 << "interpolating field from cells to points"
00086 << endl;
00087 }
00088
00089 interpolateInternalField(vf, pf);
00090
00091
00092 boundaryInterpolator_.interpolate(vf, pf, false);
00093 }
00094
00095
00096 template<class Type>
00097 tmp<GeometricField<Type, pointPatchField, pointMesh> >
00098 volPointInterpolation::interpolate
00099 (
00100 const GeometricField<Type, fvPatchField, volMesh>& vf,
00101 const wordList& patchFieldTypes
00102 ) const
00103 {
00104 wordList types(patchFieldTypes);
00105
00106 const pointMesh& pMesh = pointMesh::New(vf.mesh());
00107
00108
00109
00110 if
00111 (
00112 isType<globalPointPatch>
00113 (
00114 pMesh.boundary()[pMesh.boundary().size() - 1]
00115 )
00116 )
00117 {
00118 types.setSize(types.size() + 1);
00119 types[types.size()-1] = pMesh.boundary()[types.size()-1].type();
00120 }
00121
00122
00123 tmp<GeometricField<Type, pointPatchField, pointMesh> > tpf
00124 (
00125 new GeometricField<Type, pointPatchField, pointMesh>
00126 (
00127 IOobject
00128 (
00129 "volPointInterpolate(" + vf.name() + ')',
00130 vf.instance(),
00131 pMesh.thisDb()
00132 ),
00133 pMesh,
00134 vf.dimensions(),
00135 types
00136 )
00137 );
00138
00139 interpolateInternalField(vf, tpf());
00140
00141
00142 boundaryInterpolator_.interpolate(vf, tpf(), true);
00143
00144 return tpf;
00145 }
00146
00147
00148 template<class Type>
00149 tmp<GeometricField<Type, pointPatchField, pointMesh> >
00150 volPointInterpolation::interpolate
00151 (
00152 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvf,
00153 const wordList& patchFieldTypes
00154 ) const
00155 {
00156
00157 tmp<GeometricField<Type, pointPatchField, pointMesh> > tpf =
00158 interpolate(tvf(), patchFieldTypes);
00159 tvf.clear();
00160 return tpf;
00161 }
00162
00163
00164 template<class Type>
00165 tmp<GeometricField<Type, pointPatchField, pointMesh> >
00166 volPointInterpolation::interpolate
00167 (
00168 const GeometricField<Type, fvPatchField, volMesh>& vf
00169 ) const
00170 {
00171 const pointMesh& pm = pointMesh::New(vf.mesh());
00172
00173 tmp<GeometricField<Type, pointPatchField, pointMesh> > tpf
00174 (
00175 new GeometricField<Type, pointPatchField, pointMesh>
00176 (
00177 IOobject
00178 (
00179 "volPointInterpolate(" + vf.name() + ')',
00180 vf.instance(),
00181 pm.thisDb()
00182 ),
00183 pm,
00184 vf.dimensions()
00185 )
00186 );
00187
00188 interpolateInternalField(vf, tpf());
00189 boundaryInterpolator_.interpolate(vf, tpf(), false);
00190
00191 return tpf;
00192 }
00193
00194
00195 template<class Type>
00196 tmp<GeometricField<Type, pointPatchField, pointMesh> >
00197 volPointInterpolation::interpolate
00198 (
00199 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvf
00200 ) const
00201 {
00202
00203 tmp<GeometricField<Type, pointPatchField, pointMesh> > tpf =
00204 interpolate(tvf());
00205 tvf.clear();
00206 return tpf;
00207 }
00208
00209
00210
00211
00212 }
00213
00214