diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptorEdges.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptorEdges.C index 5fcf31f421..afc8fcd078 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptorEdges.C +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptorEdges.C @@ -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()); diff --git a/src/mesh/blockMesh/curvedEdges/BSpline.C b/src/mesh/blockMesh/curvedEdges/BSpline.C index 3e166f25cb..cd7ee90ca1 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline.C +++ b/src/mesh/blockMesh/curvedEdges/BSpline.C @@ -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))); } diff --git a/src/mesh/blockMesh/curvedEdges/BSpline.H b/src/mesh/blockMesh/curvedEdges/BSpline.H index ace98b4e21..5ba6423ea1 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline.H +++ b/src/mesh/blockMesh/curvedEdges/BSpline.H @@ -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; diff --git a/src/mesh/blockMesh/curvedEdges/arcEdge.C b/src/mesh/blockMesh/curvedEdges/arcEdge.C index afb62a8f8b..5718b731ad 100644 --- a/src/mesh/blockMesh/curvedEdges/arcEdge.C +++ b/src/mesh/blockMesh/curvedEdges/arcEdge.C @@ -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_; } diff --git a/src/mesh/blockMesh/curvedEdges/arcEdge.H b/src/mesh/blockMesh/curvedEdges/arcEdge.H index da96d150fc..1539916aaa 100644 --- a/src/mesh/blockMesh/curvedEdges/arcEdge.H +++ b/src/mesh/blockMesh/curvedEdges/arcEdge.H @@ -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; diff --git a/src/mesh/blockMesh/curvedEdges/curvedEdge.C b/src/mesh/blockMesh/curvedEdges/curvedEdge.C index 4b80a221dd..595a923475 100644 --- a/src/mesh/blockMesh/curvedEdges/curvedEdge.C +++ b/src/mesh/blockMesh/curvedEdges/curvedEdge.C @@ -108,27 +108,27 @@ Foam::autoPtr 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; } diff --git a/src/mesh/blockMesh/curvedEdges/curvedEdge.H b/src/mesh/blockMesh/curvedEdges/curvedEdge.H index 49ad047e45..629b833cb9 100644 --- a/src/mesh/blockMesh/curvedEdges/curvedEdge.H +++ b/src/mesh/blockMesh/curvedEdges/curvedEdge.H @@ -26,8 +26,8 @@ Class Foam::curvedEdge Description - Define a curved edge in space that is parameterised for - 0 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_]); } diff --git a/src/mesh/blockMesh/curvedEdges/lineEdge.H b/src/mesh/blockMesh/curvedEdges/lineEdge.H index a601830f7f..fdc8d035e6 100644 --- a/src/mesh/blockMesh/curvedEdges/lineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/lineEdge.H @@ -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; diff --git a/src/mesh/blockMesh/curvedEdges/polyLine.C b/src/mesh/blockMesh/curvedEdges/polyLine.C index e8872de6a2..739fd044f1 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLine.C +++ b/src/mesh/blockMesh/curvedEdges/polyLine.C @@ -40,18 +40,19 @@ void Foam::polyLine::calcDistances() { distances_[0] = 0.0; - for (label i=1; i 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] ) + ); } diff --git a/src/mesh/blockMesh/curvedEdges/polyLine.H b/src/mesh/blockMesh/curvedEdges/polyLine.H index 4ef97f3052..e549b8fb85 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLine.H +++ b/src/mesh/blockMesh/curvedEdges/polyLine.H @@ -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; diff --git a/src/mesh/blockMesh/curvedEdges/polyLineEdge.C b/src/mesh/blockMesh/curvedEdges/polyLineEdge.C index 89029d1af9..522c6abe48 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/polyLineEdge.C @@ -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); } diff --git a/src/mesh/blockMesh/curvedEdges/polyLineEdge.H b/src/mesh/blockMesh/curvedEdges/polyLineEdge.H index 532a91ad5d..2c79765a98 100644 --- a/src/mesh/blockMesh/curvedEdges/polyLineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/polyLineEdge.H @@ -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; diff --git a/src/mesh/blockMesh/curvedEdges/polySplineEdge.C b/src/mesh/blockMesh/curvedEdges/polySplineEdge.C index 8e4f0f90b3..94ef3feb70 100644 --- a/src/mesh/blockMesh/curvedEdges/polySplineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/polySplineEdge.C @@ -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); } diff --git a/src/mesh/blockMesh/curvedEdges/polySplineEdge.H b/src/mesh/blockMesh/curvedEdges/polySplineEdge.H index b133b9e45d..e352da96fc 100644 --- a/src/mesh/blockMesh/curvedEdges/polySplineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/polySplineEdge.H @@ -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; diff --git a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.C b/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.C index 3132a1f7ea..61b803f44b 100644 --- a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.C @@ -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); } diff --git a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H b/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H index 4c6df2a509..14a22adc09 100644 --- a/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H +++ b/src/mesh/blockMesh/curvedEdges/simpleSplineEdge.H @@ -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; diff --git a/src/mesh/blockMesh/curvedEdges/spline.C b/src/mesh/blockMesh/curvedEdges/spline.C index cddf6fa8ed..4f7ab8e195 100644 --- a/src/mesh/blockMesh/curvedEdges/spline.C +++ b/src/mesh/blockMesh/curvedEdges/spline.C @@ -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++) { diff --git a/src/mesh/blockMesh/curvedEdges/spline.H b/src/mesh/blockMesh/curvedEdges/spline.H index 74e73afdc6..1055690933 100644 --- a/src/mesh/blockMesh/curvedEdges/spline.H +++ b/src/mesh/blockMesh/curvedEdges/spline.H @@ -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;