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 "slidingInterface.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <OpenFOAM/line.H>
00029 #include <dynamicMesh/polyTopoChanger.H>
00030
00031
00032
00033 const Foam::scalar Foam::slidingInterface::pointMergeTolDefault_ = 0.05;
00034 const Foam::scalar Foam::slidingInterface::edgeMergeTolDefault_ = 0.01;
00035 const Foam::label Foam::slidingInterface::nFacesPerSlaveEdgeDefault_ = 5;
00036 const Foam::label Foam::slidingInterface::edgeFaceEscapeLimitDefault_ = 10;
00037
00038 const Foam::scalar Foam::slidingInterface::integralAdjTolDefault_ = 0.05;
00039 const Foam::scalar Foam::slidingInterface::edgeMasterCatchFractionDefault_ = 0.4;
00040 const Foam::scalar Foam::slidingInterface::edgeEndCutoffTolDefault_ = 0.0001;
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 bool Foam::slidingInterface::projectPoints() const
00057 {
00058 if (debug)
00059 {
00060 Pout<< "bool slidingInterface::projectPoints() : "
00061 << " for object " << name() << " : "
00062 << "Projecting slave points onto master surface." << endl;
00063 }
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 const polyMesh& mesh = topoChanger().mesh();
00090
00091 const primitiveFacePatch& masterPatch =
00092 mesh.faceZones()[masterFaceZoneID_.index()]();
00093
00094 const primitiveFacePatch& slavePatch =
00095 mesh.faceZones()[slaveFaceZoneID_.index()]();
00096
00097
00098
00099
00100 const pointField& masterLocalPoints = masterPatch.localPoints();
00101 const faceList& masterLocalFaces = masterPatch.localFaces();
00102 const edgeList& masterEdges = masterPatch.edges();
00103 const labelListList& masterEdgeFaces = masterPatch.edgeFaces();
00104 const labelListList& masterFaceEdges = masterPatch.faceEdges();
00105 const labelListList& masterFaceFaces = masterPatch.faceFaces();
00106
00107
00108
00109
00110
00111
00112 const pointField& slaveLocalPoints = slavePatch.localPoints();
00113 const edgeList& slaveEdges = slavePatch.edges();
00114 const labelListList& slaveEdgeFaces = slavePatch.edgeFaces();
00115 const vectorField& slavePointNormals = slavePatch.pointNormals();
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 scalarField minMasterPointLength(masterLocalPoints.size(), GREAT);
00126 scalarField minMasterFaceLength(masterPatch.size(), GREAT);
00127
00128 forAll (masterEdges, edgeI)
00129 {
00130 const edge& curEdge = masterEdges[edgeI];
00131
00132 const scalar curLength =
00133 masterEdges[edgeI].mag(masterLocalPoints);
00134
00135
00136 minMasterPointLength[curEdge.start()] =
00137 min
00138 (
00139 minMasterPointLength[curEdge.start()],
00140 curLength
00141 );
00142
00143 minMasterPointLength[curEdge.end()] =
00144 min
00145 (
00146 minMasterPointLength[curEdge.end()],
00147 curLength
00148 );
00149
00150
00151 const labelList& curFaces = masterEdgeFaces[edgeI];
00152
00153 forAll (curFaces, faceI)
00154 {
00155 minMasterFaceLength[curFaces[faceI]] =
00156 min
00157 (
00158 minMasterFaceLength[curFaces[faceI]],
00159 curLength
00160 );
00161 }
00162 }
00163
00164
00165
00166
00167
00168 scalarField minSlavePointLength(slaveLocalPoints.size(), GREAT);
00169 scalarField minSlaveFaceLength(slavePatch.size(), GREAT);
00170
00171 forAll (slaveEdges, edgeI)
00172 {
00173 const edge& curEdge = slaveEdges[edgeI];
00174
00175 const scalar curLength =
00176 slaveEdges[edgeI].mag(slaveLocalPoints);
00177
00178
00179 minSlavePointLength[curEdge.start()] =
00180 min
00181 (
00182 minSlavePointLength[curEdge.start()],
00183 curLength
00184 );
00185
00186 minSlavePointLength[curEdge.end()] =
00187 min
00188 (
00189 minSlavePointLength[curEdge.end()],
00190 curLength
00191 );
00192
00193
00194 const labelList& curFaces = slaveEdgeFaces[edgeI];
00195
00196 forAll (curFaces, faceI)
00197 {
00198 minSlaveFaceLength[curFaces[faceI]] =
00199 min
00200 (
00201 minSlaveFaceLength[curFaces[faceI]],
00202 curLength
00203 );
00204 }
00205 }
00206
00207
00208
00209
00210
00211
00212
00213 List<objectHit> slavePointFaceHits =
00214 slavePatch.projectPoints
00215 (
00216 masterPatch,
00217 slavePointNormals,
00218 projectionAlgo_
00219 );
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 if (debug)
00232 {
00233 label nHits = 0;
00234
00235 forAll (slavePointFaceHits, pointI)
00236 {
00237 if (slavePointFaceHits[pointI].hit())
00238 {
00239 nHits++;
00240 }
00241 }
00242
00243 Pout<< "Number of hits in point projection: " << nHits
00244 << " out of " << slavePointFaceHits.size() << " points."
00245 << endl;
00246 }
00247
00248
00249 if (projectedSlavePointsPtr_) delete projectedSlavePointsPtr_;
00250
00251 projectedSlavePointsPtr_ =
00252 new pointField(slavePointFaceHits.size(), vector::zero);
00253 pointField& projectedSlavePoints = *projectedSlavePointsPtr_;
00254
00255
00256
00257 label nAdjustedPoints = 0;
00258
00259
00260
00261 if (matchType_ == INTEGRAL)
00262 {
00263 if (debug)
00264 {
00265 Pout<< "bool slidingInterface::projectPoints() for object "
00266 << name() << " : "
00267 << "Adjusting point projection for integral match: ";
00268 }
00269
00270 forAll (slavePointFaceHits, pointI)
00271 {
00272 if (slavePointFaceHits[pointI].hit())
00273 {
00274
00275 projectedSlavePoints[pointI] =
00276 masterLocalFaces
00277 [slavePointFaceHits[pointI].hitObject()].ray
00278 (
00279 slaveLocalPoints[pointI],
00280 slavePointNormals[pointI],
00281 masterLocalPoints,
00282 projectionAlgo_
00283 ).hitPoint();
00284 }
00285 else
00286 {
00287
00288 pointHit missAdjust =
00289 masterLocalFaces[slavePointFaceHits[pointI].hitObject()].ray
00290 (
00291 slaveLocalPoints[pointI],
00292 slavePointNormals[pointI],
00293 masterLocalPoints,
00294 projectionAlgo_
00295 );
00296
00297 const point nearPoint = missAdjust.missPoint();
00298 const point missPoint =
00299 slaveLocalPoints[pointI]
00300 + slavePointNormals[pointI]*missAdjust.distance();
00301
00302
00303 const scalar mergeTol =
00304 integralAdjTol_*minSlavePointLength[pointI];
00305
00306
00307 if (mag(nearPoint - missPoint) < mergeTol)
00308 {
00309 if (debug)
00310 {
00311 Pout << "a";
00312 }
00313
00314
00315
00316
00317
00318
00319
00320 projectedSlavePoints[pointI] = nearPoint;
00321
00322 slavePointFaceHits[pointI] =
00323 objectHit(true, slavePointFaceHits[pointI].hitObject());
00324
00325 nAdjustedPoints++;
00326 }
00327 else
00328 {
00329 projectedSlavePoints[pointI] = slaveLocalPoints[pointI];
00330
00331 if (debug)
00332 {
00333 Pout << "n";
00334 }
00335 }
00336 }
00337 }
00338
00339 if (debug)
00340 {
00341 Pout << " done." << endl;
00342 }
00343 }
00344 else if (matchType_ == PARTIAL)
00345 {
00346 forAll (slavePointFaceHits, pointI)
00347 {
00348 if (slavePointFaceHits[pointI].hit())
00349 {
00350
00351 projectedSlavePoints[pointI] =
00352 masterLocalFaces
00353 [slavePointFaceHits[pointI].hitObject()].ray
00354 (
00355 slaveLocalPoints[pointI],
00356 slavePointNormals[pointI],
00357 masterLocalPoints,
00358 projectionAlgo_
00359 ).hitPoint();
00360 }
00361 else
00362 {
00363
00364 projectedSlavePoints[pointI] = slaveLocalPoints[pointI];
00365 }
00366 }
00367 }
00368 else
00369 {
00370 FatalErrorIn
00371 (
00372 "bool slidingInterface::projectPoints() const"
00373 ) << "Problem in point projection. Unknown sliding match type "
00374 << " for object " << name()
00375 << abort(FatalError);
00376 }
00377
00378 if (debug)
00379 {
00380 Pout<< "Number of adjusted points in projection: "
00381 << nAdjustedPoints << endl;
00382
00383
00384 scalar minEdgeLength = GREAT;
00385 scalar el = 0;
00386 label nShortEdges = 0;
00387
00388 forAll (slaveEdges, edgeI)
00389 {
00390 el = slaveEdges[edgeI].mag(projectedSlavePoints);
00391
00392 if (el < SMALL)
00393 {
00394 Pout<< "Point projection problems for edge: "
00395 << slaveEdges[edgeI] << ". Length = " << el
00396 << endl;
00397
00398 nShortEdges++;
00399 }
00400
00401 minEdgeLength = min(minEdgeLength, el);
00402 }
00403
00404 if (nShortEdges > 0)
00405 {
00406 FatalErrorIn
00407 (
00408 "bool slidingInterface::projectPoints() const"
00409 ) << "Problem in point projection. " << nShortEdges
00410 << " short projected edges "
00411 << "after adjustment for object " << name()
00412 << abort(FatalError);
00413 }
00414 else
00415 {
00416 Pout << " ... projection OK." << endl;
00417 }
00418 }
00419
00420
00421
00422
00423
00424
00425
00426
00427 labelList slavePointPointHits(slaveLocalPoints.size(), -1);
00428 labelList masterPointPointHits(masterLocalPoints.size(), -1);
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441 label nMergedPoints = 0;
00442
00443 forAll (projectedSlavePoints, pointI)
00444 {
00445 if (slavePointFaceHits[pointI].hit())
00446 {
00447
00448 point& curPoint = projectedSlavePoints[pointI];
00449
00450
00451 const face& hitFace =
00452 masterLocalFaces[slavePointFaceHits[pointI].hitObject()];
00453
00454 label mergePoint = -1;
00455 scalar mergeDist = GREAT;
00456
00457
00458 forAll (hitFace, hitPointI)
00459 {
00460 scalar dist =
00461 mag(masterLocalPoints[hitFace[hitPointI]] - curPoint);
00462
00463
00464 const scalar mergeTol =
00465 pointMergeTol_*
00466 min
00467 (
00468 minSlavePointLength[pointI],
00469 minMasterPointLength[hitFace[hitPointI]]
00470 );
00471
00472 if (dist < mergeTol && dist < mergeDist)
00473 {
00474 mergePoint = hitFace[hitPointI];
00475 mergeDist = dist;
00476
00477
00478
00479
00480
00481
00482
00483
00484 }
00485 }
00486
00487 if (mergePoint > -1)
00488 {
00489
00490 nMergedPoints++;
00491
00492 slavePointPointHits[pointI] = mergePoint;
00493 curPoint = masterLocalPoints[mergePoint];
00494 masterPointPointHits[mergePoint] = pointI;
00495 }
00496 }
00497 }
00498
00499
00500
00501
00502 if (debug)
00503 {
00504
00505 scalar minEdgeLength = GREAT;
00506 scalar el = 0;
00507
00508 forAll (slaveEdges, edgeI)
00509 {
00510 el = slaveEdges[edgeI].mag(projectedSlavePoints);
00511
00512 if (el < SMALL)
00513 {
00514 Pout<< "Point projection problems for edge: "
00515 << slaveEdges[edgeI] << ". Length = " << el
00516 << endl;
00517 }
00518
00519 minEdgeLength = min(minEdgeLength, el);
00520 }
00521
00522 if (minEdgeLength < SMALL)
00523 {
00524 FatalErrorIn
00525 (
00526 "bool slidingInterface::projectPoints() const"
00527 ) << "Problem in point projection. Short projected edge "
00528 << " after point merge for object " << name()
00529 << abort(FatalError);
00530 }
00531 else
00532 {
00533 Pout << " ... point merge OK." << endl;
00534 }
00535 }
00536
00537
00538
00539 labelList slavePointEdgeHits(slaveLocalPoints.size(), -1);
00540
00541 label nMovedPoints = 0;
00542
00543 forAll (projectedSlavePoints, pointI)
00544 {
00545
00546 if (slavePointPointHits[pointI] < 0)
00547 {
00548
00549 point& curPoint = projectedSlavePoints[pointI];
00550
00551
00552 const labelList& hitFaceEdges =
00553 masterFaceEdges[slavePointFaceHits[pointI].hitObject()];
00554
00555
00556 const scalar mergeLength =
00557 min
00558 (
00559 minSlavePointLength[pointI],
00560 minMasterFaceLength[slavePointFaceHits[pointI].hitObject()]
00561 );
00562
00563 const scalar mergeTol = pointMergeTol_*mergeLength;
00564
00565 scalar minDistance = GREAT;
00566
00567 forAll (hitFaceEdges, edgeI)
00568 {
00569 const edge& curEdge = masterEdges[hitFaceEdges[edgeI]];
00570
00571 pointHit edgeHit =
00572 curEdge.line(masterLocalPoints).nearestDist(curPoint);
00573
00574 if (edgeHit.hit())
00575 {
00576 scalar dist =
00577 mag(edgeHit.hitPoint() - projectedSlavePoints[pointI]);
00578
00579 if (dist < mergeTol && dist < minDistance)
00580 {
00581
00582 nMovedPoints++;
00583
00584 slavePointEdgeHits[pointI] = hitFaceEdges[edgeI];
00585 projectedSlavePoints[pointI] = edgeHit.hitPoint();
00586
00587 minDistance = dist;
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600 }
00601 }
00602 }
00603
00604 if (slavePointEdgeHits[pointI] > -1)
00605 {
00606
00607
00608 point& curPoint = projectedSlavePoints[pointI];
00609
00610 const edge& hitMasterEdge =
00611 masterEdges[slavePointEdgeHits[pointI]];
00612
00613 label mergePoint = -1;
00614 scalar mergeDist = GREAT;
00615
00616 forAll (hitMasterEdge, hmeI)
00617 {
00618 scalar hmeDist =
00619 mag(masterLocalPoints[hitMasterEdge[hmeI]] - curPoint);
00620
00621
00622 const scalar mergeTol =
00623 pointMergeTol_*
00624 min
00625 (
00626 minSlavePointLength[pointI],
00627 minMasterPointLength[hitMasterEdge[hmeI]]
00628 );
00629
00630 if (hmeDist < mergeTol && hmeDist < mergeDist)
00631 {
00632 mergePoint = hitMasterEdge[hmeI];
00633 mergeDist = hmeDist;
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643 }
00644 }
00645
00646 if (mergePoint > -1)
00647 {
00648
00649 slavePointPointHits[pointI] = mergePoint;
00650 curPoint = masterLocalPoints[mergePoint];
00651 masterPointPointHits[mergePoint] = pointI;
00652
00653 slavePointFaceHits[pointI] =
00654 objectHit(true, slavePointFaceHits[pointI].hitObject());
00655
00656
00657
00658 slavePointEdgeHits[pointI] = -1;
00659 }
00660 }
00661 }
00662 }
00663
00664 if (debug)
00665 {
00666 Pout<< "Number of merged master points: " << nMergedPoints << nl
00667 << "Number of adjusted slave points: " << nMovedPoints << endl;
00668
00669
00670 scalar minEdgeLength = GREAT;
00671 scalar el = 0;
00672
00673 forAll (slaveEdges, edgeI)
00674 {
00675 el = slaveEdges[edgeI].mag(projectedSlavePoints);
00676
00677 if (el < SMALL)
00678 {
00679 Pout<< "Point projection problems for edge: "
00680 << slaveEdges[edgeI] << ". Length = " << el
00681 << endl;
00682 }
00683
00684 minEdgeLength = min(minEdgeLength, el);
00685 }
00686
00687 if (minEdgeLength < SMALL)
00688 {
00689 FatalErrorIn
00690 (
00691 "bool slidingInterface::projectPoints() const"
00692 ) << "Problem in point projection. Short projected edge "
00693 << " after correction for object " << name()
00694 << abort(FatalError);
00695 }
00696 }
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739 labelList masterPointEdgeHits(masterLocalPoints.size(), -1);
00740 scalarField masterPointEdgeDist(masterLocalPoints.size(), GREAT);
00741
00742
00743
00744
00745
00746
00747
00748 if (debug)
00749 {
00750 Pout << "Processing slave edges " << endl;
00751 }
00752
00753
00754 labelHashSet curFaceMap
00755 (
00756 nFacesPerSlaveEdge_*primitiveMesh::edgesPerFace_
00757 );
00758
00759 labelHashSet addedFaces(2*primitiveMesh::edgesPerFace_);
00760
00761 forAll (slaveEdges, edgeI)
00762 {
00763 const edge& curEdge = slaveEdges[edgeI];
00764
00765
00766
00767
00768
00769
00770
00771
00772 {
00773
00774 curFaceMap.clear();
00775 addedFaces.clear();
00776
00777
00778 const label startFace =
00779 slavePointFaceHits[curEdge.start()].hitObject();
00780 const label endFace = slavePointFaceHits[curEdge.end()].hitObject();
00781
00782
00783 curFaceMap.insert(startFace);
00784 addedFaces.insert(startFace);
00785
00786
00787
00788 label nSweeps = 0;
00789 bool completed = false;
00790
00791 while (nSweeps < edgeFaceEscapeLimit_)
00792 {
00793 nSweeps++;
00794
00795 if (addedFaces.found(endFace))
00796 {
00797 completed = true;
00798 }
00799
00800
00801 const labelList cf = addedFaces.toc();
00802 addedFaces.clear();
00803
00804 forAll (cf, cfI)
00805 {
00806 const labelList& curNbrs = masterFaceFaces[cf[cfI]];
00807
00808 forAll (curNbrs, nbrI)
00809 {
00810 if (!curFaceMap.found(curNbrs[nbrI]))
00811 {
00812 curFaceMap.insert(curNbrs[nbrI]);
00813 addedFaces.insert(curNbrs[nbrI]);
00814 }
00815 }
00816 }
00817
00818 if (completed) break;
00819
00820 if (debug)
00821 {
00822 Pout << ".";
00823 }
00824 }
00825
00826 if (!completed)
00827 {
00828 if (debug)
00829 {
00830 Pout << "x";
00831 }
00832
00833
00834
00835
00836 label nReverseSweeps = 0;
00837
00838 addedFaces.clear();
00839 curFaceMap.insert(endFace);
00840 addedFaces.insert(endFace);
00841
00842 while (nReverseSweeps < edgeFaceEscapeLimit_)
00843 {
00844 nReverseSweeps++;
00845
00846 if (addedFaces.found(startFace))
00847 {
00848 completed = true;
00849 }
00850
00851
00852 const labelList cf = addedFaces.toc();
00853 addedFaces.clear();
00854
00855 forAll (cf, cfI)
00856 {
00857 const labelList& curNbrs = masterFaceFaces[cf[cfI]];
00858
00859 forAll (curNbrs, nbrI)
00860 {
00861 if (!curFaceMap.found(curNbrs[nbrI]))
00862 {
00863 curFaceMap.insert(curNbrs[nbrI]);
00864 addedFaces.insert(curNbrs[nbrI]);
00865 }
00866 }
00867 }
00868
00869 if (completed) break;
00870
00871 if (debug)
00872 {
00873 Pout << ".";
00874 }
00875 }
00876 }
00877
00878 if (completed)
00879 {
00880 if (debug)
00881 {
00882 Pout << "+ ";
00883 }
00884 }
00885 else
00886 {
00887 if (debug)
00888 {
00889 Pout << "z ";
00890 }
00891 }
00892
00893
00894
00895
00896 labelHashSet curPointMap
00897 (
00898 nFacesPerSlaveEdge_*primitiveMesh::pointsPerFace_
00899 );
00900
00901 const labelList curFaces = curFaceMap.toc();
00902
00903 forAll (curFaces, faceI)
00904 {
00905 const face& f = masterLocalFaces[curFaces[faceI]];
00906
00907 forAll (f, pointI)
00908 {
00909 curPointMap.insert(f[pointI]);
00910 }
00911 }
00912
00913 const labelList curMasterPoints = curPointMap.toc();
00914
00915
00916
00917 linePointRef edgeLine = curEdge.line(projectedSlavePoints);
00918
00919 const vector edgeVec = edgeLine.vec();
00920 const scalar edgeMag = edgeLine.mag();
00921
00922
00923
00924
00925
00926 scalar slaveCatchDist =
00927 edgeMasterCatchFraction_*edgeMag
00928 + 0.5*
00929 (
00930 mag
00931 (
00932 projectedSlavePoints[curEdge.start()]
00933 - slaveLocalPoints[curEdge.start()]
00934 )
00935 + mag
00936 (
00937 projectedSlavePoints[curEdge.end()]
00938 - slaveLocalPoints[curEdge.end()]
00939 )
00940 );
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950 vector edgeNormalInPlane =
00951 edgeVec
00952 ^ (
00953 slavePointNormals[curEdge.start()]
00954 + slavePointNormals[curEdge.end()]
00955 );
00956
00957 edgeNormalInPlane /= mag(edgeNormalInPlane);
00958
00959 forAll (curMasterPoints, pointI)
00960 {
00961 const label cmp = curMasterPoints[pointI];
00962
00963
00964
00965 if
00966 (
00967 slavePointPointHits[curEdge.start()] == cmp
00968 || slavePointPointHits[curEdge.end()] == cmp
00969 || masterPointPointHits[cmp] > -1
00970 )
00971 {
00972
00973 continue;
00974 }
00975
00976
00977 pointHit edgeLineHit =
00978 edgeLine.nearestDist(masterLocalPoints[cmp]);
00979
00980 if (edgeLineHit.hit())
00981 {
00982
00983
00984
00985
00986
00987
00988 scalar cutOnSlave =
00989 ((edgeLineHit.hitPoint() - edgeLine.start()) & edgeVec)
00990 /sqr(edgeMag);
00991
00992 scalar distInEdgePlane =
00993 min
00994 (
00995 edgeLineHit.distance(),
00996 mag
00997 (
00998 (
00999 masterLocalPoints[cmp]
01000 - edgeLineHit.hitPoint()
01001 )
01002 & edgeNormalInPlane
01003 )
01004 );
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018 if
01019 (
01020 cutOnSlave > edgeEndCutoffTol_
01021 && cutOnSlave < 1.0 - edgeEndCutoffTol_
01022 && distInEdgePlane < edgeMergeTol_*edgeMag
01023 && edgeLineHit.distance()
01024 < min
01025 (
01026 slaveCatchDist,
01027 masterPointEdgeDist[cmp]
01028 )
01029 )
01030 {
01031 if (debug)
01032 {
01033 if (masterPointEdgeHits[cmp] == -1)
01034 {
01035
01036 Pout << "m";
01037 }
01038 else
01039 {
01040
01041 Pout << "M";
01042 }
01043 }
01044
01045
01046 masterPointEdgeHits[cmp] = edgeI;
01047 masterPointEdgeDist[cmp] = edgeLineHit.distance();
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067 }
01068 }
01069 }
01070 }
01071 }
01072
01073 if (debug)
01074 {
01075 Pout << endl;
01076 }
01077
01078
01079 if (debug)
01080 {
01081 Pout<< "bool slidingInterface::projectPoints() for object "
01082 << name() << " : "
01083 << "Finished projecting points. Topology = ";
01084 }
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103 if (!attached_)
01104 {
01105
01106 trigger_ = true;
01107
01108
01109 deleteDemandDrivenData(slavePointPointHitsPtr_);
01110 slavePointPointHitsPtr_ = new labelList(slavePointPointHits);
01111
01112 deleteDemandDrivenData(slavePointEdgeHitsPtr_);
01113 slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits);
01114
01115 deleteDemandDrivenData(slavePointFaceHitsPtr_);
01116 slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits);
01117
01118 deleteDemandDrivenData(masterPointEdgeHitsPtr_);
01119 masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits);
01120
01121 if (debug)
01122 {
01123 Pout << "(Detached interface) changing." << endl;
01124 }
01125 }
01126 else
01127 {
01128
01129
01130 trigger_ = false;
01131
01132 if
01133 (
01134 !slavePointPointHitsPtr_
01135 || !slavePointEdgeHitsPtr_
01136 || !slavePointFaceHitsPtr_
01137 || !masterPointEdgeHitsPtr_
01138 )
01139 {
01140
01141 deleteDemandDrivenData(slavePointPointHitsPtr_);
01142 slavePointPointHitsPtr_ = new labelList(slavePointPointHits);
01143
01144 deleteDemandDrivenData(slavePointEdgeHitsPtr_);
01145 slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits);
01146
01147 deleteDemandDrivenData(slavePointFaceHitsPtr_);
01148 slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits);
01149
01150 deleteDemandDrivenData(masterPointEdgeHitsPtr_);
01151 masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits);
01152
01153 if (debug)
01154 {
01155 Pout << "(Attached interface restart) changing." << endl;
01156 }
01157
01158 trigger_ = true;
01159 return trigger_;
01160 }
01161
01162 if (slavePointPointHits != (*slavePointPointHitsPtr_))
01163 {
01164 if (debug)
01165 {
01166 Pout << "(Point projection) ";
01167 }
01168
01169 trigger_ = true;
01170 }
01171
01172 if (slavePointEdgeHits != (*slavePointEdgeHitsPtr_))
01173 {
01174 if (debug)
01175 {
01176 Pout << "(Edge projection) ";
01177 }
01178
01179 trigger_ = true;
01180 }
01181
01182
01183
01184 bool faceHitsDifferent = false;
01185
01186 const List<objectHit>& oldPointFaceHits = *slavePointFaceHitsPtr_;
01187
01188 forAll (slavePointFaceHits, pointI)
01189 {
01190 if
01191 (
01192 slavePointPointHits[pointI] < 0
01193 && slavePointEdgeHits[pointI] < 0
01194 )
01195 {
01196
01197 if (slavePointFaceHits[pointI] != oldPointFaceHits[pointI])
01198 {
01199
01200 faceHitsDifferent = true;
01201 break;
01202 }
01203 }
01204 }
01205
01206 if (faceHitsDifferent)
01207 {
01208 if (debug)
01209 {
01210 Pout << "(Face projection) ";
01211 }
01212
01213 trigger_ = true;
01214
01215 }
01216
01217 if (masterPointEdgeHits != (*masterPointEdgeHitsPtr_))
01218 {
01219 if (debug)
01220 {
01221 Pout << "(Master point projection) ";
01222 }
01223
01224 trigger_ = true;
01225 }
01226
01227
01228 if (trigger_)
01229 {
01230
01231 deleteDemandDrivenData(slavePointPointHitsPtr_);
01232 slavePointPointHitsPtr_ = new labelList(slavePointPointHits);
01233
01234 deleteDemandDrivenData(slavePointEdgeHitsPtr_);
01235 slavePointEdgeHitsPtr_ = new labelList(slavePointEdgeHits);
01236
01237 deleteDemandDrivenData(slavePointFaceHitsPtr_);
01238 slavePointFaceHitsPtr_ = new List<objectHit>(slavePointFaceHits);
01239
01240 deleteDemandDrivenData(masterPointEdgeHitsPtr_);
01241 masterPointEdgeHitsPtr_ = new labelList(masterPointEdgeHits);
01242
01243 if (debug)
01244 {
01245 Pout << "changing." << endl;
01246 }
01247 }
01248 else
01249 {
01250 if (debug)
01251 {
01252 Pout << "preserved." << endl;
01253 }
01254 }
01255 }
01256
01257 return trigger_;
01258 }
01259
01260
01261 void Foam::slidingInterface::clearPointProjection() const
01262 {
01263 deleteDemandDrivenData(slavePointPointHitsPtr_);
01264 deleteDemandDrivenData(slavePointEdgeHitsPtr_);
01265 deleteDemandDrivenData(slavePointFaceHitsPtr_);
01266 deleteDemandDrivenData(masterPointEdgeHitsPtr_);
01267
01268 deleteDemandDrivenData(projectedSlavePointsPtr_);
01269 }
01270
01271
01272