48 surfaceToCell::typeName,
49 "\n Usage: surfaceToCell" 50 "<surface> <outsidePoints> <cut> <inside> <outside> <near> <curvature>\n\n" 51 " <surface> name of triSurface\n" 52 " <outsidePoints> list of points that define outside\n" 53 " <cut> boolean whether to include cells cut by surface\n" 54 " <inside> ,, ,, inside surface\n" 55 " <outside> ,, ,, outside surface\n" 56 " <near> scalar; include cells with centre <= near to surface\n" 57 " <curvature> scalar; include cells close to strong curvature" 59 " (curvature defined as difference in surface normal at nearest" 60 " point on surface for each vertex of cell)\n\n" 68 const triSurfaceSearch& querySurf,
77 if (iter != cache.end())
87 label triI = inter.index();
90 cache.insert(pointi, triI);
97 bool Foam::surfaceToCell::differingPointNormals
99 const triSurfaceSearch& querySurf,
103 const label cellTriI,
105 Map<label>& pointToNearest
108 const triSurface& surf = querySurf.surface();
118 const face& f = faces[cFaces[cFacei]];
122 label pointi = f[fp];
134 if (pointTriI != -1 && pointTriI != cellTriI)
136 scalar cosAngle = normals[pointTriI] & normals[cellTriI];
149 void Foam::surfaceToCell::combine(topoSet&
set,
const bool add)
const 154 if (useSurfaceOrientation_ && (includeInside_ || includeOutside_))
156 const meshSearch queryMesh(mesh_);
159 boolList isInside(querySurf().calcInside(mesh_.cellCentres()));
161 Info<<
" Marked inside/outside using surface orientation in = " 162 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
166 if (isInside[celli] && includeInside_)
168 addOrDelete(
set, celli, add);
170 else if (!isInside[celli] && includeOutside_)
172 addOrDelete(
set, celli, add);
176 else if (includeCut_ || includeInside_ || includeOutside_)
185 const meshSearch queryMesh(mesh_);
189 forAll(outsidePoints_, outsideI)
191 const point& outsidePoint = outsidePoints_[outsideI];
194 label celli = queryMesh.findCell(outsidePoint, -1,
false);
198 <<
"outsidePoint " << outsidePoint
199 <<
" is not inside any cell" 206 cellClassification cellType
215 Info<<
" Marked inside/outside using surface intersection in = " 216 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
221 label cType = cellType[celli];
239 addOrDelete(
set, celli, add);
254 const vector span(nearDist_, nearDist_, nearDist_);
259 Info<<
" Selecting cells with cellCentre closer than " 260 << nearDist_ <<
" to surface" <<
endl;
266 const point& c = ctrs[celli];
270 if (inter.hit() && (
mag(inter.hitPoint() -
c) < nearDist_))
272 addOrDelete(
set, celli, add);
276 Info<<
" Determined nearest surface point in = " 277 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
284 Info<<
" Selecting cells with cellCentre closer than " 285 << nearDist_ <<
" to surface and curvature factor" 286 <<
" less than " << curvature_ <<
endl;
289 Map<label> pointToNearest(mesh_.nCells()/10);
293 const point& c = ctrs[celli];
297 if (inter.hit() && (
mag(inter.hitPoint() -
c) < nearDist_))
301 differingPointNormals
311 addOrDelete(
set, celli, add);
316 Info<<
" Determined nearest surface point in = " 317 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
323 void Foam::surfaceToCell::checkSettings()
const 330 (includeCut_ && includeInside_ && includeOutside_)
331 || (!includeCut_ && !includeInside_ && !includeOutside_)
336 <<
"Illegal include cell specification." 337 <<
" Result would be either all or no cells." << endl
338 <<
"Please set one of includeCut, includeInside, includeOutside" 339 <<
" to true, set nearDistance to a value > 0" 340 <<
" or set curvature to a value -1 .. 1." 344 if (useSurfaceOrientation_ && includeCut_)
347 <<
"Illegal include cell specification." 348 <<
" You cannot specify both 'useSurfaceOrientation'" 349 <<
" and 'includeCut'" 350 <<
" since 'includeCut' specifies a topological split" 363 const bool includeCut,
364 const bool includeInside,
365 const bool includeOutside,
366 const bool useSurfaceOrientation,
367 const scalar nearDist,
368 const scalar curvature
373 outsidePoints_(outsidePoints),
374 includeCut_(includeCut),
375 includeInside_(includeInside),
376 includeOutside_(includeOutside),
377 useSurfaceOrientation_(useSurfaceOrientation),
379 curvature_(curvature),
395 const bool includeCut,
396 const bool includeInside,
397 const bool includeOutside,
398 const bool useSurfaceOrientation,
399 const scalar nearDist,
400 const scalar curvature
405 outsidePoints_(outsidePoints),
406 includeCut_(includeCut),
407 includeInside_(includeInside),
408 includeOutside_(includeOutside),
409 useSurfaceOrientation_(useSurfaceOrientation),
411 curvature_(curvature),
413 querySurfPtr_(&querySurf),
428 outsidePoints_(dict.
lookup(
"outsidePoints")),
432 useSurfaceOrientation_
453 surfName_(checkIs(is)),
454 outsidePoints_(checkIs(is)),
456 includeInside_(
readBool(checkIs(is))),
457 includeOutside_(
readBool(checkIs(is))),
458 useSurfaceOrientation_(
false),
491 Info<<
" Adding cells in relation to surface " << surfName_
498 Info<<
" Removing cells in relation to surface " << surfName_
#define forAll(list, i)
Loop across all elements in list.
string expand(const string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Expand occurences of variables according to the mapping.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
HashTable< label, label, Hash< label > >::const_iterator const_iterator
const cellList & cells() const
PointIndexHit< point > pointIndexHit
Vector< scalar > vector
A scalar version of the templated Vector.
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
virtual ~surfaceToCell()
Destructor.
Macros for easy insertion into run-time selection tables.
Base class of a source for a topoSet.
virtual const pointField & points() const
Return raw points.
List< bool > boolList
Bool container classes.
Helper class to search on triSurface.
vectorField pointField
pointField is a vectorField.
setAction
Enumeration defining the valid actions.
List< label > labelList
A List of labels.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
virtual const faceList & faces() const
Return raw faces.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
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.
Template functions to aid in the implementation of demand driven data.
vector point
Point is a vector.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Class with constructor to add usage string to table.
const dimensionedScalar c
Speed of light in a vacuum.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Mesh consisting of general polyhedral cells.
Triangulated surface description with patch information.
void deleteDemandDrivenData(DataPtr &dataPtr)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.