Go to the documentation of this file.
48 Foam::distanceSurface::topologyFilterType
50 Foam::distanceSurface::topoFilterNames_
52 { topologyFilterType::NONE,
"none" },
53 { topologyFilterType::LARGEST_REGION,
"largestRegion" },
54 { topologyFilterType::NEAREST_POINTS,
"nearestPoints" },
55 { topologyFilterType::PROXIMITY_REGIONS,
"proximityRegions" },
56 { topologyFilterType::PROXIMITY_FACES,
"proximityFaces" },
57 { topologyFilterType::PROXIMITY_FACES,
"proximity" },
81 <<
"Had " << notHit <<
" faces/cells from "
82 << nearest.size() <<
" without a point hit." <<
nl
83 <<
"May be caused by a severely degenerate input surface" <<
nl
113 const scalar normDist = (
diff & norm);
124 const List<pointIndexHit>& nearest,
142 const List<pointIndexHit>& nearest,
164 const bitSet& ignoreLocation,
172 if (ignoreLocation.
test(i))
195 template<
bool WantPo
intFilter = false>
201 const scalar boundBoxInflate = 0.1
218 const point& pt = nearest[celli].point();
224 cellBb.
inflate(boundBoxInflate);
228 ignoreCells.
set(celli);
230 else if (WantPointFilter)
233 pointFilter.
set(cPoints);
251 const word& defaultSurfaceName,
264 dict.getOrDefault(
"surfaceName", defaultSurfaceName),
274 distance_(
dict.getOrDefault<scalar>(
"distance", 0)),
275 withZeroDistance_(
equal(distance_, 0)),
280 ||
dict.getOrDefault<
bool>(
"signed", true)
291 topoFilterNames_.getOrDefault
295 topologyFilterType::NONE
299 maxDistanceSqr_(
Foam::
sqr(GREAT)),
300 absProximity_(
dict.getOrDefault<scalar>(
"absProximity", 1
e-5)),
301 cellDistancePtr_(nullptr),
305 isoSurfacePtr_(nullptr)
307 if (topologyFilterType::NEAREST_POINTS == topoFilter_)
309 dict.readEntry(
"nearestPoints", nearestPoints_);
312 if (
dict.readIfPresent(
"maxDistance", maxDistanceSqr_))
314 maxDistanceSqr_ =
Foam::sqr(maxDistanceSqr_);
321 const polyMesh&
mesh,
322 const word& surfaceType,
323 const word& surfaceName,
324 const isoSurfaceParams& params,
345 const word& surfaceType,
346 const word& surfaceName,
348 const bool useSignedDistance,
383 const bool useSignedDistance,
388 geometryPtr_(surface),
390 withZeroDistance_(
equal(distance_, 0)),
399 topoFilter_(topologyFilterType::NONE),
401 maxDistanceSqr_(
Foam::
sqr(GREAT)),
403 cellDistancePtr_(nullptr),
407 isoSurfacePtr_(nullptr)
417 Pout<<
"distanceSurface::createGeometry updating geometry." <<
endl;
421 isoSurfacePtr_.reset(
nullptr);
426 const searchableSurface& geom = geometryPtr_();
428 const fvMesh& fvmesh =
static_cast<const fvMesh&
>(mesh_);
433 cellDistancePtr_.reset
439 "distanceSurface.cellDistance",
440 fvmesh.time().timeName(),
450 auto& cellDistance = *cellDistancePtr_;
458 bitSet ignoreCells, ignoreCellPoints;
460 const bool filterCells =
472 List<pointIndexHit> nearest;
491 ignoreCellPoints = simpleGeometricFilter<false>
502 topologyFilterType::PROXIMITY_REGIONS == topoFilter_
509 if (withSignDistance_)
512 geom.getNormal(nearest, norms);
526 else if (withZeroDistance_)
537 calcAbsoluteDistance(
fld, cc, nearest);
544 forAll(fvmesh.C().boundaryField(), patchi)
546 const pointField& cc = fvmesh.C().boundaryField()[patchi];
549 List<pointIndexHit> nearest;
558 if (withSignDistance_)
561 geom.getNormal(nearest, norms);
563 if (withZeroDistance_)
579 calcAbsoluteDistance(
fld, cc, nearest);
590 pointDistance_.resize(fvmesh.nPoints());
591 pointDistance_ = GREAT;
596 List<pointIndexHit> nearest;
606 if (withSignDistance_)
609 geom.getNormal(nearest, norms);
623 else if (withZeroDistance_)
634 calcAbsoluteDistance(
fld, pts, nearest);
640 if (ignoreCells.none())
642 ignoreCells.clearStorage();
644 else if (filterCells && topologyFilterType::NONE != topoFilter_)
647 isoSurfaceBase isoCutter
655 if (topologyFilterType::LARGEST_REGION == topoFilter_)
657 refineBlockedCells(ignoreCells, isoCutter);
658 filterKeepLargestRegion(ignoreCells);
660 else if (topologyFilterType::NEAREST_POINTS == topoFilter_)
662 refineBlockedCells(ignoreCells, isoCutter);
663 filterKeepNearestRegions(ignoreCells);
670 ignoreCellPoints.clearStorage();
675 Pout<<
"Writing cell distance:" << cellDistance.objectPath() <<
endl;
676 cellDistance.
write();
682 "distanceSurface.pointDistance",
683 fvmesh.time().timeName(),
692 pDist.primitiveFieldRef() = pointDistance_;
694 Pout<<
"Writing point distance:" << pDist.objectPath() <<
endl;
712 if (filterCells && topologyFilterType::PROXIMITY_REGIONS == topoFilter_)
714 isoSurfaceBase isoCutter
722 refineBlockedCells(ignoreCells, isoCutter);
733 || topologyFilterType::PROXIMITY_FACES == topoFilter_
734 || topologyFilterType::PROXIMITY_REGIONS == topoFilter_
737 surface_.transfer(
static_cast<meshedSurface&
>(*isoSurfacePtr_));
738 meshCells_.transfer(isoSurfacePtr_->meshCells());
740 isoSurfacePtr_.reset(
nullptr);
741 cellDistancePtr_.reset(
nullptr);
742 pointDistance_.clear();
745 if (topologyFilterType::PROXIMITY_FACES == topoFilter_)
747 filterFaceProximity();
749 else if (topologyFilterType::PROXIMITY_REGIONS == topoFilter_)
751 filterRegionProximity(ignoreCells);
764 os <<
" surface:" << surfaceName()
766 <<
" topology:" << topoFilterNames_[topoFilter_];
768 isoParams_.print(
os);
772 os <<
" faces:" << surface().surfFaces().size()
773 <<
" points:" << surface().points().size();
vectorField pointField
pointField is a vectorField.
virtual const pointField & points() const
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void resize(const label numElem, const unsigned int val=0u)
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
static autoPtr< isoSurfaceBase > New(const isoSurfaceParams ¶ms, const volScalarField &cellValues, const scalarField &pointValues, const scalar iso, const bitSet &ignoreCells=bitSet())
A class for handling words, derived from Foam::string.
Low-level components common to various iso-surface algorithms.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
const labelListList & cellPoints() const
static constexpr const zero Zero
void filterRegionProximity(bitSet &ignoreCells) const
void inflate(const scalar s)
algorithmType algorithm() const noexcept
void print(Ostream &os, int level=0) const
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
static word timeName(const scalar t, const int precision=precision_)
distanceSurface(const word &defaultSurfaceName, const polyMesh &mesh, const dictionary &dict)
void set(const bitSet &bitset)
static void calcNormalDistance_filtered(scalarField &distance, const bitSet &ignoreLocation, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
Ostream & endl(Ostream &os)
static void calcNormalDistance_zero(scalarField &distance, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
void filterKeepNearestRegions(bitSet &ignoreCells) const
dimensionedScalar sign(const dimensionedScalar &ds)
bool test(const label pos) const
Mesh consisting of general polyhedral cells.
label nPoints() const noexcept
Field< vector > vectorField
Specialisation of Field<T> for vector.
bool refineBlockedCells(bitSet &ignoreCells, const isoSurfaceBase &isoContext) const
scalar diff(const triad &A, const triad &B)
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
label nCells() const noexcept
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
bool hit() const noexcept
static scalar normalDistance_zero(const point &pt, const pointIndexHit &pHit, const vector &norm)
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
void transfer(pointField &pointLst, List< Face > &faceLst)
Generic templated field type.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
void transfer(List< T > &list)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
void filterFaceProximity()
GeometricField< scalar, fvPatchField, volMesh > volScalarField
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const volVectorField & C() const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Preferences for controlling iso-surface algorithms.
OBJstream os(runTime.globalPath()/outputName)
Macros for easy insertion into run-time selection tables.
Generic dimensioned Type class.
virtual bool write(const token &tok)=0
Mesh data needed to do the Finite Volume discretisation.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
errorManip< error > abort(error &err)
Vector< scalar > vector
A scalar version of the templated Vector.
scalar distance(const vector &p1, const vector &p2)
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
bool contains(const point &pt) const
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
static void checkAllHits(const UList< pointIndexHit > &nearest)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
#define FatalErrorInFunction
dimensionedSymmTensor sqr(const dimensionedVector &dv)
PointIndexHit< point > pointIndexHit
A PointIndexHit for 3D points.
MeshedSurface< face > meshedSurface
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const dimensionedScalar e
const point_type & point() const noexcept
void filterKeepLargestRegion(bitSet &ignoreCells) const
A bounding box defined in terms of min/max extrema points.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
const Time & time() const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
vector point
Point is a vector.
Generic GeometricField class.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
constant condensation/saturation model.
bool equal(const T &s1, const T &s2)
defineTypeNameAndDebug(combustionModel, 0)
static scalar normalDistance_nonzero(const point &pt, const pointIndexHit &pHit, const vector &norm)
static void calcNormalDistance_nonzero(scalarField &distance, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
const Boundary & boundaryField() const
void add(const boundBox &bb)
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
static bitSet simpleGeometricFilter(bitSet &ignoreCells, const List< pointIndexHit > &nearest, const polyMesh &mesh, const scalar boundBoxInflate=0.1)