51 surfaceToCell::typeName,
52 "\n Usage: surfaceToCell"
53 "<surface> <outsidePoints> <cut> <inside> <outside> <near> <curvature>\n\n"
54 " <surface> name of triSurface\n"
55 " <outsidePoints> list of points that define outside\n"
56 " <cut> boolean whether to include cells cut by surface\n"
57 " <inside> ,, ,, inside surface\n"
58 " <outside> ,, ,, outside surface\n"
59 " <near> scalar; include cells with centre <= near to surface\n"
60 " <curvature> scalar; include cells close to strong curvature"
62 " (curvature defined as difference in surface normal at nearest"
63 " point on surface for each vertex of cell)\n\n"
69 Foam::label Foam::surfaceToCell::getNearest
71 const triSurfaceSearch& querySurf,
80 if (iter != cache.end())
90 label triI = inter.index();
93 cache.insert(pointI, triI);
103 bool Foam::surfaceToCell::differingPointNormals
105 const triSurfaceSearch& querySurf,
109 const label cellTriI,
111 Map<label>& pointToNearest
114 const triSurface& surf = querySurf.surface();
124 const face&
f = faces[cFaces[cFaceI]];
128 label pointI = f[fp];
140 if (pointTriI != -1 && pointTriI != cellTriI)
142 scalar cosAngle = normals[pointTriI] & normals[cellTriI];
159 if (includeCut_ || includeInside_ || includeOutside_)
168 meshSearch queryMesh(mesh_,
true);
172 forAll(outsidePoints_, outsideI)
174 const point& outsidePoint = outsidePoints_[outsideI];
177 label cellI = queryMesh.findCell(outsidePoint, -1,
false);
180 FatalErrorIn(
"surfaceToCell::combine(topoSet&, const bool)")
181 <<
"outsidePoint " << outsidePoint
182 <<
" is not inside any cell"
189 cellClassification cellType
198 Info<<
" Marked inside/outside in = "
199 << timer.cpuTimeIncrement() <<
" s" <<
endl <<
endl;
204 label cType = cellType[cellI];
222 addOrDelete(
set, cellI, add);
237 const vector span(nearDist_, nearDist_, nearDist_);
242 Info<<
" Selecting cells with cellCentre closer than "
243 << nearDist_ <<
" to surface" <<
endl;
249 const point& c = ctrs[cellI];
253 if (inter.hit() && (
mag(inter.hitPoint() - c) < nearDist_))
255 addOrDelete(
set, cellI, add);
259 Info<<
" Determined nearest surface point in = "
260 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
267 Info<<
" Selecting cells with cellCentre closer than "
268 << nearDist_ <<
" to surface and curvature factor"
269 <<
" less than " << curvature_ <<
endl;
272 Map<label> pointToNearest(mesh_.nCells()/10);
276 const point& c = ctrs[cellI];
280 if (inter.hit() && (
mag(inter.hitPoint() - c) < nearDist_))
284 differingPointNormals
294 addOrDelete(
set, cellI, add);
299 Info<<
" Determined nearest surface point in = "
300 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
306 void Foam::surfaceToCell::checkSettings()
const
313 (includeCut_ && includeInside_ && includeOutside_)
314 || (!includeCut_ && !includeInside_ && !includeOutside_)
320 "surfaceToCell:checkSettings()"
321 ) <<
"Illegal include cell specification."
322 <<
" Result would be either all or no cells." << endl
323 <<
"Please set one of includeCut, includeInside, includeOutside"
324 <<
" to true, set nearDistance to a value > 0"
325 <<
" or set curvature to a value -1 .. 1."
339 const bool includeCut,
340 const bool includeInside,
341 const bool includeOutside,
342 const scalar nearDist,
343 const scalar curvature
348 outsidePoints_(outsidePoints),
349 includeCut_(includeCut),
350 includeInside_(includeInside),
351 includeOutside_(includeOutside),
353 curvature_(curvature),
370 const bool includeCut,
371 const bool includeInside,
372 const bool includeOutside,
373 const scalar nearDist,
374 const scalar curvature
379 outsidePoints_(outsidePoints),
380 includeCut_(includeCut),
381 includeInside_(includeInside),
382 includeOutside_(includeOutside),
384 curvature_(curvature),
386 querySurfPtr_(&querySurf),
401 surfName_(dict.
lookup(
"file")),
402 outsidePoints_(dict.
lookup(
"outsidePoints")),
424 surfName_(checkIs(is)),
425 outsidePoints_(checkIs(is)),
427 includeInside_(
readBool(checkIs(is))),
428 includeOutside_(
readBool(checkIs(is))),
451 delete querySurfPtr_;
467 Info<<
" Adding cells in relation to surface " << surfName_
474 Info<<
" Removing cells in relation to surface " << surfName_