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
216 const point& pt = nearest[celli].point();
219 cellBb.
inflate(boundBoxInflate);
221 if (!cellBb.contains(pt))
223 ignoreCells.
set(celli);
225 else if (WantPointFilter)
243 const word& defaultSurfaceName,
256 dict.getOrDefault(
"surfaceName", defaultSurfaceName),
257 mesh.time().constant(),
266 distance_(
dict.getOrDefault<scalar>(
"distance", 0)),
267 withZeroDistance_(
equal(distance_, 0)),
272 ||
dict.getOrDefault<bool>(
"signed", true)
283 topoFilterNames_.getOrDefault
287 topologyFilterType::NONE
291 maxDistanceSqr_(
Foam::
sqr(GREAT)),
292 absProximity_(
dict.getOrDefault<scalar>(
"absProximity", 1
e-5)),
293 cellDistancePtr_(nullptr),
297 isoSurfacePtr_(nullptr)
299 if (topologyFilterType::NEAREST_POINTS == topoFilter_)
301 dict.readEntry(
"nearestPoints", nearestPoints_);
304 if (
dict.readIfPresent(
"maxDistance", maxDistanceSqr_))
306 maxDistanceSqr_ =
Foam::sqr(maxDistanceSqr_);
313 const polyMesh&
mesh,
314 const word& surfaceType,
315 const word& surfaceName,
316 const isoSurfaceParams& params,
337 const word& surfaceType,
338 const word& surfaceName,
340 const bool useSignedDistance,
354 mesh.time().constant(),
375 const bool useSignedDistance,
382 withZeroDistance_(
equal(distance_, 0)),
391 topoFilter_(topologyFilterType::NONE),
393 maxDistanceSqr_(
Foam::
sqr(GREAT)),
395 cellDistancePtr_(nullptr),
399 isoSurfacePtr_(nullptr)
409 Pout<<
"distanceSurface::createGeometry updating geometry." <<
endl;
413 isoSurfacePtr_.reset(
nullptr);
418 const searchableSurface& geom = geometryPtr_();
420 const fvMesh& fvmesh =
static_cast<const fvMesh&
>(mesh_);
425 cellDistancePtr_.reset
431 "distanceSurface.cellDistance",
432 fvmesh.time().timeName(),
442 auto& cellDistance = *cellDistancePtr_;
450 bitSet ignoreCells, ignoreCellPoints;
452 const bool filterCells =
464 List<pointIndexHit> nearest;
483 ignoreCellPoints = simpleGeometricFilter<false>
494 topologyFilterType::PROXIMITY_REGIONS == topoFilter_
501 if (withSignDistance_)
504 geom.getNormal(nearest, norms);
518 else if (withZeroDistance_)
529 calcAbsoluteDistance(
fld, cc, nearest);
536 forAll(fvmesh.C().boundaryField(), patchi)
538 const pointField& cc = fvmesh.C().boundaryField()[patchi];
541 List<pointIndexHit> nearest;
550 if (withSignDistance_)
553 geom.getNormal(nearest, norms);
555 if (withZeroDistance_)
571 calcAbsoluteDistance(
fld, cc, nearest);
582 pointDistance_.resize(fvmesh.nPoints());
583 pointDistance_ = GREAT;
588 List<pointIndexHit> nearest;
598 if (withSignDistance_)
601 geom.getNormal(nearest, norms);
615 else if (withZeroDistance_)
626 calcAbsoluteDistance(
fld,
pts, nearest);
632 if (ignoreCells.none())
634 ignoreCells.clearStorage();
636 else if (filterCells && topologyFilterType::NONE != topoFilter_)
639 isoSurfaceBase isoCutter
647 if (topologyFilterType::LARGEST_REGION == topoFilter_)
649 refineBlockedCells(ignoreCells, isoCutter);
650 filterKeepLargestRegion(ignoreCells);
652 else if (topologyFilterType::NEAREST_POINTS == topoFilter_)
654 refineBlockedCells(ignoreCells, isoCutter);
655 filterKeepNearestRegions(ignoreCells);
662 ignoreCellPoints.clearStorage();
667 Pout<<
"Writing cell distance:" << cellDistance.objectPath() <<
endl;
668 cellDistance.
write();
674 "distanceSurface.pointDistance",
675 fvmesh.time().timeName(),
686 Pout<<
"Writing point distance:" << pDist.objectPath() <<
endl;
704 if (filterCells && topologyFilterType::PROXIMITY_REGIONS == topoFilter_)
706 isoSurfaceBase isoCutter
714 refineBlockedCells(ignoreCells, isoCutter);
725 || topologyFilterType::PROXIMITY_FACES == topoFilter_
726 || topologyFilterType::PROXIMITY_REGIONS == topoFilter_
729 surface_.transfer(static_cast<meshedSurface&>(*isoSurfacePtr_));
730 meshCells_.transfer(isoSurfacePtr_->meshCells());
732 isoSurfacePtr_.reset(
nullptr);
733 cellDistancePtr_.reset(
nullptr);
734 pointDistance_.clear();
737 if (topologyFilterType::PROXIMITY_FACES == topoFilter_)
739 filterFaceProximity();
741 else if (topologyFilterType::PROXIMITY_REGIONS == topoFilter_)
743 filterRegionProximity(ignoreCells);
756 os <<
" surface:" << surfaceName()
758 <<
" topology:" << topoFilterNames_[topoFilter_];
760 isoParams_.print(
os);
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dimensionedScalar sign(const dimensionedScalar &ds)
static scalar normalDistance_zero(const point &pt, const pointIndexHit &pHit, const vector &norm)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
void size(const label n)
Older name for setAddressableSize.
distanceSurface(const word &defaultSurfaceName, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
void set(const bitSet &bitset)
Set specified bits from another bitset.
void createGeometry()
Create/recreate the distance surface.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void inflate(const scalar factor)
Expand box by factor*mag(span) in all dimensions.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Preferences for controlling iso-surface algorithms.
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static void checkAllHits(const UList< pointIndexHit > &nearest)
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
scalar distance(const vector &p1, const vector &p2)
A bounding box defined in terms of min/max extrema points.
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
Ignore writing from objectRegistry::writeObject()
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Macros for easy insertion into run-time selection tables.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
#define forAll(list, i)
Loop across all elements in list.
static scalar normalDistance_nonzero(const point &pt, const pointIndexHit &pHit, const vector &norm)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
static void calcNormalDistance_nonzero(scalarField &distance, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
static bitSet simpleGeometricFilter(bitSet &ignoreCells, const List< pointIndexHit > &nearest, const polyMesh &mesh, const scalar boundBoxInflate=0.1)
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
errorManip< error > abort(error &err)
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
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))
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
bool hit() const noexcept
Is there a hit?
bool equal(const T &s1, const T &s2)
Compare two values for equality.
vector point
Point is a vector.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
label nCells() const noexcept
Number of mesh cells.
static void calcNormalDistance_zero(scalarField &distance, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
Field< vector > vectorField
Specialisation of Field<T> for vector.
A surface defined by a distance from an input searchable surface. Uses an iso-surface algorithm (cell...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
static void calcNormalDistance_filtered(scalarField &distance, const bitSet &ignoreLocation, const pointField &points, const List< pointIndexHit > &nearest, const vectorField &normals)
Defines the attributes of an object for which implicit objectRegistry management is supported...
boundBox cellBb(const label celli) const
The bounding box for given cell index.
void print(Ostream &os, int level=0) const
Print information.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const labelListList & cellPoints() const
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.
static constexpr const zero Zero
Global zero (0)