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);
195 <<
"outsidePoint " << outsidePoint
196 <<
" is not inside any cell" <<
nl 214 Info<<
" Marked inside/outside using surface intersection in = " 215 << timer.cpuTimeIncrement() <<
" s" <<
nl <<
endl;
239 addOrDelete(
set, celli,
add);
254 const vector span(nearDist_, nearDist_, nearDist_);
261 Info<<
" Selecting cells with cellCentre closer than " 262 << nearDist_ <<
" to surface" <<
endl;
269 const point&
c = ctrs[celli];
273 if (inter.hit() && inter.point().dist(
c) < nearDist_)
275 addOrDelete(
set, celli,
add);
281 Info<<
" Determined nearest surface point in = " 282 << timer.cpuTimeIncrement() <<
" s" <<
nl <<
endl;
291 Info<<
" Selecting cells with cellCentre closer than " 292 << nearDist_ <<
" to surface and curvature factor" 293 <<
" less than " << curvature_ <<
endl;
297 Map<label> pointToNearest(mesh_.nCells()/10);
301 const point&
c = ctrs[celli];
305 if (inter.hit() && inter.point().dist(
c) < nearDist_)
309 differingPointNormals
319 addOrDelete(
set, celli,
add);
326 Info<<
" Determined nearest surface point in = " 327 << timer.cpuTimeIncrement() <<
" s" <<
nl <<
endl;
334 void Foam::surfaceToCell::checkSettings()
const 341 (includeCut_ && includeInside_ && includeOutside_)
342 || (!includeCut_ && !includeInside_ && !includeOutside_)
347 <<
"Illegal include cell specification." 348 <<
" Result would be either all or no cells." <<
endl 349 <<
"Please set one of includeCut, includeInside, includeOutside" 350 <<
" to true, set nearDistance to a value > 0" 351 <<
" or set curvature to a value -1 .. 1." 355 if (useSurfaceOrientation_ && includeCut_)
358 <<
"Illegal include cell specification." 359 <<
" You cannot specify both 'useSurfaceOrientation'" 360 <<
" and 'includeCut'" 361 <<
" since 'includeCut' specifies a topological split" 374 const bool includeCut,
375 const bool includeInside,
376 const bool includeOutside,
377 const bool useSurfaceOrientation,
378 const scalar nearDist,
379 const scalar curvature
384 outsidePoints_(outsidePoints),
385 includeCut_(includeCut),
386 includeInside_(includeInside),
387 includeOutside_(includeOutside),
388 useSurfaceOrientation_(useSurfaceOrientation),
390 curvature_(curvature),
406 const bool includeCut,
407 const bool includeInside,
408 const bool includeOutside,
409 const bool useSurfaceOrientation,
410 const scalar nearDist,
411 const scalar curvature
416 outsidePoints_(outsidePoints),
417 includeCut_(includeCut),
418 includeInside_(includeInside),
419 includeOutside_(includeOutside),
420 useSurfaceOrientation_(useSurfaceOrientation),
422 curvature_(curvature),
424 querySurfPtr_(&querySurf),
440 includeCut_(
dict.
get<bool>(
"includeCut")),
441 includeInside_(
dict.
get<bool>(
"includeInside")),
442 includeOutside_(
dict.
get<bool>(
"includeOutside")),
443 useSurfaceOrientation_
445 dict.getOrDefault(
"useSurfaceOrientation", false)
447 nearDist_(
dict.
get<scalar>(
"nearDistance")),
448 curvature_(
dict.
get<scalar>(
"curvature")),
455 dict.getOrDefault<scalar>(
"scale", -1)
472 surfName_(checkIs(is)),
473 outsidePoints_(checkIs(is)),
475 includeInside_(
readBool(checkIs(is))),
476 includeOutside_(
readBool(checkIs(is))),
477 useSurfaceOrientation_(false),
478 nearDist_(readScalar(checkIs(is))),
479 curvature_(readScalar(checkIs(is))),
512 Info<<
" Adding cells in relation to surface " << surfName_
522 Info<<
" Removing cells in relation to surface " << surfName_
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
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.
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.
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
vectorField pointField
pointField is a vectorField.
A class for handling words, derived from Foam::string.
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.
Template functions to aid in the implementation of demand driven data.
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.
void deleteDemandDrivenData(DataPtr &dataPtr)
List< bool > boolList
A List of bools.
bool readBool(Istream &is)
Read bool from stream using Foam::Switch(Istream&)
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
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.