processorPointPatch.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 "processorPointPatch.H"
00028 #include "pointBoundaryMesh.H"
00029 #include "addToRunTimeSelectionTable.H"
00030 #include "pointMesh.H"
00031 #include "globalPointPatch.H"
00032 #include "faceList.H"
00033 #include "primitiveFacePatch.H"
00034 #include "emptyPolyPatch.H"
00035
00036
00037
00038 namespace Foam
00039 {
00040
00041
00042
00043 defineTypeNameAndDebug(processorPointPatch, 0);
00044
00045 addToRunTimeSelectionTable
00046 (
00047 facePointPatch,
00048 processorPointPatch,
00049 polyPatch
00050 );
00051
00052
00053
00054
00055 void Foam::processorPointPatch::initGeometry()
00056 {
00057
00058
00059
00060
00061 if (isMaster())
00062 {
00063 meshPoints_ = procPolyPatch_.meshPoints();
00064 }
00065 else
00066 {
00067
00068
00069 const polyPatch& pp = patch();
00070
00071 faceList masterFaces(pp.size());
00072
00073 forAll (pp, faceI)
00074 {
00075 masterFaces[faceI] = pp[faceI].reverseFace();
00076 }
00077
00078 meshPoints_ = primitiveFacePatch
00079 (
00080 masterFaces,
00081 pp.points()
00082 ).meshPoints();
00083 }
00084
00085 if (Pstream::parRun())
00086 {
00087 initPatchPatchPoints();
00088 }
00089 }
00090
00091
00092 void Foam::processorPointPatch::calcGeometry()
00093 {
00094 if (Pstream::parRun())
00095 {
00096 calcPatchPatchPoints();
00097 }
00098
00099
00100
00101 if
00102 (
00103 !Pstream::parRun()
00104 || !boundaryMesh().mesh().globalData().nGlobalPoints()
00105 )
00106 {
00107 nonGlobalPatchPoints_.setSize(meshPoints_.size());
00108 forAll(nonGlobalPatchPoints_, i)
00109 {
00110 nonGlobalPatchPoints_[i] = i;
00111 }
00112 }
00113 else
00114 {
00115
00116 const labelList& sharedPoints =
00117 boundaryMesh().globalPatch().meshPoints();
00118
00119 nonGlobalPatchPoints_.setSize(meshPoints_.size());
00120
00121 label noFiltPoints = 0;
00122
00123 forAll (meshPoints_, pointI)
00124 {
00125 label curP = meshPoints_[pointI];
00126
00127 bool found = false;
00128
00129 forAll (sharedPoints, sharedI)
00130 {
00131 if (sharedPoints[sharedI] == curP)
00132 {
00133 found = true;
00134 break;
00135 }
00136 }
00137
00138 if (!found)
00139 {
00140 nonGlobalPatchPoints_[noFiltPoints] = pointI;
00141 meshPoints_[noFiltPoints] = curP;
00142 noFiltPoints++;
00143 }
00144 }
00145
00146 nonGlobalPatchPoints_.setSize(noFiltPoints);
00147 meshPoints_.setSize(noFiltPoints);
00148 }
00149 }
00150
00151
00152 void processorPointPatch::initPatchPatchPoints()
00153 {
00154 if (debug)
00155 {
00156 Info<< "processorPointPatch::calcPatchPatchPoints() : "
00157 << "constructing patch-patch points"
00158 << endl;
00159 }
00160
00161 const polyBoundaryMesh& bm = boundaryMesh().mesh()().boundaryMesh();
00162
00163
00164 const labelList& ppmp = meshPoints();
00165
00166
00167 Map<label> patchPointSet(2*ppmp.size());
00168
00169 forAll (ppmp, ppi)
00170 {
00171 patchPointSet.insert(ppmp[ppi], ppi);
00172 }
00173
00174
00175
00176 labelListList patchPatchPoints(bm.size());
00177
00178
00179 List<List<vector> > patchPatchPointNormals(bm.size());
00180
00181
00182 forAll(bm, patchi)
00183 {
00184 if
00185 (
00186 patchi != index()
00187 && !isA<emptyPolyPatch>(bm[patchi])
00188 && !bm[patchi].coupled()
00189 )
00190 {
00191
00192 const labelList& meshPoints = bm[patchi].meshPoints();
00193
00194
00195 const vectorField& normals = bm[patchi].pointNormals();
00196
00197 label pppi = 0;
00198 forAll(meshPoints, pointi)
00199 {
00200 label ppp = meshPoints[pointi];
00201
00202
00203
00204 Map<label>::iterator iter = patchPointSet.find(ppp);
00205
00206 if (iter != patchPointSet.end())
00207 {
00208
00209
00210 if (!patchPatchPoints[patchi].size())
00211 {
00212 patchPatchPoints[patchi].setSize(ppmp.size());
00213 patchPatchPointNormals[patchi].setSize(ppmp.size());
00214 }
00215
00216
00217 patchPatchPoints[patchi][pppi] = iter();
00218 patchPatchPointNormals[patchi][pppi] = normals[pointi];
00219 pppi++;
00220 }
00221 }
00222
00223
00224
00225 patchPatchPoints[patchi].setSize(pppi);
00226 patchPatchPointNormals[patchi].setSize(pppi);
00227 }
00228 }
00229
00230
00231
00232 OPstream toNeighbProc
00233 (
00234 Pstream::blocking,
00235 neighbProcNo()
00236 );
00237
00238 toNeighbProc
00239 << ppmp.size()
00240 << patchPatchPoints
00241 << patchPatchPointNormals;
00242
00243 if (debug)
00244 {
00245 Info<< "processorPointPatch::calcPatchPatchPoints() : "
00246 << "constructed patch-patch points"
00247 << endl;
00248 }
00249 }
00250
00251
00252 void Foam::processorPointPatch::calcPatchPatchPoints()
00253 {
00254
00255 IPstream fromNeighbProc
00256 (
00257 Pstream::blocking,
00258 neighbProcNo()
00259 );
00260
00261 label nbrNPoints(readLabel(fromNeighbProc));
00262 labelListList patchPatchPoints(fromNeighbProc);
00263 List<List<vector> > patchPatchPointNormals(fromNeighbProc);
00264
00265 pointBoundaryMesh& pbm = const_cast<pointBoundaryMesh&>(boundaryMesh());
00266 const labelList& ppmp = meshPoints();
00267
00268
00269
00270
00271
00272
00273
00274 if (nbrNPoints != ppmp.size())
00275 {
00276 WarningIn("processorPointPatch::calcPatchPatchPoints()")
00277 << "Processor patch " << name()
00278 << " has " << ppmp.size() << " points; coupled patch has "
00279 << nbrNPoints << " points." << endl
00280 << " (usually due to decomposed cyclics)."
00281 << " This might give problems" << endl
00282 << " when using point fields (interpolation, mesh motion)."
00283 << endl;
00284 }
00285
00286
00287
00288
00289 forAll(patchPatchPoints, patchi)
00290 {
00291 const labelList& patchPoints = patchPatchPoints[patchi];
00292 const List<vector>& patchPointNormals = patchPatchPointNormals[patchi];
00293
00294
00295 if (patchPoints.size())
00296 {
00297
00298 facePointPatch& fpp = refCast<facePointPatch>(pbm[patchi]);
00299 const labelList& fmp = fpp.meshPoints();
00300 labelList& mp = fpp.meshPoints_;
00301
00302 const vectorField& fnormals = fpp.pointNormals();
00303 vectorField& normals = fpp.pointNormals_;
00304
00305
00306 Map<label> patchPointSet(2*fmp.size());
00307
00308 forAll (fmp, ppi)
00309 {
00310 patchPointSet.insert(fmp[ppi], ppi);
00311 }
00312
00313 label nPoints = mp.size();
00314 label lpi = 0;
00315 bool resized = false;
00316
00317
00318 forAll(patchPoints, ppi)
00319 {
00320
00321
00322 if (!patchPointSet.found(ppmp[patchPoints[ppi]]))
00323 {
00324
00325
00326
00327 if (!resized)
00328 {
00329 if (!mp.size() && fmp.size())
00330 {
00331 mp = fmp;
00332 normals = fnormals;
00333
00334 nPoints = mp.size();
00335 }
00336
00337 mp.setSize(nPoints + patchPoints.size());
00338 loneMeshPoints_.setSize(patchPoints.size());
00339 normals.setSize(nPoints + patchPoints.size());
00340 resized = true;
00341 }
00342
00343
00344 mp[nPoints] = ppmp[patchPoints[ppi]];
00345 loneMeshPoints_[lpi++] = ppmp[patchPoints[ppi]];
00346 normals[nPoints++] = patchPointNormals[ppi];
00347 }
00348 }
00349
00350
00351
00352 if (resized)
00353 {
00354 mp.setSize(nPoints);
00355 loneMeshPoints_.setSize(lpi);
00356 normals.setSize(nPoints);
00357 }
00358 }
00359 }
00360 }
00361
00362
00363 void processorPointPatch::initMovePoints(const pointField&)
00364 {}
00365
00366
00367 void processorPointPatch::movePoints(const pointField&)
00368 {}
00369
00370
00371 void processorPointPatch::initUpdateMesh()
00372 {
00373 facePointPatch::initUpdateMesh();
00374 processorPointPatch::initGeometry();
00375 }
00376
00377
00378 void processorPointPatch::updateMesh()
00379 {
00380 facePointPatch::updateMesh();
00381 processorPointPatch::calcGeometry();
00382 }
00383
00384
00385
00386
00387 processorPointPatch::processorPointPatch
00388 (
00389 const polyPatch& patch,
00390 const pointBoundaryMesh& bm
00391 )
00392 :
00393 coupledFacePointPatch(patch, bm),
00394 procPolyPatch_(refCast<const processorPolyPatch>(patch))
00395 {}
00396
00397
00398
00399
00400 processorPointPatch::~processorPointPatch()
00401 {}
00402
00403
00404
00405
00406 }
00407
00408
Copyright © 2000-2009 OpenCFD Ltd