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