53 surfaceToCell::typeName,
54 "\n Usage: surfaceToCell"
55 "<surface> <outsidePoints> <cut> <inside> <outside> <near> <curvature>\n\n"
56 " <surface> name of triSurface\n"
57 " <outsidePoints> list of points that define outside\n"
58 " <cut> boolean whether to include cells cut by surface\n"
59 " <inside> ,, ,, inside surface\n"
60 " <outside> ,, ,, outside surface\n"
61 " <near> scalar; include cells with centre <= near to surface\n"
62 " <curvature> scalar; include cells close to strong curvature"
64 " (curvature defined as difference in surface normal at nearest"
65 " point on surface for each vertex of cell)\n\n"
71 Foam::label Foam::surfaceToCell::getNearest
73 const triSurfaceSearch& querySurf,
80 const auto iter = cache.cfind(pointi);
90 const label trii = inter.index();
93 cache.insert(pointi, trii);
99 bool Foam::surfaceToCell::differingPointNormals
101 const triSurfaceSearch& querySurf,
105 const label cellTriI,
107 Map<label>& pointToNearest
110 const triSurface& surf = querySurf.surface();
118 for (
const label facei : cFaces)
120 const face&
f = faces[facei];
122 for (
const label pointi :
f)
134 if (pointTriI != -1 && pointTriI != cellTriI)
136 scalar cosAngle = normals[pointTriI] & normals[cellTriI];
149 void Foam::surfaceToCell::combine(topoSet& set,
const bool add)
const
153 if (useSurfaceOrientation_ && (includeInside_ || includeOutside_))
155 const meshSearch queryMesh(mesh_);
158 boolList isInside(querySurf().calcInside(mesh_.cellCentres()));
162 Info<<
" Marked inside/outside using surface orientation in = "
163 << timer.cpuTimeIncrement() <<
" s" <<
nl <<
endl;
168 if (isInside[celli] ? includeInside_ : includeOutside_)
170 addOrDelete(set, celli,
add);
174 else if (includeCut_ || includeInside_ || includeOutside_)
183 const meshSearch queryMesh(mesh_);
187 for (
const point& outsidePoint : outsidePoints_)
190 label celli = queryMesh.findCell(outsidePoint, -1,
false);
194 <<
"outsidePoint " << outsidePoint
195 <<
" is not inside any cell"
213 Info<<
" Marked inside/outside using surface intersection in = "
214 << timer.cpuTimeIncrement() <<
" s" <<
nl <<
endl;
238 addOrDelete(set, celli,
add);
253 const vector span(nearDist_, nearDist_, nearDist_);
260 Info<<
" Selecting cells with cellCentre closer than "
261 << nearDist_ <<
" to surface" <<
endl;
268 const point&
c = ctrs[celli];
272 if (inter.hit() && (
mag(inter.hitPoint() -
c) < nearDist_))
274 addOrDelete(set, celli,
add);
280 Info<<
" Determined nearest surface point in = "
281 << timer.cpuTimeIncrement() <<
" s" <<
nl <<
endl;
290 Info<<
" Selecting cells with cellCentre closer than "
291 << nearDist_ <<
" to surface and curvature factor"
292 <<
" less than " << curvature_ <<
endl;
296 Map<label> pointToNearest(mesh_.nCells()/10);
300 const point&
c = ctrs[celli];
304 if (inter.hit() && (
mag(inter.hitPoint() -
c) < nearDist_))
308 differingPointNormals
318 addOrDelete(set, celli,
add);
325 Info<<
" Determined nearest surface point in = "
326 << timer.cpuTimeIncrement() <<
" s" <<
nl <<
endl;
333 void Foam::surfaceToCell::checkSettings()
const
340 (includeCut_ && includeInside_ && includeOutside_)
341 || (!includeCut_ && !includeInside_ && !includeOutside_)
346 <<
"Illegal include cell specification."
347 <<
" Result would be either all or no cells." <<
endl
348 <<
"Please set one of includeCut, includeInside, includeOutside"
349 <<
" to true, set nearDistance to a value > 0"
350 <<
" or set curvature to a value -1 .. 1."
354 if (useSurfaceOrientation_ && includeCut_)
357 <<
"Illegal include cell specification."
358 <<
" You cannot specify both 'useSurfaceOrientation'"
359 <<
" and 'includeCut'"
360 <<
" since 'includeCut' specifies a topological split"
373 const bool includeCut,
374 const bool includeInside,
375 const bool includeOutside,
376 const bool useSurfaceOrientation,
377 const scalar nearDist,
378 const scalar curvature
383 outsidePoints_(outsidePoints),
384 includeCut_(includeCut),
385 includeInside_(includeInside),
386 includeOutside_(includeOutside),
387 useSurfaceOrientation_(useSurfaceOrientation),
389 curvature_(curvature),
405 const bool includeCut,
406 const bool includeInside,
407 const bool includeOutside,
408 const bool useSurfaceOrientation,
409 const scalar nearDist,
410 const scalar curvature
415 outsidePoints_(outsidePoints),
416 includeCut_(includeCut),
417 includeInside_(includeInside),
418 includeOutside_(includeOutside),
419 useSurfaceOrientation_(useSurfaceOrientation),
421 curvature_(curvature),
423 querySurfPtr_(&querySurf),
439 includeCut_(
dict.
get<
bool>(
"includeCut")),
440 includeInside_(
dict.
get<
bool>(
"includeInside")),
441 includeOutside_(
dict.
get<
bool>(
"includeOutside")),
442 useSurfaceOrientation_
446 nearDist_(
dict.
get<scalar>(
"nearDistance")),
447 curvature_(
dict.
get<scalar>(
"curvature")),
471 surfName_(checkIs(is)),
472 outsidePoints_(checkIs(is)),
474 includeInside_(
readBool(checkIs(is))),
475 includeOutside_(
readBool(checkIs(is))),
476 useSurfaceOrientation_(
false),
477 nearDist_(readScalar(checkIs(is))),
478 curvature_(readScalar(checkIs(is))),
511 Info<<
" Adding cells in relation to surface " << surfName_
521 Info<<
" Removing cells in relation to surface " << surfName_