48 Foam::distanceSurface::topologyFilterType
50Foam::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))
195template<
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_)
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,
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);
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_)
657 refineBlockedCells(ignoreCells, isoCutter);
658 filterKeepLargestRegion(ignoreCells);
660 else if (topologyFilterType::NEAREST_POINTS == topoFilter_)
662 refineBlockedCells(ignoreCells, isoCutter);
663 filterKeepNearestRegions(ignoreCells);
675 Pout<<
"Writing cell distance:" << cellDistance.objectPath() <<
endl;
676 cellDistance.
write();
682 "distanceSurface.pointDistance",
712 if (filterCells && topologyFilterType::PROXIMITY_REGIONS == topoFilter_)
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();
Macros for easy insertion into run-time selection tables.
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
fileName objectPath() const
The complete path + object name.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
void clearStorage()
Clear the list and delete storage.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
const point_type & point() const noexcept
Return point, no checks.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
static word timeName(const scalar t, const int precision=precision_)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void flip()
Invert all bits in the addressable region.
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool none() const
True if no bits in this bitset are set.
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
A bounding box defined in terms of min/max extrema points.
bool contains(const point &pt) const
Contains point? (inside or on edge)
void add(const boundBox &bb)
Extend to include the second box.
void inflate(const scalar s)
Inflate box by factor*mag(span) in all dimensions.
void clear()
Clear bounding box and make it an inverted box.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
void createGeometry()
Create/recreate the distance surface.
Mesh data needed to do the Finite Volume discretisation.
const volVectorField & C() const
Return cell centres as volVectorField.
const Time & time() const
Return the top-level database.
Low-level components common to various iso-surface algorithms.
Preferences for controlling iso-surface algorithms.
scalar print()
Print to screen.
constant condensation/saturation model.
Mesh consisting of general polyhedral cells.
virtual const pointField & points() const
Return raw points.
label nPoints() const noexcept
Number of mesh points.
const labelListList & cellPoints() const
label nCells() const noexcept
Number of mesh cells.
void reset(const label nPoints, const label nInternalFaces, const label nFaces, const label nCells)
Reset this primitiveMesh given the primitive array sizes.
virtual bool write(const bool valid=true) const
Write using setting from DB.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
static void calcNormalDistance_zero(scalarField &distance, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
scalar distance(const vector &p1, const vector &p2)
static scalar normalDistance_zero(const point &pt, const pointIndexHit &pHit, const vector &norm)
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
static void calcNormalDistance_filtered(scalarField &distance, const bitSet &ignoreLocation, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
static scalar normalDistance_nonzero(const point &pt, const pointIndexHit &pHit, const vector &norm)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool equal(const T &s1, const T &s2)
Compare two values for equality.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
static void calcNormalDistance_nonzero(scalarField &distance, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
static void checkAllHits(const UList< pointIndexHit > &nearest)
static bitSet simpleGeometricFilter(bitSet &ignoreCells, const List< pointIndexHit > &nearest, const polyMesh &mesh, const scalar boundBoxInflate=0.1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.