mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
finally commited pending (cosmetic) code cleanup for blockMesh/curvedEdges
- slightly better code isolation, dropped unneed variables, changed vector -> point in the appropriate places - the spline stuff is still horribly broken. Needs a complete rewrite or needs to get chucked.
This commit is contained in:
@ -120,8 +120,8 @@ void Foam::blockDescriptor::setEdge
|
||||
// divide the line
|
||||
lineDivide divEdge(cedge, dim, 1.0/(gExp+SMALL));
|
||||
|
||||
pointField p = divEdge.points();
|
||||
scalarList d = divEdge.lambdaDivisions();
|
||||
const pointField& p = divEdge.points();
|
||||
const scalarList& d = divEdge.lambdaDivisions();
|
||||
|
||||
edgePoints_[edgeI].setSize(p.size());
|
||||
edgeWeights_[edgeI].setSize(d.size());
|
||||
|
||||
@ -115,13 +115,13 @@ Foam::BSpline::BSpline
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::BSpline::realPosition(const scalar mu) const
|
||||
Foam::point Foam::BSpline::realPosition(const scalar mu) const
|
||||
{
|
||||
return spline::position(mu);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::BSpline::position(const scalar mu) const
|
||||
Foam::point Foam::BSpline::position(const scalar mu) const
|
||||
{
|
||||
return spline::position((1.0/(nKnots() - 1))*(1.0 + mu*(nKnots() - 3)));
|
||||
}
|
||||
|
||||
@ -82,13 +82,13 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the real position of a point on the curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
vector realPosition(const scalar lambda) const;
|
||||
//- Return the real point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
point realPosition(const scalar lambda) const;
|
||||
|
||||
//- Return the position of a point on the curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
vector position(const scalar lambda) const;
|
||||
//- Return the point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
point position(const scalar lambda) const;
|
||||
|
||||
//- Return the length of the curve
|
||||
scalar length() const;
|
||||
|
||||
@ -61,7 +61,7 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle()
|
||||
|
||||
scalar fact = 0.5*(bsqr - adotb)/denom;
|
||||
|
||||
vector centre = 0.5*a + fact*((a ^ b) ^ a);
|
||||
point centre = 0.5*a + fact*((a ^ b) ^ a);
|
||||
|
||||
centre += p1_;
|
||||
|
||||
@ -75,7 +75,7 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle()
|
||||
angle_ = radToDeg(acos(tmp));
|
||||
|
||||
// check if the vectors define an exterior or an interior arcEdge
|
||||
if (((r1 ^ r2)&(r1 ^ r3)) < 0.0)
|
||||
if (((r1 ^ r2) & (r1 ^ r3)) < 0.0)
|
||||
{
|
||||
angle_ = 360.0 - angle_;
|
||||
}
|
||||
@ -133,7 +133,7 @@ Foam::arcEdge::arcEdge(const pointField& points, Istream& is)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::arcEdge::position(const scalar lambda) const
|
||||
Foam::point Foam::arcEdge::position(const scalar lambda) const
|
||||
{
|
||||
if (lambda < 0 || lambda > 1)
|
||||
{
|
||||
@ -146,7 +146,7 @@ Foam::vector Foam::arcEdge::position(const scalar lambda) const
|
||||
{
|
||||
return p1_;
|
||||
}
|
||||
else if (lambda > 1-SMALL)
|
||||
else if (lambda > 1 - SMALL)
|
||||
{
|
||||
return p3_;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ class arcEdge
|
||||
{
|
||||
// Private data
|
||||
|
||||
vector p1_, p2_, p3_;
|
||||
point p1_, p2_, p3_;
|
||||
scalar angle_;
|
||||
scalar radius_;
|
||||
cylindricalCS cs_;
|
||||
@ -96,9 +96,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the position of a point on the curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
vector position(const scalar) const;
|
||||
//- Return the point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
point position(const scalar) const;
|
||||
|
||||
//- Return the length of the curve
|
||||
scalar length() const;
|
||||
|
||||
@ -108,27 +108,27 @@ Foam::autoPtr<Foam::curvedEdge> Foam::curvedEdge::New
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointField Foam::curvedEdge::knotlist
|
||||
Foam::pointField Foam::curvedEdge::fullKnotList
|
||||
(
|
||||
const pointField& points,
|
||||
const label start,
|
||||
const label end,
|
||||
const pointField& otherknots
|
||||
const pointField& otherKnots
|
||||
)
|
||||
{
|
||||
pointField newPoints(otherknots.size() + 2);
|
||||
pointField allKnots(otherKnots.size() + 2);
|
||||
|
||||
// start/end knots
|
||||
newPoints[0] = points[start];
|
||||
newPoints[otherknots.size() + 1] = points[end];
|
||||
allKnots[0] = points[start];
|
||||
allKnots[otherKnots.size() + 1] = points[end];
|
||||
|
||||
// intermediate knots
|
||||
forAll(otherknots, knotI)
|
||||
forAll(otherKnots, knotI)
|
||||
{
|
||||
newPoints[knotI+1] = otherknots[knotI];
|
||||
allKnots[knotI+1] = otherKnots[knotI];
|
||||
}
|
||||
|
||||
return newPoints;
|
||||
return allKnots;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,8 +26,8 @@ Class
|
||||
Foam::curvedEdge
|
||||
|
||||
Description
|
||||
Define a curved edge in space that is parameterised for
|
||||
0<lambda<1 from the beginning to the end point.
|
||||
Define a curved edge that is parameterized for 0<lambda<1
|
||||
between the start and end point.
|
||||
|
||||
SourceFiles
|
||||
curvedEdge.C
|
||||
@ -62,6 +62,19 @@ protected:
|
||||
const label start_;
|
||||
const label end_;
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Return a complete knotList by adding the start/end points
|
||||
// to the given list
|
||||
static pointField fullKnotList
|
||||
(
|
||||
const pointField&,
|
||||
const label start,
|
||||
const label end,
|
||||
const pointField& otherKnots
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -136,23 +149,13 @@ public:
|
||||
// - -1: same edge, but different orientation
|
||||
inline int compare(const label start, const label end) const;
|
||||
|
||||
//- Return the position of a point on the curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
virtual vector position(const scalar) const = 0;
|
||||
//- Return the point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
virtual point position(const scalar) const = 0;
|
||||
|
||||
//- Return the length of the curve
|
||||
virtual scalar length() const = 0;
|
||||
|
||||
//- Return a complete knotList by adding the start/end points
|
||||
// to the given list
|
||||
static pointField knotlist
|
||||
(
|
||||
const pointField&,
|
||||
const label start,
|
||||
const label end,
|
||||
const pointField& otherknots
|
||||
);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
|
||||
@ -67,7 +67,4 @@ inline int Foam::curvedEdge::compare(const edge& e) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -55,14 +55,14 @@ class lineDivide
|
||||
// Private data
|
||||
|
||||
pointField points_;
|
||||
|
||||
scalarList divisions_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
// discretization and expansion ration
|
||||
//- Construct from components with discretization and expansion ratio
|
||||
lineDivide
|
||||
(
|
||||
const curvedEdge&,
|
||||
|
||||
@ -46,23 +46,19 @@ Foam::lineEdge::lineEdge
|
||||
const label end
|
||||
)
|
||||
:
|
||||
curvedEdge(points, start, end),
|
||||
startPoint_(points_[start_]),
|
||||
direction_(points_[end_] - points_[start_])
|
||||
curvedEdge(points, start, end)
|
||||
{}
|
||||
|
||||
|
||||
Foam::lineEdge::lineEdge(const pointField& points, Istream& is)
|
||||
:
|
||||
curvedEdge(points, is),
|
||||
startPoint_(points_[start_]),
|
||||
direction_(points_[end_] - points_[start_])
|
||||
curvedEdge(points, is)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::lineEdge::position(const scalar lambda) const
|
||||
Foam::point Foam::lineEdge::position(const scalar lambda) const
|
||||
{
|
||||
if (lambda < 0 || lambda > 1)
|
||||
{
|
||||
@ -71,13 +67,13 @@ Foam::vector Foam::lineEdge::position(const scalar lambda) const
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return startPoint_ + lambda*direction_;
|
||||
return points_[start_] + lambda * (points_[end_] - points_[start_]);
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::lineEdge::length() const
|
||||
{
|
||||
return mag(direction_);
|
||||
return mag(points_[end_] - points_[start_]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -52,14 +52,6 @@ class lineEdge
|
||||
:
|
||||
public curvedEdge
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Avoid repetitive calculation of the start point
|
||||
const vector startPoint_;
|
||||
|
||||
//- Avoid repetitive calculation of the direction (end - start)
|
||||
const vector direction_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -68,7 +60,6 @@ class lineEdge
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const lineEdge&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -83,16 +74,16 @@ public:
|
||||
lineEdge(const pointField&, Istream&);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~lineEdge(){}
|
||||
//- Destructor
|
||||
virtual ~lineEdge()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the position of a point on the curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
vector position(const scalar) const;
|
||||
//- Return the point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
point position(const scalar) const;
|
||||
|
||||
//- Return the length of the curve
|
||||
scalar length() const;
|
||||
|
||||
@ -40,18 +40,19 @@ void Foam::polyLine::calcDistances()
|
||||
{
|
||||
distances_[0] = 0.0;
|
||||
|
||||
for (label i=1; i<distances_.size(); i++)
|
||||
for (label i=1; i < distances_.size(); i++)
|
||||
{
|
||||
distances_[i] = distances_[i-1] +
|
||||
mag(controlPoints_[i] - controlPoints_[i-1]);
|
||||
}
|
||||
|
||||
// normalize
|
||||
// normalize on the interval 0-1
|
||||
lineLength_ = distances_[distances_.size()-1];
|
||||
for (label i=1; i<distances_.size(); i++)
|
||||
for (label i=1; i < distances_.size() - 1; i++)
|
||||
{
|
||||
distances_[i] /= lineLength_;
|
||||
}
|
||||
distances_[distances_.size()-1] = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -75,10 +76,15 @@ Foam::polyLine::polyLine(const pointField& ps)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::polyLine::position(const scalar lambda) const
|
||||
const Foam::pointField& Foam::polyLine::controlPoints() const
|
||||
{
|
||||
return controlPoints_;
|
||||
}
|
||||
|
||||
|
||||
Foam::point Foam::polyLine::position(const scalar lambda) const
|
||||
{
|
||||
// check range of lambda
|
||||
|
||||
if (lambda < 0 || lambda > 1)
|
||||
{
|
||||
FatalErrorIn("polyLine::position(const scalar)")
|
||||
@ -87,8 +93,7 @@ Foam::vector Foam::polyLine::position(const scalar lambda) const
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// Quick calc of endpoints
|
||||
|
||||
// check endpoints
|
||||
if (lambda < SMALL)
|
||||
{
|
||||
return controlPoints_[0];
|
||||
@ -99,25 +104,24 @@ Foam::vector Foam::polyLine::position(const scalar lambda) const
|
||||
}
|
||||
|
||||
|
||||
// search table of cumulative distance to find which linesegment we
|
||||
// are on
|
||||
// search table of cumulative distances to find which line-segment
|
||||
// we are on. Check the upper bound.
|
||||
|
||||
label i(0);
|
||||
do
|
||||
label i = 1;
|
||||
while (distances_[i] < lambda)
|
||||
{
|
||||
i++;
|
||||
} while (distances_[i] < lambda);
|
||||
}
|
||||
i--; // we now want the lower bound
|
||||
|
||||
i--; // we overshot!
|
||||
|
||||
// construct position vector
|
||||
scalar offsetDist =
|
||||
(lambda - distances_[i])
|
||||
/(distances_[i+1] - distances_[i]);
|
||||
|
||||
vector offsetV = controlPoints_[i+1] - controlPoints_[i];
|
||||
|
||||
return controlPoints_[i] + offsetDist*offsetV;
|
||||
// linear interpolation
|
||||
return
|
||||
(
|
||||
controlPoints_[i]
|
||||
+ ( controlPoints_[i+1] - controlPoints_[i] )
|
||||
* ( lambda - distances_[i] ) / ( distances_[i+1] - distances_[i] )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,8 @@ Class
|
||||
Foam::polyLine
|
||||
|
||||
Description
|
||||
Defines a curvedEdge in terms of a series of straight line segments.
|
||||
Define a series of control points, which can also be interpreted as a
|
||||
series of straight line segments.
|
||||
|
||||
This is the basic polyLine class which implements just the line
|
||||
(no topology - it is not derived from curvedEdge)
|
||||
@ -66,15 +67,20 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- The control points or ends of each segmen
|
||||
pointField controlPoints_;
|
||||
|
||||
//- The rational (0-1) cumulative distance for each control-point
|
||||
scalarList distances_;
|
||||
|
||||
//- The real line length
|
||||
scalar lineLength_;
|
||||
|
||||
// Protected member functions
|
||||
|
||||
//- Precalculate the rational cumulative distances and the line-length
|
||||
void calcDistances();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
@ -85,9 +91,12 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the position of a point on the curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
vector position(const scalar) const;
|
||||
//- Return const-access to the control-points
|
||||
const pointField& controlPoints() const;
|
||||
|
||||
//- Return the point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
point position(const scalar) const;
|
||||
|
||||
//- Return the length of the curve
|
||||
scalar length() const;
|
||||
|
||||
@ -44,24 +44,24 @@ Foam::polyLineEdge::polyLineEdge
|
||||
const pointField& ps,
|
||||
const label start,
|
||||
const label end,
|
||||
const pointField& otherpoints
|
||||
const pointField& otherPoints
|
||||
)
|
||||
:
|
||||
curvedEdge(ps, start, end),
|
||||
polyLine(knotlist(ps, start, end, otherpoints))
|
||||
polyLine(fullKnotList(ps, start_, end_, otherPoints))
|
||||
{}
|
||||
|
||||
|
||||
Foam::polyLineEdge::polyLineEdge(const pointField& ps, Istream& is)
|
||||
:
|
||||
curvedEdge(ps, is),
|
||||
polyLine(knotlist(ps, start_, end_, pointField(is)))
|
||||
polyLine(fullKnotList(ps, start_, end_, pointField(is)))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::polyLineEdge::position(const scalar lambda) const
|
||||
Foam::point Foam::polyLineEdge::position(const scalar lambda) const
|
||||
{
|
||||
return polyLine::position(lambda);
|
||||
}
|
||||
|
||||
@ -26,8 +26,7 @@ Class
|
||||
Foam::polyLineEdge
|
||||
|
||||
Description
|
||||
Defines a curvedEdge in terms of a series of straight line segments.
|
||||
This is the public face of polyLine
|
||||
A curvedEdge defined in terms of a series of straight line segments.
|
||||
|
||||
SourceFiles
|
||||
polyLineEdge.C
|
||||
@ -91,9 +90,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the position of a point on the curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
vector position(const scalar lambda) const;
|
||||
//- Return the point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
point position(const scalar lambda) const;
|
||||
|
||||
//- Return the length of the curve
|
||||
scalar length() const;
|
||||
|
||||
@ -56,7 +56,7 @@ Foam::pointField Foam::polySplineEdge::intervening
|
||||
{
|
||||
BSpline spl
|
||||
(
|
||||
knotlist(points_, start_, end_, otherknots),
|
||||
fullKnotList(points_, start_, end_, otherknots),
|
||||
fstend,
|
||||
sndend
|
||||
);
|
||||
@ -135,7 +135,7 @@ Foam::polySplineEdge::polySplineEdge
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::polySplineEdge::position(const scalar mu) const
|
||||
Foam::point Foam::polySplineEdge::position(const scalar mu) const
|
||||
{
|
||||
return polyLine::position(mu);
|
||||
}
|
||||
|
||||
@ -90,16 +90,16 @@ public:
|
||||
polySplineEdge(const pointField&, Istream&);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~polySplineEdge(){}
|
||||
//- Destructor
|
||||
virtual ~polySplineEdge()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the position of a point on the curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
vector position(const scalar mu) const;
|
||||
//- Return the point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
point position(const scalar mu) const;
|
||||
|
||||
//- Return the length of the curve
|
||||
scalar length() const;
|
||||
|
||||
@ -48,7 +48,7 @@ Foam::simpleSplineEdge::simpleSplineEdge
|
||||
)
|
||||
:
|
||||
curvedEdge(points, start, end),
|
||||
BSpline(knotlist(points, start, end, otherknots))
|
||||
BSpline(fullKnotList(points, start, end, otherknots))
|
||||
{}
|
||||
|
||||
|
||||
@ -63,20 +63,20 @@ Foam::simpleSplineEdge::simpleSplineEdge
|
||||
)
|
||||
:
|
||||
curvedEdge(points, start, end),
|
||||
BSpline(knotlist(points, start, end, otherknots), fstend, sndend)
|
||||
BSpline(fullKnotList(points, start, end, otherknots), fstend, sndend)
|
||||
{}
|
||||
|
||||
|
||||
Foam::simpleSplineEdge::simpleSplineEdge(const pointField& points, Istream& is)
|
||||
:
|
||||
curvedEdge(points, is),
|
||||
BSpline(knotlist(points, start_, end_, pointField(is)))
|
||||
BSpline(fullKnotList(points, start_, end_, pointField(is)))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::simpleSplineEdge::position(const scalar mu) const
|
||||
Foam::point Foam::simpleSplineEdge::position(const scalar mu) const
|
||||
{
|
||||
return BSpline::position(mu);
|
||||
}
|
||||
|
||||
@ -102,9 +102,9 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the position of a point on the simple spline curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
vector position(const scalar mu) const;
|
||||
//- Return the point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
point position(const scalar) const;
|
||||
|
||||
//- Return the length of the simple spline curve
|
||||
scalar length() const;
|
||||
|
||||
@ -72,9 +72,9 @@ Foam::spline::spline(const pointField& knotPoints)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vector Foam::spline::position(const scalar mu) const
|
||||
Foam::point Foam::spline::position(const scalar mu) const
|
||||
{
|
||||
vector loc(vector::zero);
|
||||
point loc(point::zero);
|
||||
|
||||
for (register label i=0; i < knots_.size(); i++)
|
||||
{
|
||||
|
||||
@ -81,6 +81,13 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the knot points in the spline
|
||||
const pointField& knotPoints() const
|
||||
{
|
||||
return knots_;
|
||||
}
|
||||
|
||||
|
||||
//- Return the number of knots in the spline
|
||||
label nKnots() const
|
||||
{
|
||||
@ -88,9 +95,9 @@ public:
|
||||
}
|
||||
|
||||
|
||||
//- Return the position of a point on the curve given by
|
||||
// the parameter 0 <= lambda <= 1
|
||||
vector position(const scalar) const;
|
||||
//- Return the point position corresponding to the curve parameter
|
||||
// 0 <= lambda <= 1
|
||||
point position(const scalar) const;
|
||||
|
||||
//- Return the length of the spline curve
|
||||
scalar length() const;
|
||||
|
||||
Reference in New Issue
Block a user