Skip to content
Snippets Groups Projects
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
Branches
Tags
No related merge requests found
Showing
with 126 additions and 59 deletions
......@@ -51,9 +51,7 @@ class BSpline
:
public spline
{
// Private member functions
scalar remap(const scalar&);
// Private Member Functions
pointField findKnots
(
......@@ -62,6 +60,12 @@ class BSpline
const vector& sndend = vector::zero
);
//- Disallow default bitwise copy construct
BSpline(const BSpline&);
//- Disallow default bitwise assignment
void operator=(const BSpline&);
public:
......
......@@ -110,12 +110,12 @@ Foam::arcEdge::arcEdge
const pointField& points,
const label start,
const label end,
const vector& P2
const vector& pMid
)
:
curvedEdge(points, start, end),
p1_(points_[start_]),
p2_(P2),
p2_(pMid),
p3_(points_[end_]),
cs_(calcAngle())
{}
......
......@@ -61,6 +61,14 @@ class arcEdge
cylindricalCS calcAngle();
// Private Member Functions
//- Disallow default bitwise copy construct
arcEdge(const arcEdge&);
//- Disallow default bitwise assignment
void operator=(const arcEdge&);
public:
//- Runtime type information
......@@ -74,7 +82,7 @@ public:
(
const pointField& points,
const label start, const label end,
const vector&
const vector& pMid
);
//- Construct from Istream setting pointsList
......
......@@ -34,42 +34,38 @@ License
Foam::lineDivide::lineDivide
(
const curvedEdge& bc,
const label n,
const scalar xratio
const curvedEdge& cedge,
const label ndiv,
const scalar& xratio
)
:
points_(n + 1),
divisions_(n + 1),
noPoints_(n)
points_(ndiv + 1),
divisions_(ndiv + 1)
{
scalar np(n);
scalar lambda(0.0);
divisions_[0] = 0.0;
divisions_[ndiv] = 1.0;
// calculate the spacing
if (xratio == 1.0)
{
const scalar y(1.0/np);
for (label i=0; i <= noPoints_; i++)
for (label i=1; i < ndiv; i++)
{
lambda = scalar(i)/np;
points_[i] = bc.position(lambda);
divisions_[i] = y*i;
divisions_[i] = scalar(i)/ndiv;
}
}
else
{
points_[0] = bc.position(0.0);
divisions_[0] = 0.0;
scalar xrpower = 1.0;
for (label i=1; i <= noPoints_; i++)
for (label i=1; i < ndiv; i++)
{
lambda = (1.0 - pow(xratio, i))/(1.0 - pow(xratio, np));
points_[i] = bc.position(lambda);
divisions_[i] = lambda;
xrpower *= xratio;
divisions_[i] = (1.0 - pow(xratio, i))/(1.0 - pow(xratio, ndiv));
}
}
// calculate the points
for (label i=0; i <= ndiv; i++)
{
points_[i] = cedge.position(divisions_[i]);
}
}
......
......@@ -56,15 +56,19 @@ class lineDivide
pointField points_;
scalarList divisions_;
label noPoints_;
public:
// Constructors
//- 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
......
......@@ -60,6 +60,14 @@ class lineEdge
//- Avoid repetitive calculation of the direction (end - start)
const vector direction_;
// Private Member Functions
//- Disallow default bitwise copy construct
lineEdge(const lineEdge&);
//- Disallow default bitwise assignment
void operator=(const lineEdge&);
public:
......
......@@ -34,35 +34,42 @@ License
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] =
mag(controlPoints_[i] - controlPoints_[i-1])
+ distances_[i-1];
distances_[0] = 0.0;
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_;
}
}
lineLength_ = distances_[distances_.size()-1];
for (label i=1; i<distances_.size(); i++)
else
{
distances_[i] /= lineLength_;
lineLength_ = 0.0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::polyLine::polyLine(const pointField& ps)
:
controlPoints_(ps),
distances_(ps.size())
distances_(0),
lineLength_(0.0)
{
if (ps.size())
{
calcDistances();
}
calcDistances();
}
......
......@@ -54,6 +54,13 @@ namespace Foam
class polyLine
{
// Private Member Functions
//- Disallow default bitwise copy construct
polyLine(const polyLine&);
//- Disallow default bitwise assignment
void operator=(const polyLine&);
protected:
......
......@@ -54,6 +54,14 @@ class polyLineEdge
public curvedEdge,
public polyLine
{
// Private Member Functions
//- Disallow default bitwise copy construct
polyLineEdge(const polyLineEdge&);
//- Disallow default bitwise assignment
void operator=(const polyLineEdge&);
public:
......
......@@ -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 * * * * * * * * * * * //
// 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
// are retained as a subset of the polyLine points.
......@@ -50,14 +63,14 @@ namespace Foam
Foam::pointField Foam::polySplineEdge::intervening
(
const pointField& otherknots,
const label nbetweenKnots,
const label nBetweenKnots,
const vector& fstend,
const vector& 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);
......@@ -65,7 +78,7 @@ Foam::pointField Foam::polySplineEdge::intervening
scalar init = 1.0/(N - 1);
scalar interval = (N - scalar(3))/N;
interval /= otherknots.size() + 1;
interval /= nbetweenKnots + 1;
interval /= nBetweenKnots + 1;
ans[0] = points_[start_];
......@@ -123,11 +136,16 @@ Foam::polySplineEdge::polySplineEdge
vector sndend(is);
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());
controlPoints_ = intervening(otherKnots_, nInterKnots, fstend, sndend);
calcDistances();
Info<< polyLine::controlPoints_ << endl;
// Info<< "polyLine[" << start_ << " " << end_
// << "] controlPoints " << controlPoints_ << endl;
}
......
......@@ -68,12 +68,6 @@ class polySplineEdge
const vector&
);
label nsize(const label otherKnotsSize, const label nBetweenKnots)
{
return otherKnotsSize*(1 + nBetweenKnots) + nBetweenKnots + 2;
}
public:
//- Runtime type information
......
......@@ -53,6 +53,14 @@ class simpleSplineEdge
public curvedEdge,
public BSpline
{
// Private Member Functions
//- Disallow default bitwise copy construct
simpleSplineEdge(const simpleSplineEdge&);
//- Disallow default bitwise assignment
void operator=(const simpleSplineEdge&);
public:
......
......@@ -56,12 +56,17 @@ class spline
//- The knots defining the spline
pointField knots_;
// Private member functions
// Private Member Functions
//- Blending function for constructing spline
scalar B(const scalar&) const;
//- Disallow default bitwise copy construct
spline(const spline&);
//- Disallow default bitwise assignment
void operator=(const spline&);
public:
......
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