pointPatchInterpolation.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 "fvMesh.H"
00029 #include "volFields.H"
00030 #include "pointFields.H"
00031 #include "emptyFvPatch.H"
00032 #include "demandDrivenData.H"
00033 #include "coupledPointPatchFields.H"
00034 #include "pointConstraint.H"
00035
00036
00037
00038 namespace Foam
00039 {
00040
00041
00042
00043 defineTypeNameAndDebug(pointPatchInterpolation, 0);
00044
00045
00046
00047
00048 void pointPatchInterpolation::makePatchPatchAddressing()
00049 {
00050 if (debug)
00051 {
00052 Info<< "pointPatchInterpolation::makePatchPatchAddressing() : "
00053 << "constructing boundary addressing"
00054 << endl;
00055 }
00056
00057 const fvBoundaryMesh& bm = fvMesh_.boundary();
00058 const pointBoundaryMesh& pbm = pointMesh::New(fvMesh_).boundary();
00059
00060
00061
00062 label nPatchPatchPoints = 0;
00063
00064 forAll(bm, patchi)
00065 {
00066 if(!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
00067 {
00068 nPatchPatchPoints += bm[patchi].patch().boundaryPoints().size();
00069 }
00070 }
00071
00072
00073
00074 Map<label> patchPatchPointSet(2*nPatchPatchPoints);
00075
00076 patchPatchPoints_.setSize(nPatchPatchPoints);
00077
00078 List<pointConstraint> patchPatchPointConstraints(nPatchPatchPoints);
00079
00080 label pppi = 0;
00081
00082 forAll(bm, patchi)
00083 {
00084 if(!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
00085 {
00086 const labelList& bp = bm[patchi].patch().boundaryPoints();
00087 const labelList& meshPoints = bm[patchi].patch().meshPoints();
00088
00089 forAll(bp, pointi)
00090 {
00091 label ppp = meshPoints[bp[pointi]];
00092
00093 Map<label>::iterator iter = patchPatchPointSet.find(ppp);
00094
00095 if (iter == patchPatchPointSet.end())
00096 {
00097 patchPatchPointSet.insert(ppp, pppi);
00098 patchPatchPoints_[pppi] = ppp;
00099
00100 pbm[patchi].applyConstraint
00101 (
00102 bp[pointi],
00103 patchPatchPointConstraints[pppi]
00104 );
00105 pppi++;
00106 }
00107 else
00108 {
00109 pbm[patchi].applyConstraint
00110 (
00111 bp[pointi],
00112 patchPatchPointConstraints[iter()]
00113 );
00114 }
00115 }
00116 }
00117 }
00118
00119 nPatchPatchPoints = pppi;
00120 patchPatchPoints_.setSize(nPatchPatchPoints);
00121 patchPatchPointConstraints.setSize(nPatchPatchPoints);
00122
00123 patchPatchPointConstraintPoints_.setSize(nPatchPatchPoints);
00124 patchPatchPointConstraintTensors_.setSize(nPatchPatchPoints);
00125
00126 label nConstraints = 0;
00127
00128 forAll(patchPatchPointConstraints, i)
00129 {
00130 if (patchPatchPointConstraints[i].first() != 0)
00131 {
00132 patchPatchPointConstraintPoints_[nConstraints] =
00133 patchPatchPoints_[i];
00134
00135 patchPatchPointConstraintTensors_[nConstraints] =
00136 patchPatchPointConstraints[i].constraintTransformation();
00137
00138 nConstraints++;
00139 }
00140 }
00141
00142 patchPatchPointConstraintPoints_.setSize(nConstraints);
00143 patchPatchPointConstraintTensors_.setSize(nConstraints);
00144
00145
00146 patchInterpolators_.clear();
00147 patchInterpolators_.setSize(bm.size());
00148
00149 forAll(bm, patchi)
00150 {
00151 patchInterpolators_.set
00152 (
00153 patchi,
00154 new primitivePatchInterpolation(bm[patchi].patch())
00155 );
00156 }
00157
00158 if (debug)
00159 {
00160 Info<< "pointPatchInterpolation::makePatchPatchAddressing() : "
00161 << "finished constructing boundary addressing"
00162 << endl;
00163 }
00164 }
00165
00166
00167 void pointPatchInterpolation::makePatchPatchWeights()
00168 {
00169 if (debug)
00170 {
00171 Info<< "pointPatchInterpolation::makePatchPatchWeights() : "
00172 << "constructing boundary weighting factors"
00173 << endl;
00174 }
00175
00176 patchPatchPointWeights_.clear();
00177 patchPatchPointWeights_.setSize(patchPatchPoints_.size());
00178
00179 const labelListList& pf = fvMesh_.pointFaces();
00180 const volVectorField& centres = fvMesh_.C();
00181 const fvBoundaryMesh& bm = fvMesh_.boundary();
00182
00183 pointScalarField sumWeights
00184 (
00185 IOobject
00186 (
00187 "sumWeights",
00188 fvMesh_.polyMesh::instance(),
00189 fvMesh_
00190 ),
00191 pointMesh::New(fvMesh_),
00192 dimensionedScalar("zero", dimless, 0)
00193 );
00194
00195 forAll(patchPatchPoints_, pointi)
00196 {
00197 const label curPoint = patchPatchPoints_[pointi];
00198 const labelList& curFaces = pf[curPoint];
00199
00200 patchPatchPointWeights_[pointi].setSize(curFaces.size());
00201 scalarList& pw = patchPatchPointWeights_[pointi];
00202
00203 label nFacesAroundPoint = 0;
00204
00205 const vector& pointLoc = fvMesh_.points()[curPoint];
00206
00207 forAll(curFaces, facei)
00208 {
00209 if (!fvMesh_.isInternalFace(curFaces[facei]))
00210 {
00211 label patchi =
00212 fvMesh_.boundaryMesh().whichPatch(curFaces[facei]);
00213
00214 if (!isA<emptyFvPatch>(bm[patchi]) && !bm[patchi].coupled())
00215 {
00216 vector d =
00217 pointLoc
00218 - centres.boundaryField()[patchi]
00219 [bm[patchi].patch().whichFace(curFaces[facei])];
00220
00221 pw[nFacesAroundPoint] = 1.0/(mag(d)+VSMALL);
00222
00223 nFacesAroundPoint++;
00224 }
00225 }
00226 }
00227
00228
00229 pw.setSize(nFacesAroundPoint);
00230
00231
00232 sumWeights[curPoint] += sum(pw);
00233 }
00234
00235
00236
00237
00238 forAll(sumWeights.boundaryField(), patchi)
00239 {
00240 if (sumWeights.boundaryField()[patchi].coupled())
00241 {
00242 refCast<coupledPointPatchScalarField>
00243 (sumWeights.boundaryField()[patchi]).initSwapAdd
00244 (
00245 sumWeights.internalField()
00246 );
00247 }
00248 }
00249
00250 forAll(sumWeights.boundaryField(), patchi)
00251 {
00252 if (sumWeights.boundaryField()[patchi].coupled())
00253 {
00254 refCast<coupledPointPatchScalarField>
00255 (sumWeights.boundaryField()[patchi]).swapAdd
00256 (
00257 sumWeights.internalField()
00258 );
00259 }
00260 }
00261
00262
00263
00264 forAll(patchPatchPoints_, pointi)
00265 {
00266 scalarList& pw = patchPatchPointWeights_[pointi];
00267 scalar sumw = sumWeights[patchPatchPoints_[pointi]];
00268
00269 forAll(pw, facei)
00270 {
00271 pw[facei] /= sumw;
00272 }
00273 }
00274
00275
00276 if (debug)
00277 {
00278 Info<< "pointPatchInterpolation::makePatchPatchWeights() : "
00279 << "finished constructing boundary weighting factors"
00280 << endl;
00281 }
00282 }
00283
00284
00285
00286
00287 pointPatchInterpolation::pointPatchInterpolation(const fvMesh& vm)
00288 :
00289 fvMesh_(vm)
00290 {
00291 updateMesh();
00292 }
00293
00294
00295
00296
00297 pointPatchInterpolation::~pointPatchInterpolation()
00298 {}
00299
00300
00301
00302
00303 void pointPatchInterpolation::updateMesh()
00304 {
00305 makePatchPatchAddressing();
00306 makePatchPatchWeights();
00307 }
00308
00309
00310 bool pointPatchInterpolation::movePoints()
00311 {
00312 forAll(patchInterpolators_, patchi)
00313 {
00314 patchInterpolators_[patchi].movePoints();
00315 }
00316
00317 makePatchPatchWeights();
00318
00319 return true;
00320 }
00321
00322
00323
00324
00325 template<>
00326 void pointPatchInterpolation::applyCornerConstraints<scalar>
00327 (
00328 GeometricField<scalar, pointPatchField, pointMesh>& pf
00329 ) const
00330 {}
00331
00332
00333
00334
00335 }
00336
00337
Copyright © 2000-2009 OpenCFD Ltd