mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
ENH: searchableSurface
Made coordinates tmp<> Added points Added overlap tests to plate and sphere
This commit is contained in:
@ -232,9 +232,10 @@ const Foam::wordList& Foam::searchableBox::regions() const
|
||||
}
|
||||
|
||||
|
||||
Foam::pointField Foam::searchableBox::coordinates() const
|
||||
Foam::tmp<Foam::pointField> Foam::searchableBox::coordinates() const
|
||||
{
|
||||
pointField ctrs(6);
|
||||
tmp<pointField> tCtrs = tmp<pointField>(new pointField(6));
|
||||
pointField& ctrs = tCtrs();
|
||||
|
||||
const pointField pts(treeBoundBox::points());
|
||||
const faceList& fcs = treeBoundBox::faces;
|
||||
@ -243,7 +244,14 @@ Foam::pointField Foam::searchableBox::coordinates() const
|
||||
{
|
||||
ctrs[i] = fcs[i].centre(pts);
|
||||
}
|
||||
return ctrs;
|
||||
|
||||
return tCtrs;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::searchableBox::points() const
|
||||
{
|
||||
return treeBoundBox::points();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -127,7 +127,10 @@ public:
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual pointField coordinates() const;
|
||||
virtual tmp<pointField> coordinates() const;
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const;
|
||||
|
||||
// Does any part of the surface overlap the supplied bound box?
|
||||
virtual bool overlaps(const boundBox& bb) const
|
||||
|
||||
@ -39,11 +39,23 @@ addToRunTimeSelectionTable(searchableSurface, searchableCylinder, dict);
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::pointField Foam::searchableCylinder::coordinates() const
|
||||
Foam::tmp<Foam::pointField> Foam::searchableCylinder::coordinates() const
|
||||
{
|
||||
pointField ctrs(1, 0.5*(point1_ + point2_));
|
||||
tmp<pointField> tCtrs(new pointField(1, 0.5*(point1_ + point2_)));
|
||||
|
||||
return ctrs;
|
||||
return tCtrs;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::searchableCylinder::points() const
|
||||
{
|
||||
tmp<pointField> tPts(new pointField(2));
|
||||
pointField& pts = tPts();
|
||||
|
||||
pts[0] = point1_;
|
||||
pts[1] = point2_;
|
||||
|
||||
return tPts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -152,7 +152,10 @@ public:
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual pointField coordinates() const;
|
||||
virtual tmp<pointField> coordinates() const;
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const;
|
||||
|
||||
//- Does any part of the surface overlap the supplied bound box?
|
||||
virtual bool overlaps(const boundBox& bb) const
|
||||
|
||||
@ -124,10 +124,16 @@ public:
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual pointField coordinates() const
|
||||
virtual tmp<pointField> coordinates() const
|
||||
{
|
||||
//notImplemented("searchablePlane::coordinates()")
|
||||
return pointField(1, refPoint());
|
||||
tmp<pointField> tCtrs(new pointField(1, refPoint()));
|
||||
return tCtrs;
|
||||
}
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const
|
||||
{
|
||||
return coordinates();
|
||||
}
|
||||
|
||||
//- Does any part of the surface overlap the supplied bound box?
|
||||
|
||||
@ -144,20 +144,52 @@ public:
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual pointField coordinates() const
|
||||
virtual tmp<pointField> coordinates() const
|
||||
{
|
||||
return pointField(1, origin_);
|
||||
tmp<pointField> tCtrs(new pointField(1, origin_ + 0.5*span_));
|
||||
return tCtrs;
|
||||
}
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const
|
||||
{
|
||||
tmp<pointField> tPts(new pointField(4));
|
||||
pointField& pts = tPts();
|
||||
|
||||
pts[0] = origin_;
|
||||
pts[2] = origin_ + span_;
|
||||
|
||||
if (span_.x() < span_.y() && span_.x() < span_.z())
|
||||
{
|
||||
pts[1] = origin_ + point(0, span_.y(), 0);
|
||||
pts[3] = origin_ + point(0, 0, span_.z());
|
||||
}
|
||||
else if (span_.y() < span_.z())
|
||||
{
|
||||
pts[1] = origin_ + point(span_.x(), 0, 0);
|
||||
pts[3] = origin_ + point(0, 0, span_.z());
|
||||
}
|
||||
else
|
||||
{
|
||||
pts[1] = origin_ + point(span_.x(), 0, 0);
|
||||
pts[3] = origin_ + point(0, span_.y(), 0);
|
||||
}
|
||||
|
||||
return tPts;
|
||||
}
|
||||
|
||||
//- Does any part of the surface overlap the supplied bound box?
|
||||
virtual bool overlaps(const boundBox& bb) const
|
||||
{
|
||||
notImplemented
|
||||
return
|
||||
(
|
||||
"searchablePlate::overlaps(const boundBox&) const"
|
||||
(origin_.x() + span_.x()) >= bb.min().x()
|
||||
&& origin_.x() <= bb.max().x()
|
||||
&& (origin_.y() + span_.y()) >= bb.min().y()
|
||||
&& origin_.y() <= bb.max().y()
|
||||
&& (origin_.z() + span_.z()) >= bb.min().z()
|
||||
&& origin_.z() <= bb.max().z()
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -167,6 +167,12 @@ Foam::searchableSphere::~searchableSphere()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::searchableSphere::overlaps(const boundBox& bb) const
|
||||
{
|
||||
return bb.overlaps(centre_, sqr(radius_));
|
||||
}
|
||||
|
||||
|
||||
const Foam::wordList& Foam::searchableSphere::regions() const
|
||||
{
|
||||
if (regions_.empty())
|
||||
|
||||
@ -133,21 +133,20 @@ public:
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual pointField coordinates() const
|
||||
virtual tmp<pointField> coordinates() const
|
||||
{
|
||||
return pointField(1, centre_);
|
||||
tmp<pointField> tCtrs(new pointField(1, centre_));
|
||||
return tCtrs;
|
||||
}
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const
|
||||
{
|
||||
return coordinates();
|
||||
}
|
||||
|
||||
//- Does any part of the surface overlap the supplied bound box?
|
||||
virtual bool overlaps(const boundBox& bb) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"searchableSphere::overlaps(const boundBox&) const"
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
virtual bool overlaps(const boundBox& bb) const;
|
||||
|
||||
|
||||
// Multiple point queries.
|
||||
|
||||
@ -206,7 +206,10 @@ public:
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual pointField coordinates() const = 0;
|
||||
virtual tmp<pointField> coordinates() const = 0;
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const = 0;
|
||||
|
||||
//- Does any part of the surface overlap the supplied bound box?
|
||||
virtual bool overlaps(const boundBox& bb) const = 0;
|
||||
|
||||
@ -325,10 +325,11 @@ Foam::label Foam::searchableSurfaceCollection::size() const
|
||||
}
|
||||
|
||||
|
||||
Foam::pointField Foam::searchableSurfaceCollection::coordinates() const
|
||||
Foam::tmp<Foam::pointField>
|
||||
Foam::searchableSurfaceCollection::coordinates() const
|
||||
{
|
||||
// Get overall size
|
||||
pointField coords(size());
|
||||
tmp<pointField> tCtrs = tmp<pointField>(new pointField(size()));
|
||||
pointField& ctrs = tCtrs();
|
||||
|
||||
// Append individual coordinates
|
||||
label coordI = 0;
|
||||
@ -339,7 +340,7 @@ Foam::pointField Foam::searchableSurfaceCollection::coordinates() const
|
||||
|
||||
forAll(subCoords, i)
|
||||
{
|
||||
coords[coordI++] = transform_[surfI].globalPosition
|
||||
ctrs[coordI++] = transform_[surfI].globalPosition
|
||||
(
|
||||
cmptMultiply
|
||||
(
|
||||
@ -350,7 +351,45 @@ Foam::pointField Foam::searchableSurfaceCollection::coordinates() const
|
||||
}
|
||||
}
|
||||
|
||||
return coords;
|
||||
return tCtrs;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::pointField>
|
||||
Foam::searchableSurfaceCollection::points() const
|
||||
{
|
||||
// Get overall size
|
||||
label nPoints = 0;
|
||||
|
||||
forAll(subGeom_, surfI)
|
||||
{
|
||||
nPoints += subGeom_[surfI].points()().size();
|
||||
}
|
||||
|
||||
tmp<pointField> tPts(new pointField(nPoints));
|
||||
pointField& pts = tPts();
|
||||
|
||||
// Append individual coordinates
|
||||
nPoints = 0;
|
||||
|
||||
forAll(subGeom_, surfI)
|
||||
{
|
||||
const pointField subCoords = subGeom_[surfI].points();
|
||||
|
||||
forAll(subCoords, i)
|
||||
{
|
||||
pts[nPoints++] = transform_[surfI].globalPosition
|
||||
(
|
||||
cmptMultiply
|
||||
(
|
||||
subCoords[i],
|
||||
scale_[surfI]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return tPts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -174,7 +174,10 @@ public:
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual pointField coordinates() const;
|
||||
virtual tmp<pointField> coordinates() const;
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const;
|
||||
|
||||
//- Does any part of the surface overlap the supplied bound box?
|
||||
virtual bool overlaps(const boundBox& bb) const
|
||||
|
||||
@ -54,7 +54,7 @@ namespace Foam
|
||||
// Forward declaration of classes
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class searchableSurfaceWithGaps Declaration
|
||||
Class searchableSurfaceWithGaps Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class searchableSurfaceWithGaps
|
||||
@ -151,11 +151,17 @@ public:
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual pointField coordinates() const
|
||||
virtual tmp<pointField> coordinates() const
|
||||
{
|
||||
return surface().coordinates();
|
||||
}
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const
|
||||
{
|
||||
return surface().points();
|
||||
}
|
||||
|
||||
//- Does any part of the surface overlap the supplied bound box?
|
||||
// Note: use perturbed surface? Since uses boundbox of points and
|
||||
// not actual intersection chosen to use unperturbed surface.
|
||||
|
||||
@ -846,7 +846,7 @@ void Foam::searchableSurfaces::writeStats
|
||||
{
|
||||
const triSurfaceMesh& ts = dynamic_cast<const triSurfaceMesh&>(s);
|
||||
Info<< " edges : " << ts.nEdges() << nl
|
||||
<< " points : " << ts.points().size() << nl;
|
||||
<< " points : " << ts.points()().size() << nl;
|
||||
}
|
||||
Info<< " bounds : " << s.bounds() << nl
|
||||
<< " closed : " << Switch(s.hasVolumeType()) << endl;
|
||||
|
||||
@ -148,7 +148,7 @@ bool Foam::triSurfaceMesh::isSurfaceClosed() const
|
||||
// Construct pointFaces. Let's hope surface has compact point
|
||||
// numbering ...
|
||||
labelListList pointFaces;
|
||||
invertManyToMany(points().size(), *this, pointFaces);
|
||||
invertManyToMany(points()().size(), *this, pointFaces);
|
||||
|
||||
// Loop over all faces surrounding point. Count edges emanating from point.
|
||||
// Every edge should be used by two faces exactly.
|
||||
@ -288,7 +288,7 @@ void Foam::triSurfaceMesh::calcBounds(boundBox& bb, label& nPoints) const
|
||||
|
||||
const triSurface& s = static_cast<const triSurface&>(*this);
|
||||
|
||||
PackedBoolList pointIsUsed(points().size());
|
||||
PackedBoolList pointIsUsed(points()().size());
|
||||
|
||||
nPoints = 0;
|
||||
bb = boundBox::invertedBox;
|
||||
@ -302,8 +302,8 @@ void Foam::triSurfaceMesh::calcBounds(boundBox& bb, label& nPoints) const
|
||||
label pointI = f[fp];
|
||||
if (pointIsUsed.set(pointI, 1u))
|
||||
{
|
||||
bb.min() = ::Foam::min(bb.min(), points()[pointI]);
|
||||
bb.max() = ::Foam::max(bb.max(), points()[pointI]);
|
||||
bb.min() = ::Foam::min(bb.min(), points()()[pointI]);
|
||||
bb.max() = ::Foam::max(bb.max(), points()()[pointI]);
|
||||
nPoints++;
|
||||
}
|
||||
}
|
||||
@ -487,14 +487,25 @@ void Foam::triSurfaceMesh::clearOut()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointField Foam::triSurfaceMesh::coordinates() const
|
||||
Foam::tmp<Foam::pointField> Foam::triSurfaceMesh::coordinates() const
|
||||
{
|
||||
tmp<pointField> tPts(new pointField(8));
|
||||
pointField& pt = tPts();
|
||||
|
||||
// Use copy to calculate face centres so they don't get stored
|
||||
return PrimitivePatch<triSurface::FaceType, SubList, const pointField&>
|
||||
pt = PrimitivePatch<triSurface::FaceType, SubList, const pointField&>
|
||||
(
|
||||
SubList<triSurface::FaceType>(*this, triSurface::size()),
|
||||
triSurface::points()
|
||||
).faceCentres();
|
||||
|
||||
return tPts;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::pointField> Foam::triSurfaceMesh::points() const
|
||||
{
|
||||
return triSurface::points();
|
||||
}
|
||||
|
||||
|
||||
@ -526,12 +537,12 @@ Foam::triSurfaceMesh::tree() const
|
||||
label nPoints;
|
||||
calcBounds(bb, nPoints);
|
||||
|
||||
if (nPoints != points().size())
|
||||
if (nPoints != points()().size())
|
||||
{
|
||||
WarningIn("triSurfaceMesh::tree() const")
|
||||
<< "Surface " << searchableSurface::name()
|
||||
<< " does not have compact point numbering."
|
||||
<< " Of " << points().size() << " only " << nPoints
|
||||
<< " Of " << points()().size() << " only " << nPoints
|
||||
<< " are used. This might give problems in some routines."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -199,7 +199,10 @@ public:
|
||||
|
||||
//- Get representative set of element coordinates
|
||||
// Usually the element centres (should be of length size()).
|
||||
virtual pointField coordinates() const;
|
||||
virtual tmp<pointField> coordinates() const;
|
||||
|
||||
//- Get the points that define the surface.
|
||||
virtual tmp<pointField> points() const;
|
||||
|
||||
// Does any part of the surface overlap the supplied bound box?
|
||||
virtual bool overlaps(const boundBox& bb) const;
|
||||
|
||||
Reference in New Issue
Block a user