52 surfaceToCell::typeName,
53 "\n Usage: surfaceToCell" 54 "<surface> <outsidePoints> <cut> <inside> <outside> <near> <curvature>\n\n" 55 " <surface> name of triSurface\n" 56 " <outsidePoints> list of points that define outside\n" 57 " <cut> boolean whether to include cells cut by surface\n" 58 " <inside> ,, ,, inside surface\n" 59 " <outside> ,, ,, outside surface\n" 60 " <near> scalar; include cells with centre <= near to surface\n" 61 " <curvature> scalar; include cells close to strong curvature" 63 " (curvature defined as difference in surface normal at nearest" 64 " point on surface for each vertex of cell)\n\n" 70 Foam::label Foam::surfaceToCell::getNearest
72 const triSurfaceSearch& querySurf,
79 const auto iter = cache.cfind(pointi);
89 const label trii = inter.index();
92 cache.insert(pointi, trii);
98 bool Foam::surfaceToCell::differingPointNormals
100 const triSurfaceSearch& querySurf,
104 const label cellTriI,
106 Map<label>& pointToNearest
109 const triSurface& surf = querySurf.surface();
117 for (
const label facei : cFaces)
119 const face&
f = faces[facei];
121 for (
const label pointi :
f)
133 if (pointTriI != -1 && pointTriI != cellTriI)
135 scalar cosAngle = normals[pointTriI] & normals[cellTriI];
148 void Foam::surfaceToCell::combine(topoSet&
set,
const bool add)
const 152 if (useSurfaceOrientation_ && (includeInside_ || includeOutside_))
154 const meshSearch queryMesh(mesh_);
157 boolList isInside(querySurf().calcInside(mesh_.cellCentres()));
161 Info<<
" Marked inside/outside using surface orientation in = " 162 << timer.cpuTimeIncrement() <<
" s" <<
nl <<
endl;
167 if (isInside[celli] ? includeInside_ : includeOutside_)
169 addOrDelete(
set, celli,
add);
173 else if (includeCut_ || includeInside_ || includeOutside_)
182 const meshSearch queryMesh(mesh_);
186 for (
const point& outsidePoint : outsidePoints_)
189 label celli = queryMesh.findCell(outsidePoint, -1,
false);
194 <<
"outsidePoint " << outsidePoint
195 <<
" is not inside any cell" <<
nl 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() && inter.point().dist(
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() && inter.point().dist(
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),
404 const bool includeCut,
405 const bool includeInside,
406 const bool includeOutside,
407 const bool useSurfaceOrientation,
408 const scalar nearDist,
409 const scalar curvature
414 outsidePoints_(outsidePoints),
415 includeCut_(includeCut),
416 includeInside_(includeInside),
417 includeOutside_(includeOutside),
418 useSurfaceOrientation_(useSurfaceOrientation),
420 curvature_(curvature),
422 querySurfPtr_(querySurf)
437 includeCut_(
dict.
get<bool>(
"includeCut")),
438 includeInside_(
dict.
get<bool>(
"includeInside")),
439 includeOutside_(
dict.
get<bool>(
"includeOutside")),
440 useSurfaceOrientation_
442 dict.getOrDefault(
"useSurfaceOrientation",
false)
444 nearDist_(
dict.
get<scalar>(
"nearDistance")),
445 curvature_(
dict.
get<scalar>(
"curvature")),
452 dict.getOrDefault<scalar>(
"scale", -1)
468 surfName_(checkIs(is)),
469 outsidePoints_(checkIs(is)),
471 includeInside_(
readBool(checkIs(is))),
472 includeOutside_(
readBool(checkIs(is))),
473 useSurfaceOrientation_(
false),
474 nearDist_(readScalar(checkIs(is))),
475 curvature_(readScalar(checkIs(is))),
501 Info<<
" Adding cells in relation to surface " << surfName_
511 Info<<
" Removing cells in relation to surface " << surfName_
cellType
Equivalent to enumeration in "vtkCellType.h" (should be uint8_t)
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Create a new set and ADD elements to it.
Add elements to current set.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Apply specified action to the topoSet.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping and return the expanded string.
const cellList & cells() const
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells...
virtual ~surfaceToCell()
Destructor.
Macros for easy insertion into run-time selection tables.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
List< face > faceList
List of faces.
Helper class to search on triSurface.
AccessType combine(const UList< T > &lists, AccessOp aop=accessOp< T >())
Combines sub-lists into a single list.
vectorField pointField
pointField is a vectorField.
constexpr T & get(FixedList< T, N > &list) noexcept
A class for handling words, derived from Foam::string.
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
setAction
Enumeration defining various actions.
virtual const faceList & faces() const
Return raw faces.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
surfaceToCell(const polyMesh &mesh, const fileName &surfName, const pointField &outsidePoints, const bool includeCut, const bool includeInside, const bool includeOutside, const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature)
Construct from components.
Subtract elements from current set.
decomposeUsingBbs false
Use bounding boxes (default) or unique decomposition of triangles (i.e. do not duplicate triangles) ...
vector point
Point is a vector.
cpuTimePosix cpuTime
Selection of preferred clock mechanism for the elapsed cpu time.
Class with constructor to add usage string to table.
const dimensionedScalar c
Speed of light in a vacuum.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
Triangulated surface description with patch information.
List< bool > boolList
A List of bools.
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)