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]];
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_))
138 boolList isInside(querySurf().calcInside(mesh_.cellCentres()));
140 Info<<
" Marked inside/outside using surface orientation in = "
141 << timer.cpuTimeIncrement() <<
" s" <<
endl <<
endl;
145 if (isInside[celli] && includeInside_)
147 addOrDelete(set, celli,
add);
149 else if (!isInside[celli] && includeOutside_)
151 addOrDelete(set, celli,
add);
155 else if (includeCut_ || includeInside_ || includeOutside_)
162 forAll(outsidePoints_, outsideI)
164 const point& outsidePoint = outsidePoints_[outsideI];
172 <<
"outsidePoint " << outsidePoint
173 <<
" is not inside any cell"
180 cellClassification cellType(mesh_, querySurf(), outsidePoints_);
183 Info<<
" Marked inside/outside using surface intersection in = "
184 << timer.cpuTimeIncrement() <<
" s" <<
endl <<
endl;
189 label cType = cellType[celli];
207 addOrDelete(set, celli,
add);
222 const vector span(nearDist_, nearDist_, nearDist_);
227 Info<<
" Selecting cells with cellCentre closer than "
228 << nearDist_ <<
" to surface" <<
endl;
234 const point&
c = ctrs[celli];
238 if (inter.hit() && (
mag(inter.hitPoint() -
c) < nearDist_))
240 addOrDelete(set, celli,
add);
244 Info<<
" Determined nearest surface point in = "
245 << timer.cpuTimeIncrement() <<
" s" <<
endl <<
endl;
252 Info<<
" Selecting cells with cellCentre closer than "
253 << nearDist_ <<
" to surface and curvature factor"
254 <<
" less than " << curvature_ <<
endl;
257 Map<label> pointToNearest(mesh_.nCells()/10);
261 const point&
c = ctrs[celli];
265 if (inter.hit() && (
mag(inter.hitPoint() -
c) < nearDist_))
269 differingPointNormals
279 addOrDelete(set, celli,
add);
284 Info<<
" Determined nearest surface point in = "
285 << timer.cpuTimeIncrement() <<
" s" <<
endl <<
endl;
291 void Foam::surfaceToCell::checkSettings()
const
298 (includeCut_ && includeInside_ && includeOutside_)
299 || (!includeCut_ && !includeInside_ && !includeOutside_)
304 <<
"Illegal include cell specification."
305 <<
" Result would be either all or no cells." <<
endl
306 <<
"Please set one of includeCut, includeInside, includeOutside"
307 <<
" to true, set nearDistance to a value > 0"
308 <<
" or set curvature to a value -1 .. 1."
312 if (useSurfaceOrientation_ && includeCut_)
315 <<
"Illegal include cell specification."
316 <<
" You cannot specify both 'useSurfaceOrientation'"
317 <<
" and 'includeCut'"
318 <<
" since 'includeCut' specifies a topological split"
328 const polyMesh&
mesh,
329 const fileName& surfName,
331 const bool includeCut,
332 const bool includeInside,
333 const bool includeOutside,
334 const bool useSurfaceOrientation,
335 const scalar nearDist,
336 const scalar curvature
341 outsidePoints_(outsidePoints),
342 includeCut_(includeCut),
343 includeInside_(includeInside),
344 includeOutside_(includeOutside),
345 useSurfaceOrientation_(useSurfaceOrientation),
347 curvature_(curvature),
348 surfPtr_(new triSurface(surfName_)),
349 querySurfPtr_(new triSurfaceSearch(*surfPtr_)),
358 const polyMesh&
mesh,
359 const fileName& surfName,
360 const triSurface& surf,
361 const triSurfaceSearch& querySurf,
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),
381 querySurfPtr_(&querySurf),
390 const polyMesh&
mesh,
391 const dictionary&
dict
400 useSurfaceOrientation_
402 dict.lookupOrDefault<bool>(
"useSurfaceOrientation", false)
406 surfPtr_(new triSurface(surfName_)),
407 querySurfPtr_(new triSurfaceSearch(*surfPtr_)),
436 Info<<
" Adding cells in relation to surface " << surfName_
443 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.
friend class const_iterator
Declare friendship with the const_iterator.
static label findCellNoTree(const polyMesh &mesh, const point &p, const pointInCellShapes=pointInCellShapes::tets)
Find the cell containing the given point. Do a.
Motion of the mesh specified as a list of pointMeshMovers.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
const cellList & cells() 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 void applyToSet(const topoSetSource::setAction action, topoSet &) const
virtual ~surfaceToCell()
Destructor.
setAction
Enumeration defining the valid actions.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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.
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
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.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
void add(GeometricField< typename typeOfSum< Type1, Type2 >::type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type1, GeoMesh, PrimitiveField2 > &gf1, const GeometricField< Type2, GeoMesh, PrimitiveField3 > &gf2)
PointIndexHit< point > pointIndexHit
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet & dimLength
void deleteDemandDrivenData(DataType *&dataPtr)
vectorField pointField
pointField is a vectorField.
List< bool > boolList
Bool container classes.
vector point
Point is a vector.
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)
Field< vector > vectorField
Specialisation of Field<T> for vector.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
string expand(const string &s, string::size_type &index, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty)