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"
71Foam::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);
99bool 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];
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;
333void 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_
444 dict.getOrDefault(
"useSurfaceOrientation", false)
446 nearDist_(
dict.get<scalar>(
"nearDistance")),
447 curvature_(
dict.get<scalar>(
"curvature")),
454 dict.getOrDefault<scalar>(
"scale", -1)
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_
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
const cellList & cells() const
A topoSetCellSource to select cells based on relation to a surface given by an external file.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Apply specified action to the topoSet.
virtual ~surfaceToCell()
Destructor.
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
Class with constructor to add usage string to table.
Base class of a source for a topoSet.
setAction
Enumeration defining various actions.
@ SUBTRACT
Subtract elements from current set.
@ ADD
Add elements to current set.
@ NEW
Create a new set and ADD elements to it.
General set of labels of mesh quantity (points, cells, faces).
Helper class to search on triSurface.
Triangulated surface description with patch information.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Template functions to aid in the implementation of demand driven data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const dimensionedScalar c
Speed of light in a vacuum.
cellType
Equivalent to enumeration in "vtkCellType.h" (should be uint8_t)
List< label > labelList
A List of labels.
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< bool > boolList
A List of bools.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
List< face > faceList
A List of faces.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void deleteDemandDrivenData(DataPtr &dataPtr)
cpuTimeCxx cpuTime
Selection of preferred clock mechanism for the elapsed cpu time.
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.