ENH: add FixedList templated get<unsigned>() methods
- provides fast compile-time indexing for FixedList (invalid indices trigger a compiler error). This enables noexcept access, which can propagate into various other uses (eg, triFace, triPoints, ...) ENH: add triangle edge vectors
This commit is contained in:
parent
c7e6ae30bf
commit
d3e285b48b
@ -189,6 +189,12 @@ int main(int argc, char *argv[])
|
|||||||
<< " hash:" << FixedList<label, 4>::hasher()(list1) << nl
|
<< " hash:" << FixedList<label, 4>::hasher()(list1) << nl
|
||||||
<< " hash:" << Hash<FixedList<label, 4>>()(list1) << nl;
|
<< " hash:" << Hash<FixedList<label, 4>>()(list1) << nl;
|
||||||
|
|
||||||
|
Info<< "get<0>: " << list1.get<0>() << nl;
|
||||||
|
Info<< "get<1>: " << list1.get<1>() << nl;
|
||||||
|
Info<< "get<2>: " << list1.get<2>() << nl;
|
||||||
|
Info<< "get<3>: " << list1.get<3>() << nl;
|
||||||
|
// Will not compile: Info<< "get<4>: " << list1.get<4>() << nl;
|
||||||
|
|
||||||
label a[4] = {0, 1, 2, 3};
|
label a[4] = {0, 1, 2, 3};
|
||||||
FixedList<label, 4> list2(a);
|
FixedList<label, 4> list2(a);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -43,7 +43,7 @@ void print(const boolVector& v)
|
|||||||
<< " any:" << Switch::name(v.any())
|
<< " any:" << Switch::name(v.any())
|
||||||
<< " all:" << Switch::name(v.all())
|
<< " all:" << Switch::name(v.all())
|
||||||
<< " none:" << Switch::name(v.none())
|
<< " none:" << Switch::name(v.none())
|
||||||
<< " count:" << v.count() << nl;
|
<< " on:" << v.count() << " off:" << v.count(false) << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|
||||||
{
|
{
|
||||||
boolVector vec{1, 0, 1};
|
boolVector vec(1, 0, 1);
|
||||||
print(vec);
|
print(vec);
|
||||||
|
|
||||||
vec.flip();
|
vec.flip();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -33,6 +33,7 @@ Description
|
|||||||
|
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "labelledTri.H"
|
#include "labelledTri.H"
|
||||||
|
#include "edge.H"
|
||||||
#include "faceList.H"
|
#include "faceList.H"
|
||||||
#include "triFaceList.H"
|
#include "triFaceList.H"
|
||||||
#include "pointList.H"
|
#include "pointList.H"
|
||||||
@ -131,10 +132,25 @@ int main(int argc, char *argv[])
|
|||||||
testSign(f1, points2, testPoints);
|
testSign(f1, points2, testPoints);
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|
||||||
triFace t1({1, 2, 3});
|
// Initializer list
|
||||||
|
// triFace t1({1, 2, 3});
|
||||||
|
|
||||||
|
// Component-wise
|
||||||
|
{
|
||||||
|
edge e1(3, 2, 1); // Inadvertent sort!!!
|
||||||
|
Info<< "edge:" << e1 << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Component-wise
|
||||||
|
triFace t1(1, 2, 3);
|
||||||
Info<< "triFace:"; faceInfo(t1, points1); Info << nl;
|
Info<< "triFace:"; faceInfo(t1, points1); Info << nl;
|
||||||
testSign(t1, points1, testPoints);
|
testSign(t1, points1, testPoints);
|
||||||
|
|
||||||
|
{
|
||||||
|
scalarField fld({0, 20, 20, 30});
|
||||||
|
Info<< "avg:" << t1.average(pointField::null(), fld) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "triFace:"; faceInfo(t1, points2); Info << nl;
|
Info<< "triFace:"; faceInfo(t1, points2); Info << nl;
|
||||||
testSign(t1, points2, testPoints);
|
testSign(t1, points2, testPoints);
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "argList.H"
|
||||||
#include "point.H"
|
#include "point.H"
|
||||||
#include "triangle.H"
|
#include "triangle.H"
|
||||||
#include "tetrahedron.H"
|
#include "tetrahedron.H"
|
||||||
@ -5,7 +6,7 @@
|
|||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
int main()
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
triangle<point, point> tri
|
triangle<point, point> tri
|
||||||
(
|
(
|
||||||
@ -14,6 +15,12 @@ int main()
|
|||||||
vector(1, 1, 0)
|
vector(1, 1, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Info<< "triangle: " << tri << nl
|
||||||
|
<< " vecA: " << tri.vecA() << nl
|
||||||
|
<< " vecB: " << tri.vecB() << nl
|
||||||
|
<< " vecC: " << tri.vecC() << nl
|
||||||
|
<< endl;
|
||||||
|
|
||||||
Info<< "tri circumCentre = " << tri.circumCentre() << endl;
|
Info<< "tri circumCentre = " << tri.circumCentre() << endl;
|
||||||
Info<< "tri circumRadius = " << tri.circumRadius() << endl;
|
Info<< "tri circumRadius = " << tri.circumRadius() << endl;
|
||||||
|
|
||||||
@ -28,6 +35,8 @@ int main()
|
|||||||
Info<< "tet circumCentre = " << tet.circumCentre() << endl;
|
Info<< "tet circumCentre = " << tet.circumCentre() << endl;
|
||||||
Info<< "tet circumRadius = " << tet.circumRadius() << endl;
|
Info<< "tet circumRadius = " << tet.circumRadius() << endl;
|
||||||
|
|
||||||
|
InfoErr<< "Enter four points: " << endl;
|
||||||
|
|
||||||
vector a(Sin);
|
vector a(Sin);
|
||||||
vector b(Sin);
|
vector b(Sin);
|
||||||
vector c(Sin);
|
vector c(Sin);
|
||||||
@ -36,5 +45,6 @@ int main()
|
|||||||
Info<< "tet circumRadius = "
|
Info<< "tet circumRadius = "
|
||||||
<< tetrahedron<point, point>(a, b, c, d).circumRadius() << endl;
|
<< tetrahedron<point, point>(a, b, c, d).circumRadius() << endl;
|
||||||
|
|
||||||
|
Info<< "\nEnd\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -216,6 +216,22 @@ public:
|
|||||||
// \note Only meaningful for contiguous data
|
// \note Only meaningful for contiguous data
|
||||||
inline char* data_bytes() noexcept;
|
inline char* data_bytes() noexcept;
|
||||||
|
|
||||||
|
//- Number of contiguous bytes for the list data,
|
||||||
|
// \note Only meaningful for contiguous data
|
||||||
|
inline static std::streamsize size_bytes() noexcept;
|
||||||
|
|
||||||
|
//- Number of contiguous bytes for the list data,
|
||||||
|
//- runtime FatalError if type is not contiguous
|
||||||
|
static std::streamsize byteSize();
|
||||||
|
|
||||||
|
//- Element access using compile-time indexing
|
||||||
|
template<unsigned Index>
|
||||||
|
inline T& get() noexcept;
|
||||||
|
|
||||||
|
//- Element access using compile-time indexing
|
||||||
|
template<unsigned Index>
|
||||||
|
inline const T& get() const noexcept;
|
||||||
|
|
||||||
//- Access first element of the list, position [0]
|
//- Access first element of the list, position [0]
|
||||||
inline T& front() noexcept;
|
inline T& front() noexcept;
|
||||||
|
|
||||||
@ -228,14 +244,6 @@ public:
|
|||||||
//- Access last element of the list, position [N-1]
|
//- Access last element of the list, position [N-1]
|
||||||
inline const T& back() const noexcept;
|
inline const T& back() const noexcept;
|
||||||
|
|
||||||
//- Number of contiguous bytes for the list data,
|
|
||||||
// \note Only meaningful for contiguous data
|
|
||||||
inline static std::streamsize size_bytes() noexcept;
|
|
||||||
|
|
||||||
//- Number of contiguous bytes for the list data,
|
|
||||||
//- runtime FatalError if type is not contiguous
|
|
||||||
static std::streamsize byteSize();
|
|
||||||
|
|
||||||
//- Return the forward circular index, i.e. next index
|
//- Return the forward circular index, i.e. next index
|
||||||
//- which returns to the first at the end of the list
|
//- which returns to the first at the end of the list
|
||||||
inline label fcIndex(const label i) const;
|
inline label fcIndex(const label i) const;
|
||||||
|
@ -203,6 +203,24 @@ inline std::streamsize Foam::FixedList<T, N>::size_bytes() noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned N>
|
||||||
|
template<unsigned Index>
|
||||||
|
inline T& Foam::FixedList<T, N>::get() noexcept
|
||||||
|
{
|
||||||
|
static_assert(Index < N, "Address outside FixedList range");
|
||||||
|
return v_[Index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, unsigned N>
|
||||||
|
template<unsigned Index>
|
||||||
|
inline const T& Foam::FixedList<T, N>::get() const noexcept
|
||||||
|
{
|
||||||
|
static_assert(Index < N, "Address outside FixedList range");
|
||||||
|
return v_[Index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, unsigned N>
|
template<class T, unsigned N>
|
||||||
inline T& Foam::FixedList<T, N>::front() noexcept
|
inline T& Foam::FixedList<T, N>::front() noexcept
|
||||||
{
|
{
|
||||||
|
@ -108,38 +108,28 @@ public:
|
|||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
label a() const { return labelPair::first(); }
|
label a() const noexcept { return labelPair::first(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
label b() const { return labelPair::second(); }
|
label b() const noexcept { return labelPair::second(); }
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
label& a() { return labelPair::first(); }
|
label& a() noexcept { return labelPair::first(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
label& b() { return labelPair::second(); }
|
label& b() noexcept { return labelPair::second(); }
|
||||||
|
|
||||||
|
|
||||||
//- The first vertex label
|
|
||||||
using labelPair::first;
|
|
||||||
|
|
||||||
//- The second (last) vertex label
|
|
||||||
using labelPair::second;
|
|
||||||
|
|
||||||
//- The last (second) vertex label
|
|
||||||
using labelPair::last;
|
|
||||||
|
|
||||||
//- The start (first) vertex label
|
//- The start (first) vertex label
|
||||||
label start() const { return labelPair::first(); }
|
label start() const noexcept { return labelPair::first(); }
|
||||||
|
|
||||||
//- The end (last/second) vertex label
|
//- The end (last/second) vertex label
|
||||||
label end() const { return labelPair::second(); }
|
label end() const noexcept { return labelPair::second(); }
|
||||||
|
|
||||||
//- The start (first) vertex label
|
//- The start (first) vertex label
|
||||||
label& start() { return labelPair::first(); }
|
label& start() noexcept { return labelPair::first(); }
|
||||||
|
|
||||||
//- The end (last/second) vertex label
|
//- The end (second/last) vertex label
|
||||||
label& end() { return labelPair::second(); }
|
label& end() noexcept { return labelPair::second(); }
|
||||||
|
|
||||||
|
|
||||||
//- Return reverse edge as copy.
|
//- Return reverse edge as copy.
|
||||||
@ -157,8 +147,11 @@ public:
|
|||||||
// No special handling of negative point labels.
|
// No special handling of negative point labels.
|
||||||
inline label maxVertex() const;
|
inline label maxVertex() const;
|
||||||
|
|
||||||
//- Return true if the vertices are unique and non-negative.
|
//- True if the vertices are unique and non-negative.
|
||||||
inline bool valid() const;
|
inline bool good() const noexcept;
|
||||||
|
|
||||||
|
//- True if the vertices are unique and non-negative.
|
||||||
|
bool valid() const noexcept { return good(); }
|
||||||
|
|
||||||
//- Return true if point label is found in edge.
|
//- Return true if point label is found in edge.
|
||||||
// Always false for a negative label.
|
// Always false for a negative label.
|
||||||
|
@ -58,7 +58,7 @@ inline Foam::edge::edge(const labelPair& pair)
|
|||||||
|
|
||||||
inline Foam::edge::edge(const FixedList<label, 2>& list)
|
inline Foam::edge::edge(const FixedList<label, 2>& list)
|
||||||
:
|
:
|
||||||
labelPair(list.first(), list.last())
|
labelPair(list.get<0>(), list.get<1>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ inline Foam::edge::edge
|
|||||||
const FixedList<label, 2>& indices
|
const FixedList<label, 2>& indices
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
labelPair(list[indices.first()], list[indices.last()])
|
labelPair(list[indices.get<0>()], list[indices.get<1>()])
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ inline Foam::label Foam::edge::maxVertex() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::edge::valid() const
|
inline bool Foam::edge::good() const noexcept
|
||||||
{
|
{
|
||||||
return (first() != second() && first() >= 0 && second() >= 0);
|
return (first() != second() && first() >= 0 && second() >= 0);
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public:
|
|||||||
inline triFace();
|
inline triFace();
|
||||||
|
|
||||||
//- Construct from three point labels
|
//- Construct from three point labels
|
||||||
inline triFace(const label p0, const label p1, const label p2);
|
inline triFace(const label p0, const label p1, const label p2) noexcept;
|
||||||
|
|
||||||
//- Construct from an initializer list of three point labels
|
//- Construct from an initializer list of three point labels
|
||||||
inline explicit triFace(std::initializer_list<label> list);
|
inline explicit triFace(std::initializer_list<label> list);
|
||||||
@ -112,41 +112,31 @@ public:
|
|||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
label a() const { return operator[](0); }
|
label a() const noexcept { return get<0>(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
label b() const { return operator[](1); }
|
label b() const noexcept { return get<1>(); }
|
||||||
|
|
||||||
//- The third vertex
|
//- The third vertex
|
||||||
label c() const { return operator[](2); }
|
label c() const noexcept { return get<2>(); }
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
label& a() { return operator[](0); }
|
label& a() noexcept { return get<0>(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
label& b() { return operator[](1); }
|
label& b() noexcept { return get<1>(); }
|
||||||
|
|
||||||
//- The third vertex
|
//- The third vertex
|
||||||
label& c() { return operator[](2); }
|
label& c() noexcept { return get<2>(); }
|
||||||
|
|
||||||
|
|
||||||
//- The first vertex label
|
|
||||||
using FixedList<label, 3>::first;
|
|
||||||
|
|
||||||
//- The last (third) vertex label
|
|
||||||
using FixedList<label, 3>::last;
|
|
||||||
|
|
||||||
//- The second vertex label
|
|
||||||
label& second() { return operator[](1); }
|
|
||||||
|
|
||||||
//- The second vertex label
|
|
||||||
label second() const { return operator[](1); }
|
|
||||||
|
|
||||||
|
|
||||||
// Queries
|
// Queries
|
||||||
|
|
||||||
//- Return true if the vertices are unique and non-negative.
|
//- True if vertices are unique and non-negative.
|
||||||
inline bool valid() const;
|
inline bool good() const noexcept;
|
||||||
|
|
||||||
|
//- True if vertices are unique and non-negative.
|
||||||
|
bool valid() const noexcept { return good(); }
|
||||||
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
@ -67,11 +67,16 @@ inline Foam::triFace::triFace()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::triFace::triFace(const label p0, const label p1, const label p2)
|
inline Foam::triFace::triFace
|
||||||
|
(
|
||||||
|
const label p0,
|
||||||
|
const label p1,
|
||||||
|
const label p2
|
||||||
|
) noexcept
|
||||||
{
|
{
|
||||||
operator[](0) = p0;
|
a() = p0;
|
||||||
operator[](1) = p1;
|
b() = p1;
|
||||||
operator[](2) = p2;
|
c() = p2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,13 +110,13 @@ inline Foam::triFace::triFace(Istream& is)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline bool Foam::triFace::valid() const
|
inline bool Foam::triFace::good() const noexcept
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
operator[](0) >= 0 && operator[](0) != operator[](1)
|
a() >= 0 && a() != b()
|
||||||
&& operator[](1) >= 0 && operator[](1) != operator[](2)
|
&& b() >= 0 && b() != c()
|
||||||
&& operator[](2) >= 0 && operator[](0) != operator[](2)
|
&& c() >= 0 && c() != a()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +150,7 @@ inline Foam::label Foam::triFace::collapse()
|
|||||||
|
|
||||||
inline void Foam::triFace::flip()
|
inline void Foam::triFace::flip()
|
||||||
{
|
{
|
||||||
std::swap(operator[](1), operator[](2));
|
std::swap(get<1>(), get<2>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,9 +158,9 @@ inline Foam::pointField Foam::triFace::points(const UList<point>& pts) const
|
|||||||
{
|
{
|
||||||
pointField p(3);
|
pointField p(3);
|
||||||
|
|
||||||
p[0] = pts[operator[](0)];
|
p[0] = pts[a()];
|
||||||
p[1] = pts[operator[](1)];
|
p[1] = pts[b()];
|
||||||
p[2] = pts[operator[](2)];
|
p[2] = pts[c()];
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -169,45 +174,25 @@ inline Foam::face Foam::triFace::triFaceFace() const
|
|||||||
|
|
||||||
inline Foam::triPointRef Foam::triFace::tri(const UList<point>& points) const
|
inline Foam::triPointRef Foam::triFace::tri(const UList<point>& points) const
|
||||||
{
|
{
|
||||||
return triPointRef
|
return triPointRef(points[a()], points[b()], points[c()]);
|
||||||
(
|
|
||||||
points[operator[](0)],
|
|
||||||
points[operator[](1)],
|
|
||||||
points[operator[](2)]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::point Foam::triFace::centre(const UList<point>& points) const
|
inline Foam::point Foam::triFace::centre(const UList<point>& points) const
|
||||||
{
|
{
|
||||||
return triPointRef::centre
|
return triPointRef::centre(points[a()], points[b()], points[c()]);
|
||||||
(
|
|
||||||
points[operator[](0)],
|
|
||||||
points[operator[](1)],
|
|
||||||
points[operator[](2)]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::vector Foam::triFace::areaNormal(const UList<point>& points) const
|
inline Foam::vector Foam::triFace::areaNormal(const UList<point>& points) const
|
||||||
{
|
{
|
||||||
return triPointRef::areaNormal
|
return triPointRef::areaNormal(points[a()], points[b()], points[c()]);
|
||||||
(
|
|
||||||
points[operator[](0)],
|
|
||||||
points[operator[](1)],
|
|
||||||
points[operator[](2)]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::vector Foam::triFace::unitNormal(const UList<point>& points) const
|
inline Foam::vector Foam::triFace::unitNormal(const UList<point>& points) const
|
||||||
{
|
{
|
||||||
return triPointRef::unitNormal
|
return triPointRef::unitNormal(points[a()], points[b()], points[c()]);
|
||||||
(
|
|
||||||
points[operator[](0)],
|
|
||||||
points[operator[](1)],
|
|
||||||
points[operator[](2)]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -220,12 +205,7 @@ inline Foam::scalar Foam::triFace::mag(const UList<point>& points) const
|
|||||||
inline Foam::Pair<Foam::point>
|
inline Foam::Pair<Foam::point>
|
||||||
Foam::triFace::box(const UList<point>& points) const
|
Foam::triFace::box(const UList<point>& points) const
|
||||||
{
|
{
|
||||||
return triPointRef::box
|
return triPointRef::box(points[a()], points[b()], points[c()]);
|
||||||
(
|
|
||||||
points[operator[](0)],
|
|
||||||
points[operator[](1)],
|
|
||||||
points[operator[](2)]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -238,7 +218,7 @@ inline Foam::label Foam::triFace::nTriangles() const noexcept
|
|||||||
inline Foam::triFace Foam::triFace::reverseFace() const
|
inline Foam::triFace Foam::triFace::reverseFace() const
|
||||||
{
|
{
|
||||||
// The starting points of the original and reverse face are identical.
|
// The starting points of the original and reverse face are identical.
|
||||||
return triFace(operator[](0), operator[](2), operator[](1));
|
return triFace(a(), c(), b());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -433,14 +413,14 @@ inline Foam::edgeList Foam::triFace::edges() const
|
|||||||
{
|
{
|
||||||
edgeList theEdges(3);
|
edgeList theEdges(3);
|
||||||
|
|
||||||
theEdges[0].first() = operator[](0);
|
theEdges[0].first() = a();
|
||||||
theEdges[0].second() = operator[](1);
|
theEdges[0].second() = b();
|
||||||
|
|
||||||
theEdges[1].first() = operator[](1);
|
theEdges[1].first() = b();
|
||||||
theEdges[1].second() = operator[](2);
|
theEdges[1].second() = c();
|
||||||
|
|
||||||
theEdges[2].first() = operator[](2);
|
theEdges[2].first() = c();
|
||||||
theEdges[2].second() = operator[](0);
|
theEdges[2].second() = a();
|
||||||
|
|
||||||
return theEdges;
|
return theEdges;
|
||||||
}
|
}
|
||||||
@ -450,14 +430,14 @@ inline Foam::edgeList Foam::triFace::rcEdges() const
|
|||||||
{
|
{
|
||||||
edgeList theEdges(3);
|
edgeList theEdges(3);
|
||||||
|
|
||||||
theEdges[0].first() = operator[](0);
|
theEdges[0].first() = a();
|
||||||
theEdges[0].second() = operator[](2);
|
theEdges[0].second() = c();
|
||||||
|
|
||||||
theEdges[1].first() = operator[](2);
|
theEdges[1].first() = c();
|
||||||
theEdges[1].second() = operator[](1);
|
theEdges[1].second() = b();
|
||||||
|
|
||||||
theEdges[2].first() = operator[](1);
|
theEdges[2].first() = b();
|
||||||
theEdges[2].second() = operator[](0);
|
theEdges[2].second() = a();
|
||||||
|
|
||||||
return theEdges;
|
return theEdges;
|
||||||
}
|
}
|
||||||
@ -465,20 +445,20 @@ inline Foam::edgeList Foam::triFace::rcEdges() const
|
|||||||
|
|
||||||
inline int Foam::triFace::edgeDirection(const Foam::edge& e) const
|
inline int Foam::triFace::edgeDirection(const Foam::edge& e) const
|
||||||
{
|
{
|
||||||
if (e.first() == operator[](0))
|
if (e.first() == a())
|
||||||
{
|
{
|
||||||
if (e.second() == operator[](1)) return 1; // Forward
|
if (e.second() == b()) return 1; // Forward
|
||||||
if (e.second() == operator[](2)) return -1; // Reverse
|
if (e.second() == c()) return -1; // Reverse
|
||||||
}
|
}
|
||||||
if (e.first() == operator[](1))
|
if (e.first() == b())
|
||||||
{
|
{
|
||||||
if (e.second() == operator[](2)) return 1; // Forward
|
if (e.second() == c()) return 1; // Forward
|
||||||
if (e.second() == operator[](0)) return -1; // Reverse
|
if (e.second() == a()) return -1; // Reverse
|
||||||
}
|
}
|
||||||
if (e.first() == operator[](2))
|
if (e.first() == c())
|
||||||
{
|
{
|
||||||
if (e.second() == operator[](0)) return 1; // Forward
|
if (e.second() == a()) return 1; // Forward
|
||||||
if (e.second() == operator[](1)) return -1; // Reverse
|
if (e.second() == b()) return -1; // Reverse
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; // Not found
|
return 0; // Not found
|
||||||
|
@ -39,13 +39,7 @@ Type Foam::triFace::average
|
|||||||
// a triangle, do a direct calculation
|
// a triangle, do a direct calculation
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
(1.0/3.0)
|
(1.0/3.0) * (fld[a()] + fld[b()] + fld[c()])
|
||||||
*
|
|
||||||
(
|
|
||||||
fld[operator[](0)]
|
|
||||||
+ fld[operator[](1)]
|
|
||||||
+ fld[operator[](2)]
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,16 +105,16 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
const point& a() const { return Pair<point>::first(); }
|
const point& a() const noexcept { return Pair<point>::first(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
const point& b() const { return Pair<point>::second(); }
|
const point& b() const noexcept { return Pair<point>::second(); }
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
point& a() { return Pair<point>::first(); }
|
point& a() noexcept { return Pair<point>::first(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
point& b() { return Pair<point>::second(); }
|
point& b() noexcept { return Pair<point>::second(); }
|
||||||
|
|
||||||
//- Return as line reference
|
//- Return as line reference
|
||||||
inline linePointRef ln() const;
|
inline linePointRef ln() const;
|
||||||
@ -148,12 +148,13 @@ class line
|
|||||||
{
|
{
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
//- First point
|
//- Reference to the first line point
|
||||||
PointRef a_;
|
PointRef a_;
|
||||||
|
|
||||||
//- Second point
|
//- Reference to the second line point
|
||||||
PointRef b_;
|
PointRef b_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -189,15 +190,15 @@ public:
|
|||||||
//- The second (last) point
|
//- The second (last) point
|
||||||
PointRef second() const noexcept { return b_; }
|
PointRef second() const noexcept { return b_; }
|
||||||
|
|
||||||
//- The last (second) point
|
|
||||||
PointRef last() const noexcept { return b_; }
|
|
||||||
|
|
||||||
//- The start (first) point
|
//- The start (first) point
|
||||||
PointRef start() const noexcept { return a_; }
|
PointRef start() const noexcept { return a_; }
|
||||||
|
|
||||||
//- The end (second) point
|
//- The end (second) point
|
||||||
PointRef end() const noexcept { return b_; }
|
PointRef end() const noexcept { return b_; }
|
||||||
|
|
||||||
|
//- The last (second) point
|
||||||
|
PointRef last() const noexcept { return b_; }
|
||||||
|
|
||||||
|
|
||||||
// Line properties (static calculations)
|
// Line properties (static calculations)
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ inline Foam::linePoints::linePoints
|
|||||||
const FixedList<label, 2>& indices
|
const FixedList<label, 2>& indices
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
Pair<point>(points[indices.first()], points[indices.last()])
|
Pair<point>(points[indices.get<0>()], points[indices.get<1>()])
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ inline Foam::line<Point, PointRef>::line
|
|||||||
const FixedList<label, 2>& indices
|
const FixedList<label, 2>& indices
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
a_(points[indices.first()]),
|
a_(points[indices.template get<0>()]),
|
||||||
b_(points[indices.last()])
|
b_(points[indices.template get<1>()])
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,28 +126,28 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
const point& a() const { return operator[](0); }
|
const point& a() const noexcept { return get<0>(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
const point& b() const { return operator[](1); }
|
const point& b() const noexcept { return get<1>(); }
|
||||||
|
|
||||||
//- The third vertex
|
//- The third vertex
|
||||||
const point& c() const { return operator[](2); }
|
const point& c() const noexcept { return get<2>(); }
|
||||||
|
|
||||||
//- The fourth vertex
|
//- The fourth vertex
|
||||||
const point& d() const { return operator[](3); }
|
const point& d() const noexcept { return get<3>(); }
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
point& a() { return operator[](0); }
|
point& a() noexcept { return get<0>(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
point& b() { return operator[](1); }
|
point& b() noexcept { return get<1>(); }
|
||||||
|
|
||||||
//- The third vertex
|
//- The third vertex
|
||||||
point& c() { return operator[](2); }
|
point& c() noexcept { return get<2>(); }
|
||||||
|
|
||||||
//- The fourth vertex
|
//- The fourth vertex
|
||||||
point& d() { return operator[](3); }
|
point& d() noexcept { return get<3>(); }
|
||||||
|
|
||||||
//- Return as tetrahedron reference
|
//- Return as tetrahedron reference
|
||||||
inline tetPointRef tet() const;
|
inline tetPointRef tet() const;
|
||||||
|
@ -40,19 +40,19 @@ inline Foam::tetPoints::tetPoints
|
|||||||
const point& p3
|
const point& p3
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
operator[](0) = p0;
|
a() = p0;
|
||||||
operator[](1) = p1;
|
b() = p1;
|
||||||
operator[](2) = p2;
|
c() = p2;
|
||||||
operator[](3) = p3;
|
d() = p3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::tetPoints::tetPoints(const tetPointRef& pts)
|
inline Foam::tetPoints::tetPoints(const tetPointRef& pts)
|
||||||
{
|
{
|
||||||
operator[](0) = pts.a();
|
a() = pts.a();
|
||||||
operator[](1) = pts.b();
|
b() = pts.b();
|
||||||
operator[](2) = pts.c();
|
c() = pts.c();
|
||||||
operator[](3) = pts.d();
|
d() = pts.d();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -94,10 +94,10 @@ inline Foam::tetrahedron<Point, PointRef>::tetrahedron
|
|||||||
const FixedList<Point, 4>& pts
|
const FixedList<Point, 4>& pts
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
a_(pts[0]),
|
a_(pts.template get<0>()),
|
||||||
b_(pts[1]),
|
b_(pts.template get<1>()),
|
||||||
c_(pts[2]),
|
c_(pts.template get<2>()),
|
||||||
d_(pts[3])
|
d_(pts.template get<3>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -108,10 +108,10 @@ inline Foam::tetrahedron<Point, PointRef>::tetrahedron
|
|||||||
const FixedList<label, 4>& indices
|
const FixedList<label, 4>& indices
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
a_(points[indices[0]]),
|
a_(points[indices.template get<0>()]),
|
||||||
b_(points[indices[1]]),
|
b_(points[indices.template get<1>()]),
|
||||||
c_(points[indices[2]]),
|
c_(points[indices.template get<2>()]),
|
||||||
d_(points[indices[3]])
|
d_(points[indices.template get<3>()])
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,22 +114,22 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
const point& a() const { return operator[](0); }
|
const point& a() const noexcept { return get<0>(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
const point& b() const { return operator[](1); }
|
const point& b() const noexcept { return get<1>(); }
|
||||||
|
|
||||||
//- The third vertex
|
//- The third vertex
|
||||||
const point& c() const { return operator[](2); }
|
const point& c() const noexcept { return get<2>(); }
|
||||||
|
|
||||||
//- The first vertex
|
//- The first vertex
|
||||||
point& a() { return operator[](0); }
|
point& a() noexcept { return get<0>(); }
|
||||||
|
|
||||||
//- The second vertex
|
//- The second vertex
|
||||||
point& b() { return operator[](1); }
|
point& b() noexcept { return get<1>(); }
|
||||||
|
|
||||||
//- The third vertex
|
//- The third vertex
|
||||||
point& c() { return operator[](2); }
|
point& c() noexcept { return get<2>(); }
|
||||||
|
|
||||||
//- Flip triangle orientation by swapping second and third vertices
|
//- Flip triangle orientation by swapping second and third vertices
|
||||||
inline void flip();
|
inline void flip();
|
||||||
@ -154,6 +154,15 @@ public:
|
|||||||
|
|
||||||
//- The enclosing (bounding) box for the triangle
|
//- The enclosing (bounding) box for the triangle
|
||||||
inline Pair<point> box() const;
|
inline Pair<point> box() const;
|
||||||
|
|
||||||
|
//- Edge vector opposite point a(): from b() to c()
|
||||||
|
inline vector vecA() const;
|
||||||
|
|
||||||
|
//- Edge vector opposite point b(): from c() to a()
|
||||||
|
inline vector vecB() const;
|
||||||
|
|
||||||
|
//- Edge vector opposite point c(): from a() to b()
|
||||||
|
inline vector vecC() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -224,7 +233,14 @@ private:
|
|||||||
|
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
PointRef a_, b_, c_;
|
//- Reference to the first triangle point
|
||||||
|
PointRef a_;
|
||||||
|
|
||||||
|
//- Reference to the second triangle point
|
||||||
|
PointRef b_;
|
||||||
|
|
||||||
|
//- Reference to the third triangle point
|
||||||
|
PointRef c_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
@ -322,30 +338,42 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
|
|
||||||
//- Return centre (centroid)
|
//- Return centre (centroid)
|
||||||
inline Point centre() const;
|
inline Point centre() const;
|
||||||
|
|
||||||
//- The area normal - with magnitude equal to area of triangle
|
//- The area normal - with magnitude equal to area of triangle
|
||||||
inline vector areaNormal() const;
|
inline vector areaNormal() const;
|
||||||
|
|
||||||
//- Return unit normal
|
//- Return unit normal
|
||||||
inline vector unitNormal() const;
|
inline vector unitNormal() const;
|
||||||
|
|
||||||
//- Legacy name for areaNormal().
|
//- Legacy name for areaNormal().
|
||||||
// \deprecated(2018-06) Deprecated for new use
|
// \deprecated(2018-06) Deprecated for new use
|
||||||
FOAM_DEPRECATED_FOR(2018-12, "areaNormal() or unitNormal()")
|
FOAM_DEPRECATED_FOR(2018-12, "areaNormal() or unitNormal()")
|
||||||
vector normal() const
|
vector normal() const
|
||||||
{
|
{
|
||||||
return areaNormal();
|
return areaNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- The magnitude of the triangle area
|
//- The magnitude of the triangle area
|
||||||
inline scalar mag() const;
|
inline scalar mag() const;
|
||||||
|
|
||||||
//- The enclosing (bounding) box for the triangle
|
//- The enclosing (bounding) box for the triangle
|
||||||
inline Pair<Point> box() const;
|
inline Pair<Point> box() const;
|
||||||
|
|
||||||
|
//- Edge vector opposite point a(): from b() to c()
|
||||||
|
inline Point vecA() const;
|
||||||
|
|
||||||
|
//- Edge vector opposite point b(): from c() to a()
|
||||||
|
inline Point vecB() const;
|
||||||
|
|
||||||
|
//- Edge vector opposite point c(): from a() to b()
|
||||||
|
inline Point vecC() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
|
||||||
//- Return circum-centre
|
//- Return circum-centre
|
||||||
inline Point circumCentre() const;
|
inline Point circumCentre() const;
|
||||||
|
@ -39,17 +39,17 @@ inline Foam::triPoints::triPoints
|
|||||||
const point& p2
|
const point& p2
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
operator[](0) = p0;
|
a() = p0;
|
||||||
operator[](1) = p1;
|
b() = p1;
|
||||||
operator[](2) = p2;
|
c() = p2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::triPoints::triPoints(const triPointRef& pts)
|
inline Foam::triPoints::triPoints(const triPointRef& pts)
|
||||||
{
|
{
|
||||||
operator[](0) = pts.a();
|
a() = pts.a();
|
||||||
operator[](1) = pts.b();
|
b() = pts.b();
|
||||||
operator[](2) = pts.c();
|
c() = pts.c();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,9 +89,9 @@ inline Foam::triangle<Point, PointRef>::triangle
|
|||||||
const FixedList<Point, 3>& pts
|
const FixedList<Point, 3>& pts
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
a_(pts[0]),
|
a_(pts.template get<0>()),
|
||||||
b_(pts[1]),
|
b_(pts.template get<1>()),
|
||||||
c_(pts[2])
|
c_(pts.template get<2>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -102,9 +102,9 @@ inline Foam::triangle<Point, PointRef>::triangle
|
|||||||
const FixedList<label, 3>& indices
|
const FixedList<label, 3>& indices
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
a_(points[indices[0]]),
|
a_(points[indices.template get<0>()]),
|
||||||
b_(points[indices[1]]),
|
b_(points[indices.template get<1>()]),
|
||||||
c_(points[indices[2]])
|
c_(points[indices.template get<2>()])
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -223,6 +223,43 @@ inline Foam::Pair<Foam::point> Foam::triPoints::box() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Point, class PointRef>
|
||||||
|
inline Point Foam::triangle<Point, PointRef>::vecA() const
|
||||||
|
{
|
||||||
|
return Point(c_ - b_);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Point, class PointRef>
|
||||||
|
inline Point Foam::triangle<Point, PointRef>::vecB() const
|
||||||
|
{
|
||||||
|
return Point(a_ - c_);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Point, class PointRef>
|
||||||
|
inline Point Foam::triangle<Point, PointRef>::vecC() const
|
||||||
|
{
|
||||||
|
return Point(b_ - a_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::vector Foam::triPoints::vecA() const
|
||||||
|
{
|
||||||
|
return vector(c() - b());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::vector Foam::triPoints::vecB() const
|
||||||
|
{
|
||||||
|
return vector(a() - c());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::vector Foam::triPoints::vecC() const
|
||||||
|
{
|
||||||
|
return vector(b() - a());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::triPointRef Foam::triPoints::tri() const
|
inline Foam::triPointRef Foam::triPoints::tri() const
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -112,17 +112,17 @@ public:
|
|||||||
//- True if all components are set
|
//- True if all components are set
|
||||||
//
|
//
|
||||||
// \note Method name compatibility with bitSet
|
// \note Method name compatibility with bitSet
|
||||||
inline bool all() const;
|
inline bool all() const noexcept;
|
||||||
|
|
||||||
//- True if any components are set
|
//- True if any components are set
|
||||||
//
|
//
|
||||||
// \note Method name compatibility with bitSet
|
// \note Method name compatibility with bitSet
|
||||||
inline bool any() const;
|
inline bool any() const noexcept;
|
||||||
|
|
||||||
//- True if no components are set
|
//- True if no components are set
|
||||||
//
|
//
|
||||||
// \note Method name compatibility with bitSet
|
// \note Method name compatibility with bitSet
|
||||||
inline bool none() const;
|
inline bool none() const noexcept;
|
||||||
|
|
||||||
//- Count number of items set.
|
//- Count number of items set.
|
||||||
// \param on can be set to false to count the number of unset bits
|
// \param on can be set to false to count the number of unset bits
|
||||||
@ -135,22 +135,22 @@ public:
|
|||||||
// Component Access
|
// Component Access
|
||||||
|
|
||||||
//- The x component
|
//- The x component
|
||||||
bool x() const { return operator[](boolVector::X); }
|
bool x() const noexcept { return get<0>(); }
|
||||||
|
|
||||||
//- The y component
|
//- The y component
|
||||||
bool y() const { return operator[](boolVector::Y); }
|
bool y() const noexcept { return get<1>(); }
|
||||||
|
|
||||||
//- The z component
|
//- The z component
|
||||||
bool z() const { return operator[](boolVector::Z); }
|
bool z() const noexcept { return get<2>(); }
|
||||||
|
|
||||||
//- The x component
|
//- The x component
|
||||||
bool& x() { return operator[](boolVector::X); }
|
bool& x() noexcept { return get<0>(); }
|
||||||
|
|
||||||
//- The y component
|
//- The y component
|
||||||
bool& y() { return operator[](boolVector::Y); }
|
bool& y() noexcept { return get<1>(); }
|
||||||
|
|
||||||
//- The z component
|
//- The z component
|
||||||
bool& z() { return operator[](boolVector::Z); }
|
bool& z() noexcept { return get<2>(); }
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -45,8 +45,6 @@ inline Foam::boolVector::boolVector
|
|||||||
const bool vy,
|
const bool vy,
|
||||||
const bool vz
|
const bool vz
|
||||||
)
|
)
|
||||||
:
|
|
||||||
FixedList<bool, 3>()
|
|
||||||
{
|
{
|
||||||
x() = vx;
|
x() = vx;
|
||||||
y() = vy;
|
y() = vy;
|
||||||
@ -62,27 +60,19 @@ inline Foam::boolVector::boolVector(Istream& is)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline bool Foam::boolVector::all() const
|
inline bool Foam::boolVector::all() const noexcept
|
||||||
{
|
{
|
||||||
for (const bool val : *this)
|
return (x() && y() && z());
|
||||||
{
|
|
||||||
if (!val) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::boolVector::any() const
|
inline bool Foam::boolVector::any() const noexcept
|
||||||
{
|
{
|
||||||
for (const bool val : *this)
|
return (x() || y() || z());
|
||||||
{
|
|
||||||
if (val) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::boolVector::none() const
|
inline bool Foam::boolVector::none() const noexcept
|
||||||
{
|
{
|
||||||
return !any();
|
return !any();
|
||||||
}
|
}
|
||||||
@ -109,10 +99,9 @@ inline unsigned int Foam::boolVector::count(const bool on) const
|
|||||||
|
|
||||||
inline void Foam::boolVector::flip()
|
inline void Foam::boolVector::flip()
|
||||||
{
|
{
|
||||||
for (bool& val : *this)
|
x() = !x();
|
||||||
{
|
y() = !y();
|
||||||
val = !val;
|
z() = !z();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -113,17 +113,17 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return first element
|
//- Access the first element
|
||||||
using FixedList<T, 2>::first;
|
const T& first() const noexcept { return this->template get<0>(); }
|
||||||
|
|
||||||
//- Return last element
|
//- Access the first element
|
||||||
using FixedList<T, 2>::last;
|
T& first() noexcept { return this->template get<0>(); }
|
||||||
|
|
||||||
//- Return second element, which is also the last element
|
//- Access the second element
|
||||||
inline const T& second() const noexcept;
|
const T& second() const noexcept { return this->template get<1>(); }
|
||||||
|
|
||||||
//- Return second element, which is also the last element
|
//- Access the second element
|
||||||
inline T& second() noexcept;
|
T& second() noexcept { return this->template get<1>(); }
|
||||||
|
|
||||||
//- Return other element
|
//- Return other element
|
||||||
inline const T& other(const T& a) const;
|
inline const T& other(const T& a) const;
|
||||||
|
@ -103,7 +103,7 @@ inline Foam::Pair<T>::Pair(const T& f, const T& s, const bool doSort)
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::Pair<T>::Pair(const FixedList<T, 2>& list, const bool doSort)
|
inline Foam::Pair<T>::Pair(const FixedList<T, 2>& list, const bool doSort)
|
||||||
:
|
:
|
||||||
Pair<T>(list.first(), list.last(), doSort)
|
Pair<T>(list.template get<0>(), list.template get<1>(), doSort)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -116,20 +116,6 @@ inline Foam::Pair<T>::Pair(Istream& is)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T& Foam::Pair<T>::second() const noexcept
|
|
||||||
{
|
|
||||||
return last();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T& Foam::Pair<T>::second() noexcept
|
|
||||||
{
|
|
||||||
return last();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline const T& Foam::Pair<T>::other(const T& val) const
|
inline const T& Foam::Pair<T>::other(const T& val) const
|
||||||
{
|
{
|
||||||
|
@ -117,16 +117,16 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return first
|
//- Access the first element
|
||||||
const T1& first() const noexcept { return f_; }
|
const T1& first() const noexcept { return f_; }
|
||||||
|
|
||||||
//- Return first
|
//- Access the first element
|
||||||
T1& first() noexcept { return f_; }
|
T1& first() noexcept { return f_; }
|
||||||
|
|
||||||
//- Return second
|
//- Access the second element
|
||||||
const T2& second() const noexcept { return s_; }
|
const T2& second() const noexcept { return s_; }
|
||||||
|
|
||||||
//- Return second
|
//- Access the second element
|
||||||
T2& second() noexcept { return s_; }
|
T2& second() noexcept { return s_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user