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();
92 const faceList& faces = mesh().faces();
95 const labelList& cFaces = mesh().cells()[celli];
99 const face&
f = faces[cFaces[cFacei]];
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")),
412 includeOutside_(
readBool(
dict.lookup(
"includeOutside"))),
413 useSurfaceOrientation_
415 dict.lookupOrDefault<bool>(
"useSurfaceOrientation", false)
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.
Macros for easy insertion into run-time selection tables.
HashTable< label, label, Hash< label > >::const_iterator const_iterator
A list of keyword definitions, which are a keyword followed by any number of values (e....
A class for handling file names.
Mesh consisting of general polyhedral cells.
A topoSetSource to select cells based on relation to surface.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
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.
virtual ~surfaceToCell()
Destructor.
Base class of a source for a topoSet.
setAction
Enumeration defining the valid actions.
General set of labels of mesh quantity (points, cells, faces).
Helper class to search on triSurface.
Triangulated surface description with patch information.
A class for handling words, derived from string.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
PointIndexHit< point > pointIndexHit
Ostream & endl(Ostream &os)
Add newline and flush stream.
vectorField pointField
pointField is a vectorField.
List< bool > boolList
Bool container classes.
vector point
Point is a vector.
void deleteDemandDrivenData(DataPtr &dataPtr)
Vector< scalar > vector
A scalar version of the templated Vector.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
Field< vector > vectorField
Specialisation of Field<T> for vector.
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
string expand(const string &s, string::size_type &index, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)