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);
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),
265 mesh.time().constant(),
274 distance_(
dict.getOrDefault<scalar>(
"distance", 0)),
275 withZeroDistance_(
equal(distance_, 0)),
280 ||
dict.getOrDefault<
bool>(
"signed",
true)
286 isoSurfaceParams::ALGO_TOPO,
287 isoSurfaceParams::filterType::DIAGCELL
291 topoFilterNames_.getOrDefault
295 topologyFilterType::NONE
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_);
322 const word& surfaceType,
323 const word& surfaceName,
345 const word& surfaceType,
346 const word& surfaceName,
348 const bool useSignedDistance,
362 mesh.time().constant(),
383 const bool useSignedDistance,
388 geometryPtr_(surface),
390 withZeroDistance_(
equal(distance_, 0)),
399 topoFilter_(topologyFilterType::NONE),
403 cellDistancePtr_(
nullptr),
407 isoSurfacePtr_(
nullptr)
417 Pout<<
"distanceSurface::createGeometry updating geometry." <<
endl;
421 isoSurfacePtr_.reset(
nullptr);
428 const fvMesh& fvmesh =
static_cast<const fvMesh&
>(mesh_);
433 cellDistancePtr_.reset
439 "distanceSurface.cellDistance",
450 auto& cellDistance = *cellDistancePtr_;
458 bitSet ignoreCells, ignoreCellPoints;
460 const bool filterCells =
491 ignoreCellPoints = simpleGeometricFilter<false>
502 topologyFilterType::PROXIMITY_REGIONS == topoFilter_
509 if (withSignDistance_)
526 else if (withZeroDistance_)
537 calcAbsoluteDistance(
fld, cc, nearest);
558 if (withSignDistance_)
563 if (withZeroDistance_)
579 calcAbsoluteDistance(
fld, cc, nearest);
590 pointDistance_.resize(fvmesh.
nPoints());
591 pointDistance_ = GREAT;
606 if (withSignDistance_)
623 else if (withZeroDistance_)
634 calcAbsoluteDistance(
fld, pts, nearest);
640 if (ignoreCells.
none())
644 else if (filterCells && topologyFilterType::NONE != topoFilter_)
655 if (topologyFilterType::LARGEST_REGION == topoFilter_)
660 else if (topologyFilterType::NEAREST_POINTS == topoFilter_)
675 Pout<<
"Writing cell distance:" << cellDistance.objectPath() <<
endl;
676 cellDistance.
write();
682 "distanceSurface.pointDistance",
694 Pout<<
"Writing point distance:" << pDist.objectPath() <<
endl;
712 if (filterCells && topologyFilterType::PROXIMITY_REGIONS == topoFilter_)
733 || topologyFilterType::PROXIMITY_FACES == topoFilter_
734 || topologyFilterType::PROXIMITY_REGIONS == topoFilter_
738 meshCells_.
transfer(isoSurfacePtr_->meshCells());
740 isoSurfacePtr_.reset(
nullptr);
741 cellDistancePtr_.reset(
nullptr);
742 pointDistance_.clear();
745 if (topologyFilterType::PROXIMITY_FACES == topoFilter_)
749 else if (topologyFilterType::PROXIMITY_REGIONS == topoFilter_)
764 os <<
" surface:" << surfaceName()
766 <<
" topology:" << topoFilterNames_[topoFilter_];
768 isoParams_.print(
os);
772 os <<
" faces:" << surface().surfFaces().size()
773 <<
" points:" << surface().points().size();
int debug
Static debugging option.
virtual const pointField & points() const
Return raw points.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
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())
Create for specified algorithm type.
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
From a set of points and indices get the normal.
const labelListList & cellPoints() const
static constexpr const zero Zero
Global zero (0)
void filterRegionProximity(bitSet &ignoreCells) const
Remove region(s) that have far faces.
void inflate(const scalar s)
Inflate box by factor*mag(span) in all dimensions.
algorithmType algorithm() const noexcept
Get current algorithm.
void print(Ostream &os, int level=0) const
Print information.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
static word timeName(const scalar t, const int precision=precision_)
distanceSurface(const word &defaultSurfaceName, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
void set(const bitSet &bitset)
Set specified bits from another bitset.
static void calcNormalDistance_filtered(scalarField &distance, const bitSet &ignoreLocation, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void calcNormalDistance_zero(scalarField &distance, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
virtual void clear()
Clear all storage.
void filterKeepNearestRegions(bitSet &ignoreCells) const
Keep region(s) closest to the nearest points.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensionedScalar sign(const dimensionedScalar &ds)
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
Mesh consisting of general polyhedral cells.
label nPoints() const noexcept
Number of mesh points.
#define forAll(list, i)
Loop across all elements in list.
bool refineBlockedCells(bitSet &ignoreCells, const isoSurfaceBase &isoContext) const
Re-filter the blocked cells based on the anticipated cuts.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
label nCells() const noexcept
Number of mesh cells.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
bool hit() const noexcept
Is there a hit?
static scalar normalDistance_zero(const point &pt, const pointIndexHit &pHit, const vector &norm)
void transfer(pointField &pointLst, List< Face > &faceLst)
Transfer the components.
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()
Adjust extracted iso-surface to remove far faces.
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
Return cell centres as volVectorField.
void flip()
Invert all bits in the addressable region.
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.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
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)
scalar distance(const vector &p1, const vector &p2)
void clear()
Clear bounding box and make it an inverted box.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
bool contains(const point &pt) const
Contains point? (inside or on edge)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
bool none() const
True if no bits in this bitset are set.
static void checkAllHits(const UList< pointIndexHit > &nearest)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
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)
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
Elementary charge.
void clear()
Clear the list, i.e. set size to zero.
const point_type & point() const noexcept
Return point, no checks.
void clearStorage()
Clear the list and delete storage.
void filterKeepLargestRegion(bitSet &ignoreCells) const
Keep region with the most cuts (after region split)
A bounding box defined in terms of min/max extrema points.
const Time & time() const
Return the top-level database.
void createGeometry()
Create/recreate the distance surface.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
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)
Interpolate field onto faces using scheme given by Istream.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void add(const boundBox &bb)
Extend to include the second box.
static bitSet simpleGeometricFilter(bitSet &ignoreCells, const List< pointIndexHit > &nearest, const polyMesh &mesh, const scalar boundBoxInflate=0.1)