mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: consistency improvement for edge/line
- added line::last() for consistency with edge::last() - adjusted unitVec() to return Zero for small vectors. Consistent with VectorSpace normalised() and vector::normalise()
This commit is contained in:
@ -421,10 +421,10 @@ inline Foam::vector Foam::edge::unitVec(const UList<point>& pts) const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Foam::vector v = pts[second()] - pts[first()];
|
const vector v = (pts[second()] - pts[first()]);
|
||||||
v /= ::Foam::mag(v) + VSMALL;
|
const scalar s(Foam::mag(v));
|
||||||
|
|
||||||
return v;
|
return s < ROOTVSMALL ? Zero : v/s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -98,20 +98,23 @@ public:
|
|||||||
inline line(Istream&);
|
inline line(Istream&);
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return first point
|
//- Return first point
|
||||||
inline PointRef first() const;
|
inline PointRef first() const;
|
||||||
|
|
||||||
//- Return second point
|
//- Return second (last) point
|
||||||
inline PointRef second() const;
|
inline PointRef second() const;
|
||||||
|
|
||||||
|
//- Return last (second) point
|
||||||
|
inline PointRef last() const;
|
||||||
|
|
||||||
//- Return first point
|
//- Return first point
|
||||||
inline PointRef start() const;
|
inline PointRef start() const;
|
||||||
|
|
||||||
//- Return second point
|
//- Return second (last) point
|
||||||
inline PointRef end() const;
|
inline PointRef end() const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -23,6 +23,7 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "zero.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -70,6 +71,13 @@ inline PointRef Foam::line<Point, PointRef>::second() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Point, class PointRef>
|
||||||
|
inline PointRef Foam::line<Point, PointRef>::last() const
|
||||||
|
{
|
||||||
|
return b_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Point, class PointRef>
|
template<class Point, class PointRef>
|
||||||
inline PointRef Foam::line<Point, PointRef>::start() const
|
inline PointRef Foam::line<Point, PointRef>::start() const
|
||||||
{
|
{
|
||||||
@ -107,10 +115,10 @@ inline Point Foam::line<Point, PointRef>::vec() const
|
|||||||
template<class Point, class PointRef>
|
template<class Point, class PointRef>
|
||||||
inline Point Foam::line<Point, PointRef>::unitVec() const
|
inline Point Foam::line<Point, PointRef>::unitVec() const
|
||||||
{
|
{
|
||||||
Point v = b_ - a_;
|
const Point v = (b_ - a_);
|
||||||
v /= ::Foam::mag(v) + VSMALL;
|
const scalar s(::Foam::mag(v));
|
||||||
|
|
||||||
return v;
|
return s < ROOTVSMALL ? Zero : v/s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user