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