Commit 8a355a63 authored by mattijs's avatar mattijs
Browse files

ENH: PointEdgeWave with trackData template argument. Using nonBlocking comms.

parent 20de9437
......@@ -37,11 +37,7 @@ SourceFiles
#define pointEdgeStructuredWalk_H
#include "point.H"
#include "label.H"
#include "scalar.H"
#include "tensor.H"
#include "pTraits.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -75,10 +71,12 @@ class pointEdgeStructuredWalk
// Private Member Functions
//- Evaluate distance to point.
template<class TrackingData>
inline bool update
(
const pointEdgeStructuredWalk& w2,
const scalar tol
const scalar tol,
TrackingData& td
);
public:
......@@ -111,80 +109,105 @@ public:
// Needed by meshWave
//- Check whether still contains original (invalid) value.
inline bool valid() const;
//- Check whether origin has been changed at all or
// still contains original (invalid) value.
template<class TrackingData>
inline bool valid(TrackingData& td) const;
//- Check for identical geometrical data. Used for cyclics checking.
template<class TrackingData>
inline bool sameGeometry
(
const pointEdgeStructuredWalk&,
const scalar tol
const scalar tol,
TrackingData& td
) const;
//- Convert origin to relative vector to leaving point
// (= point coordinate)
template<class TrackingData>
inline void leaveDomain
(
const polyPatch& patch,
const label patchPointI,
const point& pos
const point& pos,
TrackingData& td
);
//- Convert relative origin to absolute by adding entering point
template<class TrackingData>
inline void enterDomain
(
const polyPatch& patch,
const label patchPointI,
const point& pos
const point& pos,
TrackingData& td
);
//- 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 pointEdgeStructuredWalk& 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 pointEdgeStructuredWalk& 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 pointEdgeStructuredWalk& 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 pointEdgeStructuredWalk& pointInfo,
const scalar tol
const scalar tol,
TrackingData& td
);
//- Same (like operator==)
template<class TrackingData>
inline bool equal(const pointEdgeStructuredWalk&, TrackingData&)
const;
// Member Operators
//Note: Used to determine whether to call update.
inline bool operator==(const pointEdgeStructuredWalk&) const;
inline bool operator!=(const pointEdgeStructuredWalk&) const;
......
......@@ -29,13 +29,15 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update this with w2.
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::update
(
const pointEdgeStructuredWalk& w2,
const scalar tol
const scalar tol,
TrackingData& td
)
{
if (!valid())
if (!valid(td))
{
// current not yet set. Walked from w2 to here (=point0)
dist_ = w2.dist_ + mag(point0_-w2.previousPoint_);
......@@ -105,17 +107,20 @@ inline const Foam::vector& Foam::pointEdgeStructuredWalk::data() const
}
inline bool Foam::pointEdgeStructuredWalk::valid() const
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::valid(TrackingData& td) const
{
return previousPoint_ != vector::max;
}
// Checks for cyclic points
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::sameGeometry
(
const pointEdgeStructuredWalk& w2,
const scalar tol
const scalar tol,
TrackingData& td
) const
{
scalar diff = Foam::mag(dist() - w2.dist());
......@@ -138,18 +143,25 @@ inline bool Foam::pointEdgeStructuredWalk::sameGeometry
}
template<class TrackingData>
inline void Foam::pointEdgeStructuredWalk::leaveDomain
(
const polyPatch& patch,
const label patchPointI,
const point& coord
const point& coord,
TrackingData& td
)
{
previousPoint_ -= coord;
}
inline void Foam::pointEdgeStructuredWalk::transform(const tensor& rotTensor)
template<class TrackingData>
inline void Foam::pointEdgeStructuredWalk::transform
(
const tensor& rotTensor,
TrackingData& td
)
{
previousPoint_ = Foam::transform(rotTensor, previousPoint_);
}
......@@ -157,11 +169,13 @@ inline void Foam::pointEdgeStructuredWalk::transform(const tensor& rotTensor)
// Update absolute geometric quantities. Note that distance (dist_)
// is not affected by leaving/entering domain.
template<class TrackingData>
inline void Foam::pointEdgeStructuredWalk::enterDomain
(
const polyPatch& patch,
const label patchPointI,
const point& coord
const point& coord,
TrackingData& td
)
{
// back to absolute form
......@@ -170,18 +184,20 @@ inline void Foam::pointEdgeStructuredWalk::enterDomain
// Update this with information from connected edge
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::updatePoint
(
const polyMesh& mesh,
const label pointI,
const label edgeI,
const pointEdgeStructuredWalk& edgeInfo,
const scalar tol
const scalar tol,
TrackingData& td
)
{
if (inZone())
{
return update(edgeInfo, tol);
return update(edgeInfo, tol, td);
}
else
{
......@@ -191,17 +207,19 @@ inline bool Foam::pointEdgeStructuredWalk::updatePoint
// Update this with new information on same point
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::updatePoint
(
const polyMesh& mesh,
const label pointI,
const pointEdgeStructuredWalk& newPointInfo,
const scalar tol
const scalar tol,
TrackingData& td
)
{
if (inZone())
{
return update(newPointInfo, tol);
return update(newPointInfo, tol, td);
}
else
{
......@@ -211,29 +229,33 @@ inline bool Foam::pointEdgeStructuredWalk::updatePoint
// Update this with new information on same point. No extra information.
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::updatePoint
(
const pointEdgeStructuredWalk& newPointInfo,
const scalar tol
const scalar tol,
TrackingData& td
)
{
return update(newPointInfo, tol);
return update(newPointInfo, tol, td);
}
// Update this with information from connected point
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::updateEdge
(
const polyMesh& mesh,
const label edgeI,
const label pointI,
const pointEdgeStructuredWalk& pointInfo,
const scalar tol
const scalar tol,
TrackingData& td
)
{
if (inZone())
{
return update(pointInfo, tol);
return update(pointInfo, tol, td);
}
else
{
......@@ -242,6 +264,17 @@ inline bool Foam::pointEdgeStructuredWalk::updateEdge
}
template <class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::equal
(
const pointEdgeStructuredWalk& rhs,
TrackingData& td
) const
{
return operator==(rhs);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::pointEdgeStructuredWalk::operator==
......
......@@ -91,6 +91,9 @@ void Foam::inversePointDistanceDiffusivity::correct()
List<pointEdgePoint> pointWallDist(mesh.nPoints());
List<pointEdgePoint> edgeWallDist(mesh.nEdges());
int dummyTrackData = 0;
{
// Seeds
List<pointEdgePoint> seedInfo(nPatchEdges);
......@@ -108,7 +111,7 @@ void Foam::inversePointDistanceDiffusivity::correct()
{
label pointI = meshPoints[i];
if (!pointWallDist[pointI].valid())
if (!pointWallDist[pointI].valid(dummyTrackData))
{
// Not yet seeded
seedInfo[nPatchEdges] = pointEdgePoint
......@@ -135,7 +138,8 @@ void Foam::inversePointDistanceDiffusivity::correct()
pointWallDist,
edgeWallDist,
mesh.globalData().nTotalPoints() // max iterations
mesh.globalData().nTotalPoints(),// max iterations
dummyTrackData
);
}
......
......@@ -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
//- Apply rotation matrix to origin
template<class TrackingData>
inline void transform
(
const polyPatch& patch,
const label patchPointI,
const point& pos
const tensor& rotTensor,
TrackingData& td
);
//- Apply rotation matrix to origin
inline void transform(const tensor& rotTensor);
//- 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,