ENH: additional constructors for triangle and triPoints

STYLE: use Foam::zero{} in expression parsers
This commit is contained in:
Mark Olesen 2024-02-02 15:26:33 +01:00
parent 19a6241e08
commit fcf090410a
11 changed files with 70 additions and 23 deletions

View File

@ -579,8 +579,8 @@ inline bool CGAL::indexedCell<Gt, Cb>::potentialCoplanarCell() const
if (nMasters == 2 && nSlaves == 2) if (nMasters == 2 && nSlaves == 2)
{ {
Foam::vector vp0(Foam::Zero); Foam::vector vp0(Foam::zero{});
Foam::vector vp1(Foam::Zero); Foam::vector vp1(Foam::zero{});
if if
( (

View File

@ -81,7 +81,7 @@ Foam::CompactListList<T> Foam::CompactListList<T>::pack_impl
if (len) if (len)
{ {
newOffsets.resize(len+1, Zero); newOffsets.resize(len+1, Foam::zero{});
for (label i = 0; i < len; ++i) for (label i = 0; i < len; ++i)
{ {

View File

@ -89,7 +89,7 @@ inline Foam::CompactListList<T>::CompactListList
const label nVals const label nVals
) )
: :
offsets_(mRows+1, Zero), offsets_(mRows+1, Foam::zero{}),
values_(nVals) values_(nVals)
{ {
// Optionally: enforceSizeSanity(); // Optionally: enforceSizeSanity();
@ -104,8 +104,8 @@ inline Foam::CompactListList<T>::CompactListList
const Foam::zero const Foam::zero
) )
: :
offsets_(mRows+1, Zero), offsets_(mRows+1, Foam::zero{}),
values_(nVals, Zero) values_(nVals, Foam::zero{})
{ {
// Optionally: enforceSizeSanity(); // Optionally: enforceSizeSanity();
} }
@ -119,7 +119,7 @@ inline Foam::CompactListList<T>::CompactListList
const T& val const T& val
) )
: :
offsets_(mRows+1, Zero), offsets_(mRows+1, Foam::zero{}),
values_(nVals, val) values_(nVals, val)
{ {
// Optionally: enforceSizeSanity(); // Optionally: enforceSizeSanity();
@ -378,7 +378,7 @@ inline void Foam::CompactListList<T>::resize
} }
else else
{ {
offsets_.resize(mRows+1, Zero); offsets_.resize(mRows+1, Foam::zero{});
values_.resize(nVals); values_.resize(nVals);
} }
} }
@ -399,7 +399,7 @@ inline void Foam::CompactListList<T>::resize_nocopy
} }
else else
{ {
offsets_.resize(mRows+1, Zero); offsets_.resize(mRows+1, Foam::zero{});
values_.resize_nocopy(nVals); values_.resize_nocopy(nVals);
} }
} }
@ -421,7 +421,7 @@ inline void Foam::CompactListList<T>::resize
} }
else else
{ {
offsets_.resize(mRows+1, Zero); offsets_.resize(mRows+1, Foam::zero{});
values_.resize(nVals, val); values_.resize(nVals, val);
} }
} }

View File

@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -163,7 +163,7 @@ operator_precedence()
svalue (lhs) ::= NUMBER (tok) . { lhs = (tok).scalarValue; } // scanToken svalue (lhs) ::= NUMBER (tok) . { lhs = (tok).scalarValue; } // scanToken
svalue (lhs) ::= ZERO . { lhs = Foam::Zero; } svalue (lhs) ::= ZERO . { lhs = Foam::zero{}; }
svalue (lhs) ::= PI LPAREN RPAREN . { lhs = Foam::constant::mathematical::pi; } svalue (lhs) ::= PI LPAREN RPAREN . { lhs = Foam::constant::mathematical::pi; }
svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); } svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); }
svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); } svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); }

View File

@ -395,7 +395,7 @@ public:
// Face splitting utilities // Face splitting utilities
//- Number of triangles after splitting //- Number of triangles after splitting
inline label nTriangles() const; inline label nTriangles() const noexcept;
//- Number of triangles after splitting //- Number of triangles after splitting
label nTriangles(const UList<point>& unused) const; label nTriangles(const UList<point>& unused) const;

View File

@ -199,9 +199,9 @@ inline Foam::label Foam::face::prevLabel(const label i) const
} }
inline Foam::label Foam::face::nTriangles() const inline Foam::label Foam::face::nTriangles() const noexcept
{ {
return size() - 2; return labelList::size() - 2;
} }

View File

@ -93,7 +93,7 @@ public:
//- Construct from an initializer list of three vertex labels //- Construct from an initializer list of three vertex labels
inline explicit triFace(std::initializer_list<label> list); inline explicit triFace(std::initializer_list<label> list);
//- Copy construct from a list of three vertex labels. //- Copy construct from a list of three vertex labels.
inline explicit triFace(const labelUList& list); inline explicit triFace(const labelUList& list);
//- Copy construct from a subset of vertex labels //- Copy construct from a subset of vertex labels

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -110,6 +110,15 @@ public:
const FixedList<label, 3>& indices const FixedList<label, 3>& indices
); );
//- Copy construct from subset of points
inline triPoints
(
const UList<point>& points,
const label p0,
const label p1,
const label p2
);
// Member Functions // Member Functions
@ -275,7 +284,7 @@ public:
//- Construct from three points //- Construct from three points
inline triangle(const FixedList<Point, 3>& pts); inline triangle(const FixedList<Point, 3>& pts);
//- Construct from three points in the list of points //- Construct from three points out of the list of points
// The indices could be from triFace etc. // The indices could be from triFace etc.
inline triangle inline triangle
( (
@ -283,6 +292,15 @@ public:
const FixedList<label, 3>& indices const FixedList<label, 3>& indices
); );
//- Construct from three points out of the list of points
inline triangle
(
const UList<Point>& points,
const label p0,
const label p1,
const label p2
);
//- Construct from Istream //- Construct from Istream
inline explicit triangle(Istream& is); inline explicit triangle(Istream& is);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2023 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -69,6 +69,20 @@ inline Foam::triPoints::triPoints
{} {}
inline Foam::triPoints::triPoints
(
const UList<point>& points,
const label p0,
const label p1,
const label p2
)
{
a() = points[p0];
b() = points[p1];
c() = points[p2];
}
template<class Point, class PointRef> template<class Point, class PointRef>
inline Foam::triangle<Point, PointRef>::triangle inline Foam::triangle<Point, PointRef>::triangle
( (
@ -108,6 +122,21 @@ inline Foam::triangle<Point, PointRef>::triangle
{} {}
template<class Point, class PointRef>
inline Foam::triangle<Point, PointRef>::triangle
(
const UList<Point>& points,
const label p0,
const label p1,
const label p2
)
:
a_(points[p0]),
b_(points[p1]),
c_(points[p2])
{}
template<class Point, class PointRef> template<class Point, class PointRef>
inline Foam::triangle<Point, PointRef>::triangle(Istream& is) inline Foam::triangle<Point, PointRef>::triangle(Istream& is)
{ {

View File

@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -129,7 +129,7 @@ identifier (lhs) ::= IDENTIFIER (tok) .
%type svalue { Foam::scalar } %type svalue { Foam::scalar }
svalue (lhs) ::= NUMBER (tok) . { lhs = (tok).scalarValue; } // scanToken svalue (lhs) ::= NUMBER (tok) . { lhs = (tok).scalarValue; } // scanToken
svalue (lhs) ::= ZERO . { lhs = Foam::Zero; } svalue (lhs) ::= ZERO . { lhs = Foam::zero{}; }
svalue (lhs) ::= PI LPAREN RPAREN . { lhs = Foam::constant::mathematical::pi; } svalue (lhs) ::= PI LPAREN RPAREN . { lhs = Foam::constant::mathematical::pi; }
svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); } svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); }
svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); } svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); }

View File

@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -170,7 +170,7 @@ identifier (lhs) ::= IDENTIFIER (tok) .
%type svalue { Foam::scalar } %type svalue { Foam::scalar }
svalue (lhs) ::= NUMBER (tok) . { lhs = (tok).scalarValue; } // scanToken svalue (lhs) ::= NUMBER (tok) . { lhs = (tok).scalarValue; } // scanToken
svalue (lhs) ::= ZERO . { lhs = Foam::Zero; } svalue (lhs) ::= ZERO . { lhs = Foam::zero{}; }
svalue (lhs) ::= PI LPAREN RPAREN . { lhs = Foam::constant::mathematical::pi; } svalue (lhs) ::= PI LPAREN RPAREN . { lhs = Foam::constant::mathematical::pi; }
svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); } svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); }
svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); } svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); }