mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: PointEdgeWave with trackData template argument. Using nonBlocking comms.
This commit is contained in:
@ -756,6 +756,9 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
||||
// Distance to wall
|
||||
List<pointData> pointWallDist(mesh.nPoints());
|
||||
|
||||
// Dummy additional info for PointEdgeWave
|
||||
int dummyTrackData = 0;
|
||||
|
||||
|
||||
// 1. Calculate distance to points where displacement is specified.
|
||||
{
|
||||
@ -783,7 +786,8 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
||||
wallInfo,
|
||||
pointWallDist,
|
||||
edgeWallDist,
|
||||
mesh.globalData().nTotalPoints() // max iterations
|
||||
mesh.globalData().nTotalPoints(), // max iterations
|
||||
dummyTrackData
|
||||
);
|
||||
}
|
||||
|
||||
@ -813,7 +817,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
||||
{
|
||||
label pointI = e[ep];
|
||||
|
||||
if (!pointMedialDist[pointI].valid())
|
||||
if (!pointMedialDist[pointI].valid(dummyTrackData))
|
||||
{
|
||||
maxPoints.append(pointI);
|
||||
maxInfo.append
|
||||
@ -857,7 +861,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
||||
{
|
||||
label pointI = meshPoints[i];
|
||||
|
||||
if (!pointMedialDist[pointI].valid())
|
||||
if (!pointMedialDist[pointI].valid(dummyTrackData))
|
||||
{
|
||||
maxPoints.append(pointI);
|
||||
maxInfo.append
|
||||
@ -888,7 +892,8 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
||||
|
||||
pointMedialDist,
|
||||
edgeMedialDist,
|
||||
mesh.globalData().nTotalPoints() // max iterations
|
||||
mesh.globalData().nTotalPoints(), // max iterations
|
||||
dummyTrackData
|
||||
);
|
||||
|
||||
// Extract medial axis distance as pointScalarField
|
||||
|
||||
@ -32,19 +32,20 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const pointData& wDist)
|
||||
if (os.format() == IOstream::ASCII)
|
||||
{
|
||||
return os
|
||||
<< wDist.origin() << token::SPACE << wDist.distSqr()
|
||||
<< static_cast<const pointEdgePoint&>(wDist)
|
||||
<< token::SPACE << wDist.s() << token::SPACE << wDist.v();
|
||||
}
|
||||
else
|
||||
{
|
||||
return os
|
||||
<< wDist.origin() << wDist.distSqr() << wDist.s() << wDist.v();
|
||||
<< static_cast<const pointEdgePoint&>(wDist)
|
||||
<< wDist.s() << wDist.v();
|
||||
}
|
||||
}
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, pointData& wDist)
|
||||
{
|
||||
return is >> wDist.origin_ >> wDist.distSqr_ >> wDist.s_ >> wDist.v_;
|
||||
return is >> static_cast<pointEdgePoint&>(wDist) >> wDist.s_ >> wDist.v_;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -25,10 +25,10 @@ Class
|
||||
Foam::pointData
|
||||
|
||||
Description
|
||||
Holds information regarding nearest wall point. Used in pointEdgeWave.
|
||||
(so not standard meshWave)
|
||||
|
||||
To be used in wall distance calculation.
|
||||
Variant of pointEdgePoint with some transported additional data.
|
||||
WIP - should be templated on data like wallDistData.
|
||||
Passive vector v_ is not a coordinate (so no enterDomain/leaveDomain
|
||||
transformation needed)
|
||||
|
||||
SourceFiles
|
||||
pointDataI.H
|
||||
@ -39,9 +39,10 @@ SourceFiles
|
||||
#ifndef pointData_H
|
||||
#define pointData_H
|
||||
|
||||
#include "point.H"
|
||||
#include "label.H"
|
||||
#include "tensor.H"
|
||||
#include "pointEdgePoint.H"
|
||||
//#include "point.H"
|
||||
//#include "label.H"
|
||||
//#include "tensor.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -49,51 +50,22 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Class forward declarations
|
||||
class polyPatch;
|
||||
class polyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pointData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pointData
|
||||
:
|
||||
public pointEdgePoint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- position of nearest wall center
|
||||
point origin_;
|
||||
|
||||
//- normal distance (squared) from point to origin
|
||||
scalar distSqr_;
|
||||
|
||||
//- additional information.
|
||||
scalar s_;
|
||||
|
||||
//- additional information.
|
||||
vector v_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Evaluate distance to point. Update distSqr, origin from whomever
|
||||
// is nearer pt. Return true if w2 is closer to point,
|
||||
// false otherwise.
|
||||
inline bool update
|
||||
(
|
||||
const point&,
|
||||
const pointData& w2,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
//- Combine current with w2. Update distSqr, origin if w2 has smaller
|
||||
// quantities and returns true.
|
||||
inline bool update
|
||||
(
|
||||
const pointData& w2,
|
||||
const scalar tol
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
@ -118,10 +90,6 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
inline const point& origin() const;
|
||||
|
||||
inline scalar distSqr() const;
|
||||
|
||||
inline scalar s() const;
|
||||
|
||||
inline const vector& v() const;
|
||||
@ -129,81 +97,60 @@ public:
|
||||
|
||||
// Needed by meshWave
|
||||
|
||||
//- Check whether origin has been changed at all or
|
||||
// still contains original (invalid) value.
|
||||
inline bool valid() const;
|
||||
|
||||
//- Check for identical geometrical data. Used for cyclics checking.
|
||||
inline bool sameGeometry(const pointData&, const scalar tol)
|
||||
const;
|
||||
|
||||
//- Convert origin to relative vector to leaving point
|
||||
// (= point coordinate)
|
||||
inline void leaveDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchPointI,
|
||||
const point& pos
|
||||
);
|
||||
|
||||
//- Convert relative origin to absolute by adding entering point
|
||||
inline void enterDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchPointI,
|
||||
const point& pos
|
||||
);
|
||||
|
||||
//- Apply rotation matrix to origin
|
||||
inline void transform(const tensor& rotTensor);
|
||||
template<class TrackingData>
|
||||
inline void transform
|
||||
(
|
||||
const tensor& rotTensor,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of edge on point
|
||||
template<class TrackingData>
|
||||
inline bool updatePoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label pointI,
|
||||
const label edgeI,
|
||||
const pointData& edgeInfo,
|
||||
const scalar tol
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of different value on same point.
|
||||
// Merge new and old info.
|
||||
template<class TrackingData>
|
||||
inline bool updatePoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label pointI,
|
||||
const pointData& newPointInfo,
|
||||
const scalar tol
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of different value on same point.
|
||||
// No information about current position whatsoever.
|
||||
template<class TrackingData>
|
||||
inline bool updatePoint
|
||||
(
|
||||
const pointData& newPointInfo,
|
||||
const scalar tol
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
//- Influence of point on edge.
|
||||
template<class TrackingData>
|
||||
inline bool updateEdge
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label edgeI,
|
||||
const label pointI,
|
||||
const pointData& pointInfo,
|
||||
const scalar tol
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//Note: Used to determine whether to call update.
|
||||
inline bool operator==(const pointData&) const;
|
||||
|
||||
inline bool operator!=(const pointData&) const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const pointData&);
|
||||
|
||||
@ -26,118 +26,12 @@ License
|
||||
#include "polyMesh.H"
|
||||
#include "transform.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Update this with w2 if w2 nearer to pt.
|
||||
inline bool Foam::pointData::update
|
||||
(
|
||||
const point& pt,
|
||||
const pointData& w2,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
scalar dist2 = magSqr(pt - w2.origin());
|
||||
|
||||
if (!valid())
|
||||
{
|
||||
distSqr_ = dist2;
|
||||
origin_ = w2.origin();
|
||||
s_ = w2.s();
|
||||
v_ = w2.v();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// if (v_ != w2.v())
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
scalar diff = distSqr_ - dist2;
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
// already nearer to pt
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
|
||||
{
|
||||
// don't propagate small changes
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// update with new values
|
||||
distSqr_ = dist2;
|
||||
origin_ = w2.origin();
|
||||
s_ = w2.s();
|
||||
v_ = w2.v();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update this with w2 (information on same point)
|
||||
inline bool Foam::pointData::update
|
||||
(
|
||||
const pointData& w2,
|
||||
const scalar tol
|
||||
)
|
||||
{
|
||||
if (!valid())
|
||||
{
|
||||
// current not yet set so use any value
|
||||
distSqr_ = w2.distSqr();
|
||||
origin_ = w2.origin();
|
||||
s_ = w2.s();
|
||||
v_ = w2.v();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// if (v_ != w2.v())
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
scalar diff = distSqr_ - w2.distSqr();
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
// already nearer to pt
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
|
||||
{
|
||||
// don't propagate small changes
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// update with new values
|
||||
distSqr_ = w2.distSqr();
|
||||
origin_ = w2.origin();
|
||||
s_ = w2.s();
|
||||
v_ = w2.v();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
inline Foam::pointData::pointData()
|
||||
:
|
||||
origin_(point::max),
|
||||
distSqr_(GREAT),
|
||||
pointEdgePoint(),
|
||||
s_(GREAT),
|
||||
v_(point::max)
|
||||
{}
|
||||
@ -152,8 +46,7 @@ inline Foam::pointData::pointData
|
||||
const vector& v
|
||||
)
|
||||
:
|
||||
origin_(origin),
|
||||
distSqr_(distSqr),
|
||||
pointEdgePoint(origin, distSqr),
|
||||
s_(s),
|
||||
v_(v)
|
||||
{}
|
||||
@ -162,8 +55,7 @@ inline Foam::pointData::pointData
|
||||
// Construct as copy
|
||||
inline Foam::pointData::pointData(const pointData& wpt)
|
||||
:
|
||||
origin_(wpt.origin()),
|
||||
distSqr_(wpt.distSqr()),
|
||||
pointEdgePoint(wpt),
|
||||
s_(wpt.s()),
|
||||
v_(wpt.v())
|
||||
{}
|
||||
@ -171,18 +63,6 @@ inline Foam::pointData::pointData(const pointData& wpt)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::point& Foam::pointData::origin() const
|
||||
{
|
||||
return origin_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::pointData::distSqr() const
|
||||
{
|
||||
return distSqr_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::pointData::s() const
|
||||
{
|
||||
return s_;
|
||||
@ -195,157 +75,143 @@ inline const Foam::vector& Foam::pointData::v() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::pointData::valid() const
|
||||
{
|
||||
return origin_ != point::max;
|
||||
}
|
||||
|
||||
|
||||
// Checks for cyclic points
|
||||
inline bool Foam::pointData::sameGeometry
|
||||
template <class TrackingData>
|
||||
inline void Foam::pointData::transform
|
||||
(
|
||||
const pointData& w2,
|
||||
const scalar tol
|
||||
) const
|
||||
{
|
||||
scalar diff = Foam::mag(distSqr() - w2.distSqr());
|
||||
|
||||
if (diff < SMALL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::pointData::leaveDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchPointI,
|
||||
const point& coord
|
||||
const tensor& rotTensor,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
origin_ -= coord;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::pointData::transform(const tensor& rotTensor)
|
||||
{
|
||||
origin_ = Foam::transform(rotTensor, origin_);
|
||||
}
|
||||
|
||||
|
||||
// Update absolute geometric quantities. Note that distance (distSqr_)
|
||||
// is not affected by leaving/entering domain.
|
||||
inline void Foam::pointData::enterDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label patchPointI,
|
||||
const point& coord
|
||||
)
|
||||
{
|
||||
// back to absolute form
|
||||
origin_ += coord;
|
||||
pointEdgePoint::transform(rotTensor, td);
|
||||
v_ = Foam::transform(rotTensor, v_);
|
||||
}
|
||||
|
||||
|
||||
// Update this with information from connected edge
|
||||
template <class TrackingData>
|
||||
inline bool Foam::pointData::updatePoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label pointI,
|
||||
const label edgeI,
|
||||
const pointData& edgeInfo,
|
||||
const scalar tol
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return
|
||||
update
|
||||
if
|
||||
(
|
||||
pointEdgePoint::updatePoint
|
||||
(
|
||||
mesh.points()[pointI],
|
||||
mesh,
|
||||
pointI,
|
||||
edgeI,
|
||||
edgeInfo,
|
||||
tol
|
||||
);
|
||||
tol,
|
||||
td
|
||||
)
|
||||
)
|
||||
{
|
||||
s_ = edgeInfo.s_;
|
||||
v_ = edgeInfo.v_;
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update this with new information on same point
|
||||
template <class TrackingData>
|
||||
inline bool Foam::pointData::updatePoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label pointI,
|
||||
const pointData& newPointInfo,
|
||||
const scalar tol
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return
|
||||
update
|
||||
if
|
||||
(
|
||||
pointEdgePoint::updatePoint
|
||||
(
|
||||
mesh.points()[pointI],
|
||||
mesh,
|
||||
pointI,
|
||||
newPointInfo,
|
||||
tol
|
||||
);
|
||||
tol,
|
||||
td
|
||||
)
|
||||
)
|
||||
{
|
||||
s_ = newPointInfo.s_;
|
||||
v_ = newPointInfo.v_;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update this with new information on same point. No extra information.
|
||||
template <class TrackingData>
|
||||
inline bool Foam::pointData::updatePoint
|
||||
(
|
||||
const pointData& newPointInfo,
|
||||
const scalar tol
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
)
|
||||
{
|
||||
return update(newPointInfo, tol);
|
||||
if (pointEdgePoint::updatePoint(newPointInfo, tol, td))
|
||||
{
|
||||
s_ = newPointInfo.s_;
|
||||
v_ = newPointInfo.v_;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update this with information from connected point
|
||||
template <class TrackingData>
|
||||
inline bool Foam::pointData::updateEdge
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label edgeI,
|
||||
const label pointI,
|
||||
const pointData& pointInfo,
|
||||
const scalar tol
|
||||
const scalar tol,
|
||||
TrackingData& td
|
||||
|
||||
)
|
||||
{
|
||||
const pointField& points = mesh.points();
|
||||
|
||||
const edge& e = mesh.edges()[edgeI];
|
||||
|
||||
const point edgeMid(0.5*(points[e[0]] + points[e[1]]));
|
||||
|
||||
return
|
||||
update
|
||||
if
|
||||
(
|
||||
pointEdgePoint::updateEdge
|
||||
(
|
||||
edgeMid,
|
||||
mesh,
|
||||
edgeI,
|
||||
pointI,
|
||||
pointInfo,
|
||||
tol
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::pointData::operator==(const pointData& rhs) const
|
||||
{
|
||||
return origin() == rhs.origin();
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::pointData::operator!=(const pointData& rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
tol,
|
||||
td
|
||||
)
|
||||
)
|
||||
{
|
||||
s_ = pointInfo.s_;
|
||||
v_ = pointInfo.v_;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user