Commit 33156d98 authored by Mark Olesen's avatar Mark Olesen
Browse files

blockMesh/curvedEdges misc. cleanup

- also sifted through code to find out why polySplineEdge is going wrong

  It doesn't seem to be a virtual/non-virtual issue, but appears to
  be an issue with how BSpline is solving for the new points.
parent e003b520
...@@ -51,9 +51,7 @@ class BSpline ...@@ -51,9 +51,7 @@ class BSpline
: :
public spline public spline
{ {
// Private member functions // Private Member Functions
scalar remap(const scalar&);
pointField findKnots pointField findKnots
( (
...@@ -62,6 +60,12 @@ class BSpline ...@@ -62,6 +60,12 @@ class BSpline
const vector& sndend = vector::zero const vector& sndend = vector::zero
); );
//- Disallow default bitwise copy construct
BSpline(const BSpline&);
//- Disallow default bitwise assignment
void operator=(const BSpline&);
public: public:
......
...@@ -110,12 +110,12 @@ Foam::arcEdge::arcEdge ...@@ -110,12 +110,12 @@ Foam::arcEdge::arcEdge
const pointField& points, const pointField& points,
const label start, const label start,
const label end, const label end,
const vector& P2 const vector& pMid
) )
: :
curvedEdge(points, start, end), curvedEdge(points, start, end),
p1_(points_[start_]), p1_(points_[start_]),
p2_(P2), p2_(pMid),
p3_(points_[end_]), p3_(points_[end_]),
cs_(calcAngle()) cs_(calcAngle())
{} {}
......
...@@ -61,6 +61,14 @@ class arcEdge ...@@ -61,6 +61,14 @@ class arcEdge
cylindricalCS calcAngle(); cylindricalCS calcAngle();
// Private Member Functions
//- Disallow default bitwise copy construct
arcEdge(const arcEdge&);
//- Disallow default bitwise assignment
void operator=(const arcEdge&);
public: public:
//- Runtime type information //- Runtime type information
...@@ -74,7 +82,7 @@ public: ...@@ -74,7 +82,7 @@ public:
( (
const pointField& points, const pointField& points,
const label start, const label end, const label start, const label end,
const vector& const vector& pMid
); );
//- Construct from Istream setting pointsList //- Construct from Istream setting pointsList
......
...@@ -34,42 +34,38 @@ License ...@@ -34,42 +34,38 @@ License
Foam::lineDivide::lineDivide Foam::lineDivide::lineDivide
( (
const curvedEdge& bc, const curvedEdge& cedge,
const label n, const label ndiv,
const scalar xratio const scalar& xratio
) )
: :
points_(n + 1), points_(ndiv + 1),
divisions_(n + 1), divisions_(ndiv + 1)
noPoints_(n)
{ {
scalar np(n); divisions_[0] = 0.0;
scalar lambda(0.0); divisions_[ndiv] = 1.0;
// calculate the spacing
if (xratio == 1.0) if (xratio == 1.0)
{ {
const scalar y(1.0/np); for (label i=1; i < ndiv; i++)
for (label i=0; i <= noPoints_; i++)
{ {
lambda = scalar(i)/np; divisions_[i] = scalar(i)/ndiv;
points_[i] = bc.position(lambda);
divisions_[i] = y*i;
} }
} }
else else
{ {
points_[0] = bc.position(0.0); for (label i=1; i < ndiv; i++)
divisions_[0] = 0.0;
scalar xrpower = 1.0;
for (label i=1; i <= noPoints_; i++)
{ {
lambda = (1.0 - pow(xratio, i))/(1.0 - pow(xratio, np)); divisions_[i] = (1.0 - pow(xratio, i))/(1.0 - pow(xratio, ndiv));
points_[i] = bc.position(lambda);
divisions_[i] = lambda;
xrpower *= xratio;
} }
} }
// calculate the points
for (label i=0; i <= ndiv; i++)
{
points_[i] = cedge.position(divisions_[i]);
}
} }
......
...@@ -56,15 +56,19 @@ class lineDivide ...@@ -56,15 +56,19 @@ class lineDivide
pointField points_; pointField points_;
scalarList divisions_; scalarList divisions_;
label noPoints_;
public: public:
// Constructors // Constructors
//- Construct from components //- Construct from components
lineDivide(const curvedEdge&, const label, const scalar = 1.0); // discretization and expansion ration
lineDivide
(
const curvedEdge&,
const label ndiv,
const scalar& xratio = 1.0
);
// Member Functions // Member Functions
......
...@@ -60,6 +60,14 @@ class lineEdge ...@@ -60,6 +60,14 @@ class lineEdge
//- Avoid repetitive calculation of the direction (end - start) //- Avoid repetitive calculation of the direction (end - start)
const vector direction_; const vector direction_;
// Private Member Functions
//- Disallow default bitwise copy construct
lineEdge(const lineEdge&);
//- Disallow default bitwise assignment
void operator=(const lineEdge&);
public: public:
......
...@@ -34,35 +34,42 @@ License ...@@ -34,35 +34,42 @@ License
void Foam::polyLine::calcDistances() void Foam::polyLine::calcDistances()
{ {
distances_[0] = 0.0; distances_.setSize(controlPoints_.size());
for (label i=1; i<distances_.size(); i++) if (distances_.size())
{ {
distances_[i] = distances_[0] = 0.0;
mag(controlPoints_[i] - controlPoints_[i-1])
+ distances_[i-1]; for (label i=1; i<distances_.size(); i++)
{
distances_[i] = distances_[i-1] +
mag(controlPoints_[i] - controlPoints_[i-1]);
}
// normalize
lineLength_ = distances_[distances_.size()-1];
for (label i=1; i<distances_.size(); i++)
{
distances_[i] /= lineLength_;
}
} }
else
lineLength_ = distances_[distances_.size()-1];
for (label i=1; i<distances_.size(); i++)
{ {
distances_[i] /= lineLength_; lineLength_ = 0.0;
} }
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::polyLine::polyLine(const pointField& ps) Foam::polyLine::polyLine(const pointField& ps)
: :
controlPoints_(ps), controlPoints_(ps),
distances_(ps.size()) distances_(0),
lineLength_(0.0)
{ {
if (ps.size()) calcDistances();
{
calcDistances();
}
} }
......
...@@ -54,6 +54,13 @@ namespace Foam ...@@ -54,6 +54,13 @@ namespace Foam
class polyLine class polyLine
{ {
// Private Member Functions
//- Disallow default bitwise copy construct
polyLine(const polyLine&);
//- Disallow default bitwise assignment
void operator=(const polyLine&);
protected: protected:
......
...@@ -54,6 +54,14 @@ class polyLineEdge ...@@ -54,6 +54,14 @@ class polyLineEdge
public curvedEdge, public curvedEdge,
public polyLine public polyLine
{ {
// Private Member Functions
//- Disallow default bitwise copy construct
polyLineEdge(const polyLineEdge&);
//- Disallow default bitwise assignment
void operator=(const polyLineEdge&);
public: public:
......
...@@ -37,10 +37,23 @@ namespace Foam ...@@ -37,10 +37,23 @@ namespace Foam
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//! @cond fileScope
inline label nsize(const label otherKnotsSize, const label nBetweenKnots)
{
return otherKnotsSize*(1 + nBetweenKnots) + nBetweenKnots + 2;
}
//! @endcond fileScope
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// intervening : returns a list of the points making up the polyLineEdge // intervening : returns a list of the points making up the polyLineEdge
// which describes the spline. nbetweenKnots is the number of points // which describes the spline. nBetweenKnots is the number of points
// placed between each knot : this ensures that the knot locations // placed between each knot : this ensures that the knot locations
// are retained as a subset of the polyLine points. // are retained as a subset of the polyLine points.
...@@ -50,14 +63,14 @@ namespace Foam ...@@ -50,14 +63,14 @@ namespace Foam
Foam::pointField Foam::polySplineEdge::intervening Foam::pointField Foam::polySplineEdge::intervening
( (
const pointField& otherknots, const pointField& otherknots,
const label nbetweenKnots, const label nBetweenKnots,
const vector& fstend, const vector& fstend,
const vector& sndend const vector& sndend
) )
{ {
BSpline spl(knotlist(points_, start_, end_, otherknots), fstend, sndend); BSpline spl(knotlist(points_, start_, end_, otherknots), fstend, sndend);
label nSize(nsize(otherknots.size(), nbetweenKnots)); label nSize(nsize(otherknots.size(), nBetweenKnots));
pointField ans(nSize); pointField ans(nSize);
...@@ -65,7 +78,7 @@ Foam::pointField Foam::polySplineEdge::intervening ...@@ -65,7 +78,7 @@ Foam::pointField Foam::polySplineEdge::intervening
scalar init = 1.0/(N - 1); scalar init = 1.0/(N - 1);
scalar interval = (N - scalar(3))/N; scalar interval = (N - scalar(3))/N;
interval /= otherknots.size() + 1; interval /= otherknots.size() + 1;
interval /= nbetweenKnots + 1; interval /= nBetweenKnots + 1;
ans[0] = points_[start_]; ans[0] = points_[start_];
...@@ -123,11 +136,16 @@ Foam::polySplineEdge::polySplineEdge ...@@ -123,11 +136,16 @@ Foam::polySplineEdge::polySplineEdge
vector sndend(is); vector sndend(is);
controlPoints_.setSize(nsize(otherKnots_.size(), nInterKnots)); controlPoints_.setSize(nsize(otherKnots_.size(), nInterKnots));
// why does this need to be here (to avoid a crash)?
// 'intervening' uses BSpline to solve the new points
// it seems to be going badly there
distances_.setSize(controlPoints_.size()); distances_.setSize(controlPoints_.size());
controlPoints_ = intervening(otherKnots_, nInterKnots, fstend, sndend); controlPoints_ = intervening(otherKnots_, nInterKnots, fstend, sndend);
calcDistances(); calcDistances();
Info<< polyLine::controlPoints_ << endl;
// Info<< "polyLine[" << start_ << " " << end_
// << "] controlPoints " << controlPoints_ << endl;
} }
......
...@@ -68,12 +68,6 @@ class polySplineEdge ...@@ -68,12 +68,6 @@ class polySplineEdge
const vector& const vector&
); );
label nsize(const label otherKnotsSize, const label nBetweenKnots)
{
return otherKnotsSize*(1 + nBetweenKnots) + nBetweenKnots + 2;
}
public: public:
//- Runtime type information //- Runtime type information
......
...@@ -53,6 +53,14 @@ class simpleSplineEdge ...@@ -53,6 +53,14 @@ class simpleSplineEdge
public curvedEdge, public curvedEdge,
public BSpline public BSpline
{ {
// Private Member Functions
//- Disallow default bitwise copy construct
simpleSplineEdge(const simpleSplineEdge&);
//- Disallow default bitwise assignment
void operator=(const simpleSplineEdge&);
public: public:
......
...@@ -56,12 +56,17 @@ class spline ...@@ -56,12 +56,17 @@ class spline
//- The knots defining the spline //- The knots defining the spline
pointField knots_; pointField knots_;
// Private Member Functions
// Private member functions
//- Blending function for constructing spline //- Blending function for constructing spline
scalar B(const scalar&) const; scalar B(const scalar&) const;
//- Disallow default bitwise copy construct
spline(const spline&);
//- Disallow default bitwise assignment
void operator=(const spline&);
public: public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment