49 const triSurfaceSearch& querySurf,
58 if (iter != cache.end())
68 label triI = inter.index();
71 cache.insert(pointi, triI);
78 bool Foam::surfaceToCell::differingPointNormals
80 const triSurfaceSearch& querySurf,
86 Map<label>& pointToNearest
89 const triSurface& surf = querySurf.surface();
99 const face& f = faces[cFaces[cFacei]];
103 label pointi = f[fp];
115 if (pointTriI != -1 && pointTriI != cellTriI)
117 scalar cosAngle = normals[pointTriI] & normals[cellTriI];
130 void Foam::surfaceToCell::combine(topoSet&
set,
const bool add)
const 135 if (useSurfaceOrientation_ && (includeInside_ || includeOutside_))
137 const meshSearch queryMesh(mesh_);
140 boolList isInside(querySurf().calcInside(mesh_.cellCentres()));
142 Info<<
" Marked inside/outside using surface orientation in = " 143 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
147 if (isInside[celli] && includeInside_)
149 addOrDelete(
set, celli, add);
151 else if (!isInside[celli] && includeOutside_)
153 addOrDelete(
set, celli, add);
157 else if (includeCut_ || includeInside_ || includeOutside_)
166 const meshSearch queryMesh(mesh_);
170 forAll(outsidePoints_, outsideI)
172 const point& outsidePoint = outsidePoints_[outsideI];
175 label celli = queryMesh.findCell(outsidePoint, -1,
false);
179 <<
"outsidePoint " << outsidePoint
180 <<
" is not inside any cell" 187 cellClassification cellType
196 Info<<
" Marked inside/outside using surface intersection in = " 197 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
202 label cType = cellType[celli];
220 addOrDelete(
set, celli, add);
235 const vector span(nearDist_, nearDist_, nearDist_);
240 Info<<
" Selecting cells with cellCentre closer than " 241 << nearDist_ <<
" to surface" <<
endl;
247 const point& c = ctrs[celli];
251 if (inter.hit() && (
mag(inter.hitPoint() -
c) < nearDist_))
253 addOrDelete(
set, celli, add);
257 Info<<
" Determined nearest surface point in = " 258 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
265 Info<<
" Selecting cells with cellCentre closer than " 266 << nearDist_ <<
" to surface and curvature factor" 267 <<
" less than " << curvature_ <<
endl;
270 Map<label> pointToNearest(mesh_.nCells()/10);
274 const point& c = ctrs[celli];
278 if (inter.hit() && (
mag(inter.hitPoint() -
c) < nearDist_))
282 differingPointNormals
292 addOrDelete(
set, celli, add);
297 Info<<
" Determined nearest surface point in = " 298 << timer.cpuTimeIncrement() <<
" s" << endl <<
endl;
304 void Foam::surfaceToCell::checkSettings()
const 311 (includeCut_ && includeInside_ && includeOutside_)
312 || (!includeCut_ && !includeInside_ && !includeOutside_)
317 <<
"Illegal include cell specification." 318 <<
" Result would be either all or no cells." << endl
319 <<
"Please set one of includeCut, includeInside, includeOutside" 320 <<
" to true, set nearDistance to a value > 0" 321 <<
" or set curvature to a value -1 .. 1." 325 if (useSurfaceOrientation_ && includeCut_)
328 <<
"Illegal include cell specification." 329 <<
" You cannot specify both 'useSurfaceOrientation'" 330 <<
" and 'includeCut'" 331 <<
" since 'includeCut' specifies a topological split" 344 const bool includeCut,
345 const bool includeInside,
346 const bool includeOutside,
347 const bool useSurfaceOrientation,
348 const scalar nearDist,
349 const scalar curvature
354 outsidePoints_(outsidePoints),
355 includeCut_(includeCut),
356 includeInside_(includeInside),
357 includeOutside_(includeOutside),
358 useSurfaceOrientation_(useSurfaceOrientation),
360 curvature_(curvature),
376 const bool includeCut,
377 const bool includeInside,
378 const bool includeOutside,
379 const bool useSurfaceOrientation,
380 const scalar nearDist,
381 const scalar curvature
386 outsidePoints_(outsidePoints),
387 includeCut_(includeCut),
388 includeInside_(includeInside),
389 includeOutside_(includeOutside),
390 useSurfaceOrientation_(useSurfaceOrientation),
392 curvature_(curvature),
394 querySurfPtr_(&querySurf),
409 outsidePoints_(dict.
lookup(
"outsidePoints")),
413 useSurfaceOrientation_
417 nearDist_(dict.
lookup<scalar>(
"nearDistance")),
418 curvature_(dict.
lookup<scalar>(
"curvature")),
449 Info<<
" Adding cells in relation to surface " << surfName_
456 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 occurrences of variables according to the mapping.
FvWallInfoData< WallInfo, label > 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.
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.
const dimensionedScalar c
Speed of light in a vacuum.
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.
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,.
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)
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.