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 "refinementSurfaces.H"
00028 #include "Time.H"
00029 #include "searchableSurfaces.H"
00030 #include "shellSurfaces.H"
00031 #include "triSurfaceMesh.H"
00032 #include "labelPair.H"
00033 #include "searchableSurfacesQueries.H"
00034 #include "UPtrList.H"
00035
00036
00037
00038
00039
00040 Foam::refinementSurfaces::refinementSurfaces
00041 (
00042 const searchableSurfaces& allGeometry,
00043 const PtrList<dictionary>& surfaceDicts
00044 )
00045 :
00046 allGeometry_(allGeometry),
00047 surfaces_(surfaceDicts.size()),
00048 names_(surfaceDicts.size()),
00049 faceZoneNames_(surfaceDicts.size()),
00050 cellZoneNames_(surfaceDicts.size()),
00051 zoneInside_(surfaceDicts.size()),
00052 regionOffset_(surfaceDicts.size())
00053 {
00054 labelList globalMinLevel(surfaceDicts.size(), 0);
00055 labelList globalMaxLevel(surfaceDicts.size(), 0);
00056 scalarField globalAngle(surfaceDicts.size(), -GREAT);
00057 List<Map<label> > regionMinLevel(surfaceDicts.size());
00058 List<Map<label> > regionMaxLevel(surfaceDicts.size());
00059 List<Map<scalar> > regionAngle(surfaceDicts.size());
00060
00061
00062
00063
00064
00065 forAll(surfaceDicts, surfI)
00066 {
00067 const dictionary& dict = surfaceDicts[surfI];
00068
00069 dict.lookup("name") >> names_[surfI];
00070
00071 surfaces_[surfI] = allGeometry_.findSurfaceID(names_[surfI]);
00072
00073
00074 globalMinLevel[surfI] = readLabel(dict.lookup("minRefinementLevel"));
00075 globalMaxLevel[surfI] = readLabel(dict.lookup("maxRefinementLevel"));
00076
00077
00078 if (dict.found("faceZone"))
00079 {
00080 dict.lookup("faceZone") >> faceZoneNames_[surfI];
00081 dict.lookup("cellZone") >> cellZoneNames_[surfI];
00082 dict.lookup("zoneInside") >> zoneInside_[surfI];
00083 }
00084
00085
00086 if (dict.found("perpendicularAngle"))
00087 {
00088 globalAngle[surfI] = readScalar(dict.lookup("perpendicularAngle"));
00089 }
00090
00092
00093
00094
00095
00096
00097
00098 if (dict.found("regions"))
00099 {
00100 PtrList<dictionary> regionDicts(dict.lookup("regions"));
00101
00102 const wordList& regionNames =
00103 allGeometry_[surfaces_[surfI]].regions();
00104
00105 forAll(regionDicts, dictI)
00106 {
00107 const dictionary& regionDict = regionDicts[dictI];
00108
00109 const word regionName(regionDict.lookup("name"));
00110
00111 label regionI = findIndex(regionNames, regionName);
00112
00113 if (regionI == -1)
00114 {
00115 FatalErrorIn
00116 (
00117 "refinementSurfaces::refinementSurfaces"
00118 "(const IOobject&, const PtrList<dictionary>&)"
00119 ) << "No region called " << regionName << " on surface "
00120 << allGeometry_[surfaces_[surfI]].name() << endl
00121 << "Valid regions are " << regionNames
00122 << exit(FatalError);
00123 }
00124
00125
00126 label min = readLabel(regionDict.lookup("minRefinementLevel"));
00127 label max = readLabel(regionDict.lookup("maxRefinementLevel"));
00128
00129 bool hasInserted = regionMinLevel[surfI].insert(regionI, min);
00130 if (!hasInserted)
00131 {
00132 FatalErrorIn
00133 (
00134 "refinementSurfaces::refinementSurfaces"
00135 "(const IOobject&, const PtrList<dictionary>&)"
00136 ) << "Duplicate region name " << regionName
00137 << " on surface " << names_[surfI]
00138 << exit(FatalError);
00139 }
00140 regionMaxLevel[surfI].insert(regionI, max);
00141
00142 if (regionDict.found("perpendicularAngle"))
00143 {
00144 regionAngle[surfI].insert
00145 (
00146 regionI,
00147 readScalar(regionDict.lookup("perpendicularAngle"))
00148 );
00149 }
00150 }
00151 }
00152 }
00153
00154
00155
00156 {
00157 HashTable<label> surfaceNames(names_.size());
00158
00159 forAll(names_, surfI)
00160 {
00161 if (!surfaceNames.insert(names_[surfI], surfI))
00162 {
00163 FatalErrorIn
00164 (
00165 "refinementSurfaces::refinementSurfaces"
00166 "(const IOobject&, const PtrList<dictionary>&)"
00167 ) << "Duplicate surface name " << names_[surfI] << endl
00168 << "Previous occurrence of name at surface "
00169 << surfaceNames[names_[surfI]]
00170 << exit(FatalError);
00171 }
00172 }
00173 }
00174
00175
00176 label nRegions = 0;
00177
00178 forAll(surfaceDicts, surfI)
00179 {
00180 regionOffset_[surfI] = nRegions;
00181
00182 nRegions += allGeometry_[surfaces_[surfI]].regions().size();
00183 }
00184
00185
00186 minLevel_.setSize(nRegions);
00187 minLevel_ = 0;
00188 maxLevel_.setSize(nRegions);
00189 maxLevel_ = 0;
00190 perpendicularAngle_.setSize(nRegions);
00191 perpendicularAngle_ = -GREAT;
00192
00193
00194
00195 forAll(surfaceDicts, surfI)
00196 {
00197 label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
00198
00199
00200 for (label i = 0; i < nRegions; i++)
00201 {
00202 minLevel_[regionOffset_[surfI] + i] = globalMinLevel[surfI];
00203 maxLevel_[regionOffset_[surfI] + i] = globalMaxLevel[surfI];
00204 perpendicularAngle_[regionOffset_[surfI] + i] = globalAngle[surfI];
00205 }
00206
00207
00208 forAllConstIter(Map<label>, regionMinLevel[surfI], iter)
00209 {
00210 label globalRegionI = regionOffset_[surfI] + iter.key();
00211
00212 minLevel_[globalRegionI] = iter();
00213 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
00214
00215
00216 if
00217 (
00218 minLevel_[globalRegionI] < 0
00219 || maxLevel_[globalRegionI] < minLevel_[globalRegionI]
00220 )
00221 {
00222 FatalErrorIn
00223 (
00224 "refinementSurfaces::refinementSurfaces"
00225 "(const IOobject&, const PtrList<dictionary>&)"
00226 ) << "Illegal level or layer specification for surface "
00227 << names_[surfI]
00228 << " : minLevel:" << minLevel_[globalRegionI]
00229 << " maxLevel:" << maxLevel_[globalRegionI]
00230 << exit(FatalError);
00231 }
00232 }
00233 forAllConstIter(Map<scalar>, regionAngle[surfI], iter)
00234 {
00235 label globalRegionI = regionOffset_[surfI] + iter.key();
00236
00237 perpendicularAngle_[globalRegionI] = regionAngle[surfI][iter.key()];
00238 }
00239
00240
00242
00243
00244
00245
00246
00247
00248
00249
00250 }
00251 }
00252
00253
00254 Foam::refinementSurfaces::refinementSurfaces
00255 (
00256 const searchableSurfaces& allGeometry,
00257 const dictionary& surfacesDict
00258 )
00259 :
00260 allGeometry_(allGeometry),
00261 surfaces_(surfacesDict.size()),
00262 names_(surfacesDict.size()),
00263 faceZoneNames_(surfacesDict.size()),
00264 cellZoneNames_(surfacesDict.size()),
00265 zoneInside_(surfacesDict.size()),
00266 regionOffset_(surfacesDict.size())
00267 {
00268
00269
00270
00271
00272 label surfI = 0;
00273 forAll(allGeometry.names(), geomI)
00274 {
00275 const word& geomName = allGeometry_.names()[geomI];
00276
00277 if (surfacesDict.found(geomName))
00278 {
00279 surfI++;
00280 }
00281 }
00282
00283
00284 surfaces_.setSize(surfI);
00285 names_.setSize(surfI);
00286 faceZoneNames_.setSize(surfI);
00287 cellZoneNames_.setSize(surfI);
00288 zoneInside_.setSize(surfI);
00289 regionOffset_.setSize(surfI);
00290
00291 labelList globalMinLevel(surfI, 0);
00292 labelList globalMaxLevel(surfI, 0);
00293 scalarField globalAngle(surfI, -GREAT);
00294 List<Map<label> > regionMinLevel(surfI);
00295 List<Map<label> > regionMaxLevel(surfI);
00296 List<Map<scalar> > regionAngle(surfI);
00297
00298 surfI = 0;
00299 forAll(allGeometry.names(), geomI)
00300 {
00301 const word& geomName = allGeometry_.names()[geomI];
00302
00303 if (surfacesDict.found(geomName))
00304 {
00305 const dictionary& dict = surfacesDict.subDict(geomName);
00306
00307 names_[surfI] = geomName;
00308 surfaces_[surfI] = geomI;
00309
00310 const labelPair refLevel(dict.lookup("level"));
00311 globalMinLevel[surfI] = refLevel[0];
00312 globalMaxLevel[surfI] = refLevel[1];
00313
00314
00315 if (dict.found("faceZone"))
00316 {
00317 dict.lookup("faceZone") >> faceZoneNames_[surfI];
00318 dict.lookup("cellZone") >> cellZoneNames_[surfI];
00319 dict.lookup("zoneInside") >> zoneInside_[surfI];
00320 }
00321
00322
00323 if (dict.found("perpendicularAngle"))
00324 {
00325 globalAngle[surfI] = readScalar
00326 (
00327 dict.lookup("perpendicularAngle")
00328 );
00329 }
00330
00331 if (dict.found("regions"))
00332 {
00333 const dictionary& regionsDict = dict.subDict("regions");
00334 const wordList& regionNames =
00335 allGeometry_[surfaces_[surfI]].regions();
00336
00337 forAll(regionNames, regionI)
00338 {
00339 if (regionsDict.found(regionNames[regionI]))
00340 {
00341
00342 const dictionary& regionDict = regionsDict.subDict
00343 (
00344 regionNames[regionI]
00345 );
00346
00347 const labelPair refLevel(regionDict.lookup("level"));
00348
00349 regionMinLevel[surfI].insert(regionI, refLevel[0]);
00350 regionMaxLevel[surfI].insert(regionI, refLevel[1]);
00351
00352 if (regionDict.found("perpendicularAngle"))
00353 {
00354 regionAngle[surfI].insert
00355 (
00356 regionI,
00357 readScalar
00358 (
00359 regionDict.lookup("perpendicularAngle")
00360 )
00361 );
00362 }
00363 }
00364 }
00365 }
00366 surfI++;
00367 }
00368 }
00369
00370
00371 label nRegions = 0;
00372
00373 forAll(surfaces_, surfI)
00374 {
00375 regionOffset_[surfI] = nRegions;
00376 nRegions += allGeometry_[surfaces_[surfI]].regions().size();
00377 }
00378
00379
00380 minLevel_.setSize(nRegions);
00381 minLevel_ = 0;
00382 maxLevel_.setSize(nRegions);
00383 maxLevel_ = 0;
00384 perpendicularAngle_.setSize(nRegions);
00385 perpendicularAngle_ = -GREAT;
00386
00387
00388 forAll(globalMinLevel, surfI)
00389 {
00390 label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
00391
00392
00393 for (label i = 0; i < nRegions; i++)
00394 {
00395 minLevel_[regionOffset_[surfI] + i] = globalMinLevel[surfI];
00396 maxLevel_[regionOffset_[surfI] + i] = globalMaxLevel[surfI];
00397 perpendicularAngle_[regionOffset_[surfI] + i] = globalAngle[surfI];
00398 }
00399
00400
00401 forAllConstIter(Map<label>, regionMinLevel[surfI], iter)
00402 {
00403 label globalRegionI = regionOffset_[surfI] + iter.key();
00404
00405 minLevel_[globalRegionI] = iter();
00406 maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
00407
00408
00409 if
00410 (
00411 minLevel_[globalRegionI] < 0
00412 || maxLevel_[globalRegionI] < minLevel_[globalRegionI]
00413 )
00414 {
00415 FatalErrorIn
00416 (
00417 "refinementSurfaces::refinementSurfaces"
00418 "(const searchableSurfaces&, const dictionary>&"
00419 ) << "Illegal level or layer specification for surface "
00420 << names_[surfI]
00421 << " : minLevel:" << minLevel_[globalRegionI]
00422 << " maxLevel:" << maxLevel_[globalRegionI]
00423 << exit(FatalError);
00424 }
00425 }
00426 forAllConstIter(Map<scalar>, regionAngle[surfI], iter)
00427 {
00428 label globalRegionI = regionOffset_[surfI] + iter.key();
00429
00430 perpendicularAngle_[globalRegionI] = regionAngle[surfI][iter.key()];
00431 }
00432 }
00433 }
00434
00435
00436
00437
00438
00439 Foam::labelList Foam::refinementSurfaces::getUnnamedSurfaces() const
00440 {
00441 labelList anonymousSurfaces(faceZoneNames_.size());
00442
00443 label i = 0;
00444 forAll(faceZoneNames_, surfI)
00445 {
00446 if (faceZoneNames_[surfI].empty())
00447 {
00448 anonymousSurfaces[i++] = surfI;
00449 }
00450 }
00451 anonymousSurfaces.setSize(i);
00452
00453 return anonymousSurfaces;
00454 }
00455
00456
00457
00458 Foam::labelList Foam::refinementSurfaces::getNamedSurfaces() const
00459 {
00460 labelList namedSurfaces(faceZoneNames_.size());
00461
00462 label namedI = 0;
00463 forAll(faceZoneNames_, surfI)
00464 {
00465 if (faceZoneNames_[surfI].size())
00466 {
00467 namedSurfaces[namedI++] = surfI;
00468 }
00469 }
00470 namedSurfaces.setSize(namedI);
00471
00472 return namedSurfaces;
00473 }
00474
00475
00476
00477 Foam::labelList Foam::refinementSurfaces::getClosedNamedSurfaces() const
00478 {
00479 labelList named(getNamedSurfaces());
00480
00481 labelList closed(named.size());
00482 label closedI = 0;
00483
00484 forAll(named, i)
00485 {
00486 label surfI = named[i];
00487
00488 if (allGeometry_[surfaces_[surfI]].hasVolumeType())
00489 {
00490 closed[closedI++] = surfI;
00491 }
00492 }
00493 closed.setSize(closedI);
00494
00495 return closed;
00496 }
00497
00498
00499
00500 Foam::labelList Foam::refinementSurfaces::countRegions(const triSurface& s)
00501 {
00502 const geometricSurfacePatchList& regions = s.patches();
00503
00504 labelList nTris(regions.size(), 0);
00505
00506 forAll(s, triI)
00507 {
00508 nTris[s[triI].region()]++;
00509 }
00510 return nTris;
00511 }
00512
00513
00514
00515
00516 void Foam::refinementSurfaces::setMinLevelFields
00517 (
00518 const shellSurfaces& shells
00519 )
00520 {
00521 forAll(surfaces_, surfI)
00522 {
00523 const searchableSurface& geom = allGeometry_[surfaces_[surfI]];
00524
00525 if (isA<triSurfaceMesh>(geom))
00526 {
00527 const triSurfaceMesh& triMesh = refCast<const triSurfaceMesh>(geom);
00528
00529 autoPtr<triSurfaceLabelField> minLevelFieldPtr
00530 (
00531 new triSurfaceLabelField
00532 (
00533 IOobject
00534 (
00535 "minLevel",
00536 triMesh.objectRegistry::time().timeName(),
00537 "triSurface",
00538 triMesh,
00539 IOobject::NO_READ,
00540 IOobject::AUTO_WRITE
00541 ),
00542 triMesh,
00543 dimless
00544 )
00545 );
00546 triSurfaceLabelField& minLevelField = minLevelFieldPtr();
00547
00548 const triSurface& s = static_cast<const triSurface&>(triMesh);
00549
00550
00551 forAll(s, triI)
00552 {
00553 minLevelField[triI] = minLevel(surfI, s[triI].region());
00554 }
00555
00556
00557 pointField fc(s.size());
00558 forAll(s, triI)
00559 {
00560 fc[triI] = s[triI].centre(s.points());
00561 }
00562
00563 labelList shellLevel;
00564 shells.findHigherLevel(fc, minLevelField, shellLevel);
00565
00566 forAll(minLevelField, triI)
00567 {
00568 minLevelField[triI] = max
00569 (
00570 minLevelField[triI],
00571 shellLevel[triI]
00572 );
00573 }
00574
00575
00576 minLevelFieldPtr.ptr()->store();
00577 }
00578 }
00579 }
00580
00581
00582
00583
00584 void Foam::refinementSurfaces::findHigherIntersection
00585 (
00586 const pointField& start,
00587 const pointField& end,
00588 const labelList& currentLevel,
00589
00590 labelList& surfaces,
00591 labelList& surfaceLevel
00592 ) const
00593 {
00594 surfaces.setSize(start.size());
00595 surfaces = -1;
00596 surfaceLevel.setSize(start.size());
00597 surfaceLevel = -1;
00598
00599 if (surfaces_.empty())
00600 {
00601 return;
00602 }
00603
00604
00605 labelList hitMap(identity(start.size()));
00606 pointField p0(start);
00607 pointField p1(end);
00608 List<pointIndexHit> hitInfo(start.size());
00609
00610 forAll(surfaces_, surfI)
00611 {
00612 const searchableSurface& geom = allGeometry_[surfaces_[surfI]];
00613
00614 geom.findLineAny(p0, p1, hitInfo);
00615
00616 labelList minLevelField;
00617 if (isA<triSurfaceMesh>(geom))
00618 {
00619 const triSurfaceMesh& triMesh = refCast<const triSurfaceMesh>(geom);
00620 triMesh.getField
00621 (
00622 "minLevel",
00623 hitInfo,
00624 minLevelField
00625 );
00626 }
00627
00628
00629
00630 label newI = 0;
00631 forAll(hitInfo, hitI)
00632 {
00633
00634 label minLocalLevel = -1;
00635
00636 if (hitInfo[hitI].hit())
00637 {
00638
00639 if (minLevelField.size())
00640 {
00641 minLocalLevel = minLevelField[hitI];
00642 }
00643 else
00644 {
00645
00646
00647 minLocalLevel = minLevel(surfI, 0);
00648 }
00649 }
00650
00651 label pointI = hitMap[hitI];
00652
00653 if (minLocalLevel > currentLevel[pointI])
00654 {
00655 surfaces[pointI] = surfI;
00656 surfaceLevel[pointI] = minLocalLevel;
00657 }
00658 else
00659 {
00660 if (hitI != newI)
00661 {
00662 hitMap[newI] = hitMap[hitI];
00663 p0[newI] = p0[hitI];
00664 p1[newI] = p1[hitI];
00665 }
00666 newI++;
00667 }
00668 }
00669
00670
00671 if (returnReduce(newI, sumOp<label>()) == 0)
00672 {
00673 break;
00674 }
00675
00676
00677 hitMap.setSize(newI);
00678 p0.setSize(newI);
00679 p1.setSize(newI);
00680 hitInfo.setSize(newI);
00681 }
00682 }
00683
00684
00685 void Foam::refinementSurfaces::findAllHigherIntersections
00686 (
00687 const pointField& start,
00688 const pointField& end,
00689 const labelList& currentLevel,
00690
00691 List<vectorList>& surfaceNormal,
00692 labelListList& surfaceLevel
00693 ) const
00694 {
00695 surfaceLevel.setSize(start.size());
00696 surfaceNormal.setSize(start.size());
00697
00698 if (surfaces_.empty())
00699 {
00700 return;
00701 }
00702
00703
00704 List<List<pointIndexHit> > hitInfo;
00705 labelList pRegions;
00706 vectorField pNormals;
00707
00708 forAll(surfaces_, surfI)
00709 {
00710 allGeometry_[surfaces_[surfI]].findLineAll(start, end, hitInfo);
00711
00712
00713
00714
00715
00716 label n = 0;
00717 forAll(hitInfo, pointI)
00718 {
00719 n += hitInfo[pointI].size();
00720 }
00721
00722 List<pointIndexHit> surfInfo(n);
00723 labelList pointMap(n);
00724 n = 0;
00725
00726 forAll(hitInfo, pointI)
00727 {
00728 const List<pointIndexHit>& pHits = hitInfo[pointI];
00729
00730 forAll(pHits, i)
00731 {
00732 surfInfo[n] = pHits[i];
00733 pointMap[n] = pointI;
00734 n++;
00735 }
00736 }
00737
00738 labelList surfRegion(n);
00739 vectorField surfNormal(n);
00740 allGeometry_[surfaces_[surfI]].getRegion(surfInfo, surfRegion);
00741 allGeometry_[surfaces_[surfI]].getNormal(surfInfo, surfNormal);
00742
00743 surfInfo.clear();
00744
00745
00746
00747
00748
00749 forAll(surfRegion, i)
00750 {
00751 label region = globalRegion(surfI, surfRegion[i]);
00752 label pointI = pointMap[i];
00753
00754 if (maxLevel_[region] > currentLevel[pointI])
00755 {
00756
00757 label sz = surfaceNormal[pointI].size();
00758 surfaceNormal[pointI].setSize(sz+1);
00759 surfaceNormal[pointI][sz] = surfNormal[i];
00760
00761 surfaceLevel[pointI].setSize(sz+1);
00762 surfaceLevel[pointI][sz] = maxLevel_[region];
00763 }
00764 }
00765 }
00766 }
00767
00768
00769 void Foam::refinementSurfaces::findNearestIntersection
00770 (
00771 const labelList& surfacesToTest,
00772 const pointField& start,
00773 const pointField& end,
00774
00775 labelList& surface1,
00776 List<pointIndexHit>& hit1,
00777 labelList& region1,
00778 labelList& surface2,
00779 List<pointIndexHit>& hit2,
00780 labelList& region2
00781 ) const
00782 {
00783
00784
00785
00786
00787 surface1.setSize(start.size());
00788 surface1 = -1;
00789 hit1.setSize(start.size());
00790 region1.setSize(start.size());
00791
00792
00793 pointField nearest(end);
00794
00795 List<pointIndexHit> nearestInfo(start.size());
00796 labelList region;
00797
00798 forAll(surfacesToTest, testI)
00799 {
00800 label surfI = surfacesToTest[testI];
00801
00802
00803 allGeometry_[surfaces_[surfI]].findLine
00804 (
00805 start,
00806 nearest,
00807 nearestInfo
00808 );
00809 allGeometry_[surfaces_[surfI]].getRegion
00810 (
00811 nearestInfo,
00812 region
00813 );
00814
00815 forAll(nearestInfo, pointI)
00816 {
00817 if (nearestInfo[pointI].hit())
00818 {
00819 hit1[pointI] = nearestInfo[pointI];
00820 surface1[pointI] = surfI;
00821 region1[pointI] = region[pointI];
00822 nearest[pointI] = hit1[pointI].hitPoint();
00823 }
00824 }
00825 }
00826
00827
00828
00829
00830
00831
00832
00833 surface2 = surface1;
00834 hit2 = hit1;
00835 region2 = region1;
00836
00837
00838 forAll(nearest, pointI)
00839 {
00840 if (hit1[pointI].hit())
00841 {
00842 nearest[pointI] = hit1[pointI].hitPoint();
00843 }
00844 else
00845 {
00846
00847 nearest[pointI] = end[pointI];
00848 }
00849 }
00850
00851 forAll(surfacesToTest, testI)
00852 {
00853 label surfI = surfacesToTest[testI];
00854
00855
00856 allGeometry_[surfaces_[surfI]].findLine
00857 (
00858 end,
00859 nearest,
00860 nearestInfo
00861 );
00862 allGeometry_[surfaces_[surfI]].getRegion
00863 (
00864 nearestInfo,
00865 region
00866 );
00867
00868 forAll(nearestInfo, pointI)
00869 {
00870 if (nearestInfo[pointI].hit())
00871 {
00872 hit2[pointI] = nearestInfo[pointI];
00873 surface2[pointI] = surfI;
00874 region2[pointI] = region[pointI];
00875 nearest[pointI] = hit2[pointI].hitPoint();
00876 }
00877 }
00878 }
00879
00880
00881
00882
00883 forAll(hit1, pointI)
00884 {
00885 if (hit1[pointI].hit() && !hit2[pointI].hit())
00886 {
00887 hit2[pointI] = hit1[pointI];
00888 surface2[pointI] = surface1[pointI];
00889 region2[pointI] = region1[pointI];
00890 }
00891 }
00892 }
00893
00894
00895 void Foam::refinementSurfaces::findAnyIntersection
00896 (
00897 const pointField& start,
00898 const pointField& end,
00899
00900 labelList& hitSurface,
00901 List<pointIndexHit>& hitInfo
00902 ) const
00903 {
00904 searchableSurfacesQueries::findAnyIntersection
00905 (
00906 allGeometry_,
00907 surfaces_,
00908 start,
00909 end,
00910 hitSurface,
00911 hitInfo
00912 );
00913 }
00914
00915
00916 void Foam::refinementSurfaces::findNearest
00917 (
00918 const labelList& surfacesToTest,
00919 const pointField& samples,
00920 const scalarField& nearestDistSqr,
00921 labelList& hitSurface,
00922 List<pointIndexHit>& hitInfo
00923 ) const
00924 {
00925 labelList geometries(UIndirectList<label>(surfaces_, surfacesToTest));
00926
00927
00928 searchableSurfacesQueries::findNearest
00929 (
00930 allGeometry_,
00931 geometries,
00932 samples,
00933 nearestDistSqr,
00934 hitSurface,
00935 hitInfo
00936 );
00937
00938
00939 forAll(hitSurface, pointI)
00940 {
00941 if (hitSurface[pointI] != -1)
00942 {
00943 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
00944 }
00945 }
00946 }
00947
00948
00949 void Foam::refinementSurfaces::findNearestRegion
00950 (
00951 const labelList& surfacesToTest,
00952 const pointField& samples,
00953 const scalarField& nearestDistSqr,
00954 labelList& hitSurface,
00955 labelList& hitRegion
00956 ) const
00957 {
00958 labelList geometries(UIndirectList<label>(surfaces_, surfacesToTest));
00959
00960
00961 List<pointIndexHit> hitInfo;
00962 searchableSurfacesQueries::findNearest
00963 (
00964 allGeometry_,
00965 geometries,
00966 samples,
00967 nearestDistSqr,
00968 hitSurface,
00969 hitInfo
00970 );
00971
00972
00973 forAll(hitSurface, pointI)
00974 {
00975 if (hitSurface[pointI] != -1)
00976 {
00977 hitSurface[pointI] = surfacesToTest[hitSurface[pointI]];
00978 }
00979 }
00980
00981
00982 hitRegion.setSize(hitSurface.size());
00983 hitRegion = -1;
00984
00985 forAll(surfacesToTest, i)
00986 {
00987 label surfI = surfacesToTest[i];
00988
00989
00990 const labelList localIndices(findIndices(hitSurface, surfI));
00991
00992 List<pointIndexHit> localHits
00993 (
00994 UIndirectList<pointIndexHit>
00995 (
00996 hitInfo,
00997 localIndices
00998 )
00999 );
01000
01001 labelList localRegion;
01002 allGeometry_[surfaces_[surfI]].getRegion(localHits, localRegion);
01003
01004 forAll(localIndices, i)
01005 {
01006 hitRegion[localIndices[i]] = localRegion[i];
01007 }
01008 }
01009 }
01010
01011
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057 void Foam::refinementSurfaces::findInside
01058 (
01059 const labelList& testSurfaces,
01060 const pointField& pt,
01061 labelList& insideSurfaces
01062 ) const
01063 {
01064 insideSurfaces.setSize(pt.size());
01065 insideSurfaces = -1;
01066
01067 forAll(testSurfaces, i)
01068 {
01069 label surfI = testSurfaces[i];
01070
01071 if (allGeometry_[surfaces_[surfI]].hasVolumeType())
01072 {
01073 List<searchableSurface::volumeType> volType;
01074 allGeometry_[surfaces_[surfI]].getVolumeType(pt, volType);
01075
01076 forAll(volType, pointI)
01077 {
01078 if (insideSurfaces[pointI] == -1)
01079 {
01080 if
01081 (
01082 (
01083 volType[pointI] == triSurfaceMesh::INSIDE
01084 && zoneInside_[surfI]
01085 )
01086 || (
01087 volType[pointI] == triSurfaceMesh::OUTSIDE
01088 && !zoneInside_[surfI]
01089 )
01090 )
01091 {
01092 insideSurfaces[pointI] = surfI;
01093 }
01094 }
01095 }
01096 }
01097 }
01098 }
01099
01100
01101