pointPatchInterpolate.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 #include "pointPatchInterpolation.H"
00028 #include "volFields.H"
00029 #include "pointFields.H"
00030 #include "emptyFvPatch.H"
00031 #include "valuePointPatchField.H"
00032 #include "coupledPointPatchField.H"
00033 #include "coupledFacePointPatch.H"
00034 #include "transform.H"
00035
00036
00037
00038 namespace Foam
00039 {
00040
00041
00042
00043 template<class Type>
00044 void pointPatchInterpolation::interpolate
00045 (
00046 const GeometricField<Type, fvPatchField, volMesh>& vf,
00047 GeometricField<Type, pointPatchField, pointMesh>& pf,
00048 bool overrideFixedValue
00049 ) const
00050 {
00051 if (debug)
00052 {
00053 Info<< "pointPatchInterpolation::interpolate("
00054 << "const GeometricField<Type, fvPatchField, volMesh>&, "
00055 << "GeometricField<Type, pointPatchField, pointMesh>&) : "
00056 << "interpolating field from cells to points"
00057 << endl;
00058 }
00059
00060
00061
00062
00063
00064 const fvBoundaryMesh& bm = fvMesh_.boundary();
00065 const pointBoundaryMesh& pbm = pointMesh::New(fvMesh_).boundary();
00066
00067 forAll(bm, patchi)
00068 {
00069 if (!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
00070 {
00071 pointPatchField<Type>& ppf = pf.boundaryField()[patchi];
00072
00073
00074
00075 ppf.setInInternalField
00076 (
00077 pf.internalField(),
00078 patchInterpolators_[patchi]
00079 .faceToPointInterpolate(vf.boundaryField()[patchi])(),
00080 bm[patchi].patch().meshPoints()
00081 );
00082
00083 if
00084 (
00085 overrideFixedValue
00086 && isA<valuePointPatchField<Type> >(ppf)
00087 )
00088 {
00089 refCast<valuePointPatchField<Type> >(ppf) = ppf;
00090 }
00091 }
00092 else if (bm[patchi].coupled())
00093 {
00094
00095
00096
00097 const labelList& loneMeshPoints =
00098 refCast<const coupledFacePointPatch>(pbm[patchi])
00099 .loneMeshPoints();
00100
00101 forAll(loneMeshPoints, i)
00102 {
00103 pf[loneMeshPoints[i]] = pTraits<Type>::zero;
00104 }
00105 }
00106
00107 }
00108
00109
00110
00111 const labelListList& PointFaces = fvMesh_.pointFaces();
00112
00113 forAll(patchPatchPoints_, pointi)
00114 {
00115 const label curPoint = patchPatchPoints_[pointi];
00116 const labelList& curFaces = PointFaces[curPoint];
00117
00118 label fI = 0;
00119
00120
00121 pf[curPoint] = pTraits<Type>::zero;
00122
00123
00124 forAll(curFaces, facei)
00125 {
00126 if (!fvMesh_.isInternalFace(curFaces[facei]))
00127 {
00128 label patchi =
00129 fvMesh_.boundaryMesh().whichPatch(curFaces[facei]);
00130
00131 if (!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
00132 {
00133 label faceInPatchi =
00134 bm[patchi].patch().whichFace(curFaces[facei]);
00135
00136 pf[curPoint] +=
00137 patchPatchPointWeights_[pointi][fI]
00138 *vf.boundaryField()[patchi][faceInPatchi];
00139
00140 fI++;
00141 }
00142 }
00143 }
00144 }
00145
00146
00147 forAll(pf.boundaryField(), patchi)
00148 {
00149 if (pf.boundaryField()[patchi].coupled())
00150 {
00151 refCast<coupledPointPatchField<Type> >(pf.boundaryField()[patchi])
00152 .initSwapAdd(pf.internalField());
00153 }
00154 }
00155
00156 forAll(pf.boundaryField(), patchi)
00157 {
00158 if (pf.boundaryField()[patchi].coupled())
00159 {
00160 refCast<coupledPointPatchField<Type> >(pf.boundaryField()[patchi])
00161 .swapAdd(pf.internalField());
00162 }
00163 }
00164
00165
00166
00167
00168
00169 pf.correctBoundaryConditions();
00170
00171
00172
00173 applyCornerConstraints(pf);
00174
00175
00176 if (debug)
00177 {
00178 Info<< "pointPatchInterpolation::interpolate("
00179 << "const GeometricField<Type, fvPatchField, volMesh>&, "
00180 << "GeometricField<Type, pointPatchField, pointMesh>&) : "
00181 << "finished interpolating field from cells to points"
00182 << endl;
00183 }
00184 }
00185
00186
00187 template<class Type>
00188 void pointPatchInterpolation::applyCornerConstraints
00189 (
00190 GeometricField<Type, pointPatchField, pointMesh>& pf
00191 ) const
00192 {
00193 forAll(patchPatchPointConstraintPoints_, pointi)
00194 {
00195 pf[patchPatchPointConstraintPoints_[pointi]] = transform
00196 (
00197 patchPatchPointConstraintTensors_[pointi],
00198 pf[patchPatchPointConstraintPoints_[pointi]]
00199 );
00200 }
00201 }
00202
00203
00204
00205
00206 }
00207
00208
Copyright © 2000-2009 OpenCFD Ltd