ENH: supplementary vector comparison methods

- background: for some application it can be useful to have fully
  sorted points. i.e., sorted by x, followed by y, followed by z.

  The default VectorSpace 'operator<' compares *all*
  components. This is seen by the following comparisons

  1.  a = (-2.2 -3.3 -4.4)
      b = (-1.1 -2.2 3.3)

      (a < b) : True
      Each 'a' component is less than each 'b' component

  2.  a = (-2.2 -3.3 -4.4)
      b = (-2.2 3.3 4.4)

      (a < b) : False
      The a.x() is not less than b.x()

  The static definitions 'less_xyz', 'less_yzx', 'less_zxy'
  instead use comparison of the next components as tie breakers
  (like a lexicographic sort).
  - same type of definition that Pair and Tuple2 use.

      a = (-2.2 -3.3 -4.4)
      b = (-2.2 3.3 4.4)

      vector::less_xyz(a, b) : True
      The a.x() == b.x(), but a.y() < b.y()

   They can be used directly as comparators:

      pointField points = ...;

      std::sort(points.begin(), points.end(), vector::less_zxy);

ENH: make VectorSpace named access methods noexcept.

   Since the addressing range is restricted to enumerated offsets
   (eg, X/Y/Z) into storage, always remains in-range.
   Possible to make constexpr with future C++ versions.

STYLE: VectorSpace 'operator>' defined using 'operator<'

- standard rewriting rule
This commit is contained in:
Mark Olesen
2022-10-17 10:41:05 +02:00
parent 371795840c
commit c973066646
50 changed files with 475 additions and 1352 deletions

View File

@ -33,6 +33,7 @@ Description
#include "vectorField.H"
#include "IOstreams.H"
#include "Random.H"
#include <algorithm>
#include <random>
@ -74,8 +75,12 @@ void doTest(vector& vec1, vector& vec2)
printInfo(vec1);
printInfo(vec2);
Info<< "min of " << vec1 << " and " << vec2 << " = "
<< min(vec1, vec2) << nl << nl;
Info<< "vector: " << vec1 << nl
<< "vector: " << vec2 << nl
<< " min: " << min(vec1, vec2) << nl
<< " dist: " << vec1.dist(vec2) << ' ' << mag(vec1 - vec2) << nl
<< "dist^2: " << vec1.distSqr(vec2) << ' ' << magSqr(vec1 - vec2) << nl
<< nl;
}
@ -146,6 +151,46 @@ int main(int argc, char *argv[])
std::shuffle(vec2.begin(), vec2.end(), std::default_random_engine());
Info<< "shuffled: " << vec2 << nl;
// Vectors with some identical components
List<vector> vectors
({
{1.1, 2.2, 3.3 },
{2.2, 3.3, 4.4 },
{-1.1, 2.2, 3.3 },
{-2.2, 3.3, 4.4 },
{-1.1, -2.2, 3.3 },
{-2.2, -3.3, 4.4 },
{-1.1, -2.2, -3.3 },
{-2.2, -3.3, -4.4 },
{-3.3, 2.1, 12 },
{3.145, 1.6, 2 },
{0, 0, 0}
});
shuffle(vectors);
Info<< "initial vectors: ";
vectors.writeList(Info, 1) << nl;
Foam::sort(vectors);
Info<< "regular sort:";
vectors.writeList(Info, 1) << nl;
std::sort(vectors.begin(), vectors.end(), vector::less_xyz);
Info<< "sorted xyz:";
vectors.writeList(Info, 1) << nl;
std::sort(vectors.begin(), vectors.end(), vector::less_yzx);
Info<< "sorted yzx:";
vectors.writeList(Info, 1) << nl;
std::sort(vectors.begin(), vectors.end(), vector::less_zxy);
Info<< "sorted zxy:";
vectors.writeList(Info, 1) << nl;
}
// Basic tests for fields

View File

@ -100,17 +100,17 @@ public:
// Member Functions
// Component access
// Component Access
inline const Cmpt& a() const;
inline const Cmpt& b() const;
inline const Cmpt& c() const;
inline const Cmpt& d() const;
const Cmpt& a() const noexcept { return this->v_[A]; }
const Cmpt& b() const noexcept { return this->v_[B]; }
const Cmpt& c() const noexcept { return this->v_[C]; }
const Cmpt& d() const noexcept { return this->v_[D]; }
inline Cmpt& a();
inline Cmpt& b();
inline Cmpt& c();
inline Cmpt& d();
Cmpt& a() noexcept { return this->v_[A]; }
Cmpt& b() noexcept { return this->v_[B]; }
Cmpt& c() noexcept { return this->v_[C]; }
Cmpt& d() noexcept { return this->v_[D]; }
// Operations

View File

@ -63,64 +63,6 @@ inline Foam::Barycentric<Cmpt>::Barycentric
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::Barycentric<Cmpt>::a() const
{
return this->v_[A];
}
template<class Cmpt>
inline const Cmpt& Foam::Barycentric<Cmpt>::b() const
{
return this->v_[B];
}
template<class Cmpt>
inline const Cmpt& Foam::Barycentric<Cmpt>::c() const
{
return this->v_[C];
}
template<class Cmpt>
inline const Cmpt& Foam::Barycentric<Cmpt>::d() const
{
return this->v_[D];
}
template<class Cmpt>
inline Cmpt& Foam::Barycentric<Cmpt>::a()
{
return this->v_[A];
}
template<class Cmpt>
inline Cmpt& Foam::Barycentric<Cmpt>::b()
{
return this->v_[B];
}
template<class Cmpt>
inline Cmpt& Foam::Barycentric<Cmpt>::c()
{
return this->v_[C];
}
template<class Cmpt>
inline Cmpt& Foam::Barycentric<Cmpt>::d()
{
return this->v_[D];
}
// * * * * * * * * * * * * * * * Member Operations * * * * * * * * * * * * * //
template<class Cmpt>

View File

@ -109,22 +109,22 @@ public:
// Member Functions
// Component access
// Component Access
inline const Cmpt& xa() const;
inline const Cmpt& xb() const;
inline const Cmpt& xc() const;
inline const Cmpt& xd() const;
const Cmpt& xa() const noexcept { return this->v_[XA]; }
const Cmpt& xb() const noexcept { return this->v_[XB]; }
const Cmpt& xc() const noexcept { return this->v_[XC]; }
const Cmpt& xd() const noexcept { return this->v_[XD]; }
inline const Cmpt& ya() const;
inline const Cmpt& yb() const;
inline const Cmpt& yc() const;
inline const Cmpt& yd() const;
const Cmpt& ya() const noexcept { return this->v_[YA]; }
const Cmpt& yb() const noexcept { return this->v_[YB]; }
const Cmpt& yc() const noexcept { return this->v_[YC]; }
const Cmpt& yd() const noexcept { return this->v_[YD]; }
inline const Cmpt& za() const;
inline const Cmpt& zb() const;
inline const Cmpt& zc() const;
inline const Cmpt& zd() const;
const Cmpt& za() const noexcept { return this->v_[ZA]; }
const Cmpt& zb() const noexcept { return this->v_[ZB]; }
const Cmpt& zc() const noexcept { return this->v_[ZC]; }
const Cmpt& zd() const noexcept { return this->v_[ZD]; }
// Row-barycentric access

View File

@ -88,90 +88,6 @@ inline Foam::BarycentricTensor<Cmpt>::BarycentricTensor
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::xa() const
{
return this->v_[XA];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::xb() const
{
return this->v_[XB];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::xc() const
{
return this->v_[XC];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::xd() const
{
return this->v_[XD];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::ya() const
{
return this->v_[YA];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::yb() const
{
return this->v_[YB];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::yc() const
{
return this->v_[YC];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::yd() const
{
return this->v_[YD];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::za() const
{
return this->v_[ZA];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::zb() const
{
return this->v_[ZB];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::zc() const
{
return this->v_[ZC];
}
template<class Cmpt>
inline const Cmpt& Foam::BarycentricTensor<Cmpt>::zd() const
{
return this->v_[ZD];
}
template<class Cmpt>
inline Foam::Barycentric<Cmpt> Foam::BarycentricTensor<Cmpt>::x() const
{

View File

@ -94,15 +94,15 @@ public:
// Member Functions
// Component access
// Component Access
inline const Cmpt& a() const;
inline const Cmpt& b() const;
inline const Cmpt& c() const;
const Cmpt& a() const noexcept { return this->v_[A]; }
const Cmpt& b() const noexcept { return this->v_[B]; }
const Cmpt& c() const noexcept { return this->v_[C]; }
inline Cmpt& a();
inline Cmpt& b();
inline Cmpt& c();
Cmpt& a() noexcept { return this->v_[A]; }
Cmpt& b() noexcept { return this->v_[B]; }
Cmpt& c() noexcept { return this->v_[C]; }
// Operations, Tests

View File

@ -60,50 +60,6 @@ inline Foam::Barycentric2D<Cmpt>::Barycentric2D
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::Barycentric2D<Cmpt>::a() const
{
return this->v_[A];
}
template<class Cmpt>
inline const Cmpt& Foam::Barycentric2D<Cmpt>::b() const
{
return this->v_[B];
}
template<class Cmpt>
inline const Cmpt& Foam::Barycentric2D<Cmpt>::c() const
{
return this->v_[C];
}
template<class Cmpt>
inline Cmpt& Foam::Barycentric2D<Cmpt>::a()
{
return this->v_[A];
}
template<class Cmpt>
inline Cmpt& Foam::Barycentric2D<Cmpt>::b()
{
return this->v_[B];
}
template<class Cmpt>
inline Cmpt& Foam::Barycentric2D<Cmpt>::c()
{
return this->v_[C];
}
// * * * * * * * * * * * * * * * Member Operations * * * * * * * * * * * * * //
template<class Cmpt>

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,15 +106,15 @@ public:
// Member Functions
// Access
// Component Access
inline const Cmpt& xx() const;
inline const Cmpt& yy() const;
inline const Cmpt& zz() const;
const Cmpt& xx() const noexcept { return this->v_[XX]; }
const Cmpt& yy() const noexcept { return this->v_[YY]; }
const Cmpt& zz() const noexcept { return this->v_[ZZ]; }
inline Cmpt& xx();
inline Cmpt& yy();
inline Cmpt& zz();
Cmpt& xx() noexcept { return this->v_[XX]; }
Cmpt& yy() noexcept { return this->v_[YY]; }
Cmpt& zz() noexcept { return this->v_[ZZ]; }
};

View File

@ -70,46 +70,6 @@ inline Foam::DiagTensor<Cmpt>::DiagTensor(Istream& is)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::DiagTensor<Cmpt>::xx() const
{
return this->v_[XX];
}
template<class Cmpt>
inline const Cmpt& Foam::DiagTensor<Cmpt>::yy() const
{
return this->v_[YY];
}
template<class Cmpt>
inline const Cmpt& Foam::DiagTensor<Cmpt>::zz() const
{
return this->v_[ZZ];
}
template<class Cmpt>
inline Cmpt& Foam::DiagTensor<Cmpt>::xx()
{
return this->v_[XX];
}
template<class Cmpt>
inline Cmpt& Foam::DiagTensor<Cmpt>::yy()
{
return this->v_[YY];
}
template<class Cmpt>
inline Cmpt& Foam::DiagTensor<Cmpt>::zz()
{
return this->v_[ZZ];
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,8 +41,8 @@ See also
\*---------------------------------------------------------------------------*/
#ifndef MatrixSpace_H
#define MatrixSpace_H
#ifndef Foam_MatrixSpace_H
#define Foam_MatrixSpace_H
#include "VectorSpace.H"
@ -238,37 +238,40 @@ public:
//- Fast const element access using compile-time addressing
template<direction Row, direction Col>
inline const Cmpt& elmt() const;
inline const Cmpt& elmt() const noexcept;
//- Fast element access using compile-time addressing
template<direction Row, direction Col>
inline Cmpt& elmt();
inline Cmpt& elmt() noexcept;
// Const element access functions for a 3x3
// Compile-time errors are generated for inappropriate use
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& xz() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
inline const Cmpt& yz() const;
inline const Cmpt& zx() const;
inline const Cmpt& zy() const;
inline const Cmpt& zz() const;
const Cmpt& xx() const noexcept { return elmt<0,0>(); }
const Cmpt& xy() const noexcept { return elmt<0,1>(); }
const Cmpt& xz() const noexcept { return elmt<0,2>(); }
const Cmpt& yx() const noexcept { return elmt<1,0>(); }
const Cmpt& yy() const noexcept { return elmt<1,1>(); }
const Cmpt& yz() const noexcept { return elmt<1,2>(); }
const Cmpt& zx() const noexcept { return elmt<2,0>(); }
const Cmpt& zy() const noexcept { return elmt<2,1>(); }
const Cmpt& zz() const noexcept { return elmt<2,2>(); }
// Element access functions for a 3x3
// Compile-time errors are generated for inappropriate use
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& xz();
inline Cmpt& yx();
inline Cmpt& yy();
inline Cmpt& yz();
inline Cmpt& zx();
inline Cmpt& zy();
inline Cmpt& zz();
Cmpt& xx() noexcept { return elmt<0,0>(); }
Cmpt& xy() noexcept { return elmt<0,1>(); }
Cmpt& xz() noexcept { return elmt<0,2>(); }
Cmpt& yx() noexcept { return elmt<1,0>(); }
Cmpt& yy() noexcept { return elmt<1,1>(); }
Cmpt& yz() noexcept { return elmt<1,2>(); }
Cmpt& zx() noexcept { return elmt<2,0>(); }
Cmpt& zy() noexcept { return elmt<2,1>(); }
Cmpt& zz() noexcept { return elmt<2,2>(); }
//- Return the transpose of the matrix
inline typename typeOfTranspose<Cmpt, Form>::type T() const;

View File

@ -125,7 +125,8 @@ Block(msType& matrix)
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
template<Foam::direction Row, Foam::direction Col>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::elmt() const
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::elmt()
const noexcept
{
static_assert(Row < Mrows && Col < Ncols, "Address outside matrix");
return this->v_[Row*Ncols + Col];
@ -135,136 +136,13 @@ inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::elmt() const
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
template<Foam::direction Row, Foam::direction Col>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::elmt()
noexcept
{
static_assert(Row < Mrows && Col < Ncols, "Address outside matrix");
return this->v_[Row*Ncols + Col];
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::xx() const
{
return elmt<0, 0>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::xx()
{
return elmt<0, 0>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::xy() const
{
return elmt<0,1>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::xy()
{
return elmt<0,1>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::xz() const
{
return elmt<0,2>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::xz()
{
return elmt<0,2>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::yx() const
{
return elmt<1,0>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::yx()
{
return elmt<1,0>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::yy() const
{
return elmt<1,1>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::yy()
{
return elmt<1,1>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::yz() const
{
return elmt<1,2>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::yz()
{
return elmt<1,2>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::zx() const
{
return elmt<2,0>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::zx()
{
return elmt<2,0>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::zy() const
{
return elmt<2,1>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::zy()
{
return elmt<2,1>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::zz() const
{
return elmt<2,2>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::zz()
{
return elmt<2,2>();
}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>
Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::identity()

View File

@ -68,8 +68,8 @@ public:
// Constructors
//- Construct null
inline RowVector();
//- Default construct
RowVector() = default;
//- Construct initialized to zero
inline RowVector(const Foam::zero);
@ -82,20 +82,20 @@ public:
inline RowVector(const Cmpt& rvx, const Cmpt& rvy, const Cmpt& rvz);
//- Construct from Istream
inline RowVector(Istream&);
inline explicit RowVector(Istream&);
// Member Functions
// Access
// Component Access
inline const Cmpt& x() const;
inline const Cmpt& y() const;
inline const Cmpt& z() const;
const Cmpt& x() const noexcept { return this->v_[X]; }
const Cmpt& y() const noexcept { return this->v_[Y]; }
const Cmpt& z() const noexcept { return this->v_[Z]; }
inline Cmpt& x();
inline Cmpt& y();
inline Cmpt& z();
Cmpt& x() noexcept { return this->v_[X]; }
Cmpt& y() noexcept { return this->v_[Y]; }
Cmpt& z() noexcept { return this->v_[Z]; }
};

View File

@ -27,11 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::RowVector<Cmpt>::RowVector()
{}
template<class Cmpt>
inline Foam::RowVector<Cmpt>::RowVector(const Foam::zero)
:
@ -71,44 +66,4 @@ inline Foam::RowVector<Cmpt>::RowVector(Istream& is)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::RowVector<Cmpt>::x() const
{
return this->v_[X];
}
template<class Cmpt>
inline const Cmpt& Foam::RowVector<Cmpt>::y() const
{
return this->v_[Y];
}
template<class Cmpt>
inline const Cmpt& Foam::RowVector<Cmpt>::z() const
{
return this->v_[Z];
}
template<class Cmpt>
inline Cmpt& Foam::RowVector<Cmpt>::x()
{
return this->v_[X];
}
template<class Cmpt>
inline Cmpt& Foam::RowVector<Cmpt>::y()
{
return this->v_[Y];
}
template<class Cmpt>
inline Cmpt& Foam::RowVector<Cmpt>::z()
{
return this->v_[Z];
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -117,10 +117,11 @@ public:
// Member Functions
// Access
// Component Access
inline const Cmpt& ii() const;
inline Cmpt& ii();
const Cmpt& ii() const noexcept { return this->v_[II]; }
Cmpt& ii() noexcept { return this->v_[II]; }
// Tensor Operations

View File

@ -64,20 +64,6 @@ inline Foam::SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::SphericalTensor<Cmpt>::ii() const
{
return this->v_[II];
}
template<class Cmpt>
inline Cmpt& Foam::SphericalTensor<Cmpt>::ii()
{
return this->v_[II];
}
template<class Cmpt>
inline const Foam::SphericalTensor<Cmpt>&
Foam::SphericalTensor<Cmpt>::T() const

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,8 +39,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef SphericalTensor2D_H
#define SphericalTensor2D_H
#ifndef Foam_SphericalTensor2D_H
#define Foam_SphericalTensor2D_H
#include "contiguous.H"
#include "VectorSpace.H"
@ -116,10 +116,11 @@ public:
// Member Functions
// Access
// Component Access
inline const Cmpt& ii() const;
inline Cmpt& ii();
const Cmpt& ii() const noexcept { return this->v_[II]; }
Cmpt& ii() noexcept { return this->v_[II]; }
};

View File

@ -61,22 +61,6 @@ inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D(Istream& is)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::SphericalTensor2D<Cmpt>::ii() const
{
return this->v_[II];
}
template<class Cmpt>
inline Cmpt& Foam::SphericalTensor2D<Cmpt>::ii()
{
return this->v_[II];
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -128,25 +128,25 @@ public:
// Component Access
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& xz() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
inline const Cmpt& yz() const;
inline const Cmpt& zx() const;
inline const Cmpt& zy() const;
inline const Cmpt& zz() const;
const Cmpt& xx() const noexcept { return this->v_[XX]; }
const Cmpt& xy() const noexcept { return this->v_[XY]; }
const Cmpt& xz() const noexcept { return this->v_[XZ]; }
const Cmpt& yx() const noexcept { return this->v_[XY]; }
const Cmpt& yy() const noexcept { return this->v_[YY]; }
const Cmpt& yz() const noexcept { return this->v_[YZ]; }
const Cmpt& zx() const noexcept { return this->v_[XZ]; }
const Cmpt& zy() const noexcept { return this->v_[YZ]; }
const Cmpt& zz() const noexcept { return this->v_[ZZ]; }
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& xz();
inline Cmpt& yx();
inline Cmpt& yy();
inline Cmpt& yz();
inline Cmpt& zx();
inline Cmpt& zy();
inline Cmpt& zz();
Cmpt& xx() noexcept { return this->v_[XX]; }
Cmpt& xy() noexcept { return this->v_[XY]; }
Cmpt& xz() noexcept { return this->v_[XZ]; }
Cmpt& yx() noexcept { return this->v_[XY]; }
Cmpt& yy() noexcept { return this->v_[YY]; }
Cmpt& yz() noexcept { return this->v_[YZ]; }
Cmpt& zx() noexcept { return this->v_[XZ]; }
Cmpt& zy() noexcept { return this->v_[YZ]; }
Cmpt& zz() noexcept { return this->v_[ZZ]; }
// Column-vector access

View File

@ -93,116 +93,6 @@ inline Foam::SymmTensor<Cmpt>::SymmTensor(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor<Cmpt>::xx() const
{
return this->v_[XX];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor<Cmpt>::xy() const
{
return this->v_[XY];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor<Cmpt>::xz() const
{
return this->v_[XZ];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor<Cmpt>::yx() const
{
return this->v_[XY];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor<Cmpt>::yy() const
{
return this->v_[YY];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor<Cmpt>::yz() const
{
return this->v_[YZ];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor<Cmpt>::zx() const
{
return this->v_[XZ];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor<Cmpt>::zy() const
{
return this->v_[YZ];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor<Cmpt>::zz() const
{
return this->v_[ZZ];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor<Cmpt>::xx()
{
return this->v_[XX];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor<Cmpt>::xy()
{
return this->v_[XY];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor<Cmpt>::xz()
{
return this->v_[XZ];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor<Cmpt>::yx()
{
return this->v_[XY];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor<Cmpt>::yy()
{
return this->v_[YY];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor<Cmpt>::yz()
{
return this->v_[YZ];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor<Cmpt>::zx()
{
return this->v_[XZ];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor<Cmpt>::zy()
{
return this->v_[YZ];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor<Cmpt>::zz()
{
return this->v_[ZZ];
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::x() const
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,8 +39,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef SymmTensor2D_H
#define SymmTensor2D_H
#ifndef Foam_SymmTensor2D_H
#define Foam_SymmTensor2D_H
#include "contiguous.H"
#include "Vector2D.H"
@ -119,28 +119,30 @@ public:
// Member Functions
// Access
// Component Access
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
const Cmpt& xx() const noexcept { return this->v_[XX]; }
const Cmpt& xy() const noexcept { return this->v_[XY]; }
const Cmpt& yx() const noexcept { return this->v_[XY]; }
const Cmpt& yy() const noexcept { return this->v_[YY]; }
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& yx();
inline Cmpt& yy();
Cmpt& xx() noexcept { return this->v_[XX]; }
Cmpt& xy() noexcept { return this->v_[XY]; }
Cmpt& yx() noexcept { return this->v_[XY]; }
Cmpt& yy() noexcept { return this->v_[YY]; }
// Diagonal access and manipulation
// Diagonal access and manipulation
//- Extract the diagonal as a vector
inline Vector2D<Cmpt> diag() const;
//- Extract the diagonal as a vector
inline Vector2D<Cmpt> diag() const;
//- Set values of the diagonal
inline void diag(const Vector2D<Cmpt>& v);
//- Set values of the diagonal
inline void diag(const Vector2D<Cmpt>& v);
// Tensor Operations
//- Return non-Hermitian transpose
inline const SymmTensor2D<Cmpt>& T() const;

View File

@ -76,56 +76,6 @@ inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor2D<Cmpt>::xx() const
{
return this->v_[XX];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor2D<Cmpt>::xy() const
{
return this->v_[XY];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor2D<Cmpt>::yx() const
{
return this->v_[XY];
}
template<class Cmpt>
inline const Cmpt& Foam::SymmTensor2D<Cmpt>::yy() const
{
return this->v_[YY];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor2D<Cmpt>::xx()
{
return this->v_[XX];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor2D<Cmpt>::xy()
{
return this->v_[XY];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor2D<Cmpt>::yx()
{
return this->v_[XY];
}
template<class Cmpt>
inline Cmpt& Foam::SymmTensor2D<Cmpt>::yy()
{
return this->v_[YY];
}
template<class Cmpt>
inline Foam::Vector2D<Cmpt> Foam::SymmTensor2D<Cmpt>::diag() const
{

View File

@ -161,27 +161,27 @@ public:
// Member Functions
// Component access
// Component Access
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& xz() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
inline const Cmpt& yz() const;
inline const Cmpt& zx() const;
inline const Cmpt& zy() const;
inline const Cmpt& zz() const;
const Cmpt& xx() const noexcept { return this->v_[XX]; }
const Cmpt& xy() const noexcept { return this->v_[XY]; }
const Cmpt& xz() const noexcept { return this->v_[XZ]; }
const Cmpt& yx() const noexcept { return this->v_[YX]; }
const Cmpt& yy() const noexcept { return this->v_[YY]; }
const Cmpt& yz() const noexcept { return this->v_[YZ]; }
const Cmpt& zx() const noexcept { return this->v_[ZX]; }
const Cmpt& zy() const noexcept { return this->v_[ZY]; }
const Cmpt& zz() const noexcept { return this->v_[ZZ]; }
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& xz();
inline Cmpt& yx();
inline Cmpt& yy();
inline Cmpt& yz();
inline Cmpt& zx();
inline Cmpt& zy();
inline Cmpt& zz();
Cmpt& xx() noexcept { return this->v_[XX]; }
Cmpt& xy() noexcept { return this->v_[XY]; }
Cmpt& xz() noexcept { return this->v_[XZ]; }
Cmpt& yx() noexcept { return this->v_[YX]; }
Cmpt& yy() noexcept { return this->v_[YY]; }
Cmpt& yz() noexcept { return this->v_[YZ]; }
Cmpt& zx() noexcept { return this->v_[ZX]; }
Cmpt& zy() noexcept { return this->v_[ZY]; }
Cmpt& zz() noexcept { return this->v_[ZZ]; }
// Column-vector access

View File

@ -149,132 +149,6 @@ inline Foam::Tensor<Cmpt>::Tensor(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::Tensor<Cmpt>::xx() const
{
return this->v_[XX];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor<Cmpt>::xy() const
{
return this->v_[XY];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor<Cmpt>::xz() const
{
return this->v_[XZ];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor<Cmpt>::yx() const
{
return this->v_[YX];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor<Cmpt>::yy() const
{
return this->v_[YY];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor<Cmpt>::yz() const
{
return this->v_[YZ];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor<Cmpt>::zx() const
{
return this->v_[ZX];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor<Cmpt>::zy() const
{
return this->v_[ZY];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor<Cmpt>::zz() const
{
return this->v_[ZZ];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor<Cmpt>::xx()
{
return this->v_[XX];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor<Cmpt>::xy()
{
return this->v_[XY];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor<Cmpt>::xz()
{
return this->v_[XZ];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor<Cmpt>::yx()
{
return this->v_[YX];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor<Cmpt>::yy()
{
return this->v_[YY];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor<Cmpt>::yz()
{
return this->v_[YZ];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor<Cmpt>::zx()
{
return this->v_[ZX];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor<Cmpt>::zy()
{
return this->v_[ZY];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor<Cmpt>::zz()
{
return this->v_[ZZ];
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::x() const
{

View File

@ -127,17 +127,17 @@ public:
// Member Functions
// Component access
// Component Access
inline const Cmpt& xx() const;
inline const Cmpt& xy() const;
inline const Cmpt& yx() const;
inline const Cmpt& yy() const;
const Cmpt& xx() const noexcept { return this->v_[XX]; }
const Cmpt& xy() const noexcept { return this->v_[XY]; }
const Cmpt& yx() const noexcept { return this->v_[YX]; }
const Cmpt& yy() const noexcept { return this->v_[YY]; }
inline Cmpt& xx();
inline Cmpt& xy();
inline Cmpt& yx();
inline Cmpt& yy();
Cmpt& xx() noexcept { return this->v_[XX]; }
Cmpt& xy() noexcept { return this->v_[XY]; }
Cmpt& yx() noexcept { return this->v_[YX]; }
Cmpt& yy() noexcept { return this->v_[YY]; }
// Column-vector access

View File

@ -94,56 +94,6 @@ inline Foam::Tensor2D<Cmpt>::Tensor2D(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::Tensor2D<Cmpt>::xx() const
{
return this->v_[XX];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor2D<Cmpt>::xy() const
{
return this->v_[XY];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor2D<Cmpt>::yx() const
{
return this->v_[YX];
}
template<class Cmpt>
inline const Cmpt& Foam::Tensor2D<Cmpt>::yy() const
{
return this->v_[YY];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor2D<Cmpt>::xx()
{
return this->v_[XX];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor2D<Cmpt>::xy()
{
return this->v_[XY];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor2D<Cmpt>::yx()
{
return this->v_[YX];
}
template<class Cmpt>
inline Cmpt& Foam::Tensor2D<Cmpt>::yy()
{
return this->v_[YY];
}
template<class Cmpt>
inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::x() const
{

View File

@ -112,23 +112,25 @@ public:
// Member Functions
//- Access to the vector x component
inline const Cmpt& x() const;
//- Access to the vector y component
inline const Cmpt& y() const;
//- Access to the vector z component
inline const Cmpt& z() const;
// Component Access
//- Access to the vector x component
inline Cmpt& x();
const Cmpt& x() const noexcept { return this->v_[X]; }
//- Access to the vector y component
inline Cmpt& y();
const Cmpt& y() const noexcept { return this->v_[Y]; }
//- Access to the vector z component
inline Cmpt& z();
const Cmpt& z() const noexcept { return this->v_[Z]; }
//- Access to the vector x component
Cmpt& x() noexcept { return this->v_[X]; }
//- Access to the vector y component
Cmpt& y() noexcept { return this->v_[Y]; }
//- Access to the vector z component
Cmpt& z() noexcept { return this->v_[Z]; }
// Vector Operations
@ -153,6 +155,38 @@ public:
//- Cross-product of \c this with another Vector.
inline Vector<Cmpt> cross(const Vector<Cmpt>& v2) const;
//- The L2-norm distance from another vector.
//- The mag() of the difference.
inline scalar dist(const Vector<Cmpt>& v2) const;
//- The L2-norm distance squared from another vector.
//- The magSqr() of the difference.
inline scalar distSqr(const Vector<Cmpt>& v2) const;
// Comparision Operations
//- Lexicographically compare \em a and \em b with order (x:y:z)
static inline bool less_xyz
(
const Vector<Cmpt>& a,
const Vector<Cmpt>& b
);
//- Lexicographically compare \em a and \em b with order (y:z:x)
static inline bool less_yzx
(
const Vector<Cmpt>& a,
const Vector<Cmpt>& b
);
//- Lexicographically compare \em a and \em b with order (z:x:y)
static inline bool less_zxy
(
const Vector<Cmpt>& a,
const Vector<Cmpt>& b
);
};

View File

@ -67,46 +67,6 @@ inline Foam::Vector<Cmpt>::Vector(Istream& is)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::Vector<Cmpt>::x() const
{
return this->v_[X];
}
template<class Cmpt>
inline const Cmpt& Foam::Vector<Cmpt>::y() const
{
return this->v_[Y];
}
template<class Cmpt>
inline const Cmpt& Foam::Vector<Cmpt>::z() const
{
return this->v_[Z];
}
template<class Cmpt>
inline Cmpt& Foam::Vector<Cmpt>::x()
{
return this->v_[X];
}
template<class Cmpt>
inline Cmpt& Foam::Vector<Cmpt>::y()
{
return this->v_[Y];
}
template<class Cmpt>
inline Cmpt& Foam::Vector<Cmpt>::z()
{
return this->v_[Z];
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
@ -172,6 +132,99 @@ Foam::Vector<Cmpt>::cross(const Vector<Cmpt>& v2) const
}
template<class Cmpt>
inline Foam::scalar Foam::Vector<Cmpt>::distSqr(const Vector<Cmpt>& v2) const
{
return
(
Foam::magSqr(v2.x() - this->x())
+ Foam::magSqr(v2.y() - this->y())
+ Foam::magSqr(v2.z() - this->z())
);
}
template<class Cmpt>
inline Foam::scalar Foam::Vector<Cmpt>::dist(const Vector<Cmpt>& v2) const
{
return ::sqrt(this->distSqr(v2));
}
// * * * * * * * * * * * * * Comparision Operations * * * * * * * * * * * * //
template<class Cmpt>
inline bool
Foam::Vector<Cmpt>::less_xyz(const Vector<Cmpt>& a, const Vector<Cmpt>& b)
{
return
(
(a.x() < b.x()) // Component is less
||
(
!(b.x() < a.x()) // Equal? Check next component
&&
(
(a.y() < b.y()) // Component is less
||
(
!(b.y() < a.y()) // Equal? Check next component
&& (a.z() < b.z())
)
)
)
);
}
template<class Cmpt>
inline bool
Foam::Vector<Cmpt>::less_yzx(const Vector<Cmpt>& a, const Vector<Cmpt>& b)
{
return
(
(a.y() < b.y()) // Component is less
||
(
!(b.y() < a.y()) // Equal? Check next component
&&
(
(a.z() < b.z()) // Component is less
||
(
!(b.z() < a.z()) // Equal? Check next component
&& (a.x() < b.x())
)
)
)
);
}
template<class Cmpt>
inline bool
Foam::Vector<Cmpt>::less_zxy(const Vector<Cmpt>& a, const Vector<Cmpt>& b)
{
return
(
(a.z() < b.z()) // Component is less
||
(
!(b.z() < a.z()) // Equal? Check next component
&&
(
(a.x() < b.x()) // Component is less
||
(
!(b.x() < a.x()) // Equal? Check next component
&& (a.y() < b.y())
)
)
)
);
}
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
namespace Foam

View File

@ -40,8 +40,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef boolVector_H
#define boolVector_H
#ifndef Foam_boolVector_H
#define Foam_boolVector_H
#include "FixedList.H"
@ -126,25 +126,25 @@ public:
inline unsigned int count(const bool on=true) const;
// Access
// Component Access
//- The x component
inline bool x() const;
bool x() const { return operator[](boolVector::X); }
//- The y component
inline bool y() const;
bool y() const { return operator[](boolVector::Y); }
//- The z component
inline bool z() const;
bool z() const { return operator[](boolVector::Z); }
//- The x component
inline bool& x();
bool& x() { return operator[](boolVector::X); }
//- The y component
inline bool& y();
bool& y() { return operator[](boolVector::Y); }
//- The z component
inline bool& z();
bool& z() { return operator[](boolVector::Z); }
// Edit

View File

@ -107,15 +107,6 @@ inline unsigned int Foam::boolVector::count(const bool on) const
}
inline bool Foam::boolVector::x() const { return operator[](boolVector::X); }
inline bool Foam::boolVector::y() const { return operator[](boolVector::Y); }
inline bool Foam::boolVector::z() const { return operator[](boolVector::Z); }
inline bool& Foam::boolVector::x() { return operator[](boolVector::X); }
inline bool& Foam::boolVector::y() { return operator[](boolVector::Y); }
inline bool& Foam::boolVector::z() { return operator[](boolVector::Z); }
inline void Foam::boolVector::flip()
{
for (bool& val : *this)

View File

@ -104,7 +104,7 @@ const char* const Foam::Vector<double>::vsType::typeName = "doubleVector";
const Foam::Vector<Type> Foam::Vector<Type>::vsType::rootMin \
( \
Vector<Type>::uniform(-Prefix##ROOTVGREAT) \
); \
);
defineTraits(float, floatScalar);

View File

@ -104,18 +104,22 @@ public:
// Member Functions
//- Access to the vector x component
inline const Cmpt& x() const;
//- Access to the vector y component
inline const Cmpt& y() const;
// Component Access
//- Access to the vector x component
inline Cmpt& x();
const Cmpt& x() const noexcept { return this->v_[X]; }
//- Access to the vector y component
inline Cmpt& y();
const Cmpt& y() const noexcept { return this->v_[Y]; }
//- Access to the vector x component
Cmpt& x() noexcept { return this->v_[X]; }
//- Access to the vector y component
Cmpt& y() noexcept { return this->v_[Y]; }
// Vector Operations
//- Normalise the vector by its magnitude
// For small magnitudes (less than ROOTVSMALL) set to zero.

View File

@ -62,34 +62,6 @@ inline Foam::Vector2D<Cmpt>::Vector2D(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::Vector2D<Cmpt>::x() const
{
return this->v_[X];
}
template<class Cmpt>
inline const Cmpt& Foam::Vector2D<Cmpt>::y() const
{
return this->v_[Y];
}
template<class Cmpt>
inline Cmpt& Foam::Vector2D<Cmpt>::x()
{
return this->v_[X];
}
template<class Cmpt>
inline Cmpt& Foam::Vector2D<Cmpt>::y()
{
return this->v_[Y];
}
template<class Cmpt>
inline Foam::Vector2D<Cmpt>& Foam::Vector2D<Cmpt>::normalise(const scalar tol)
{

View File

@ -856,21 +856,6 @@ inline bool operator!=
}
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator>
(
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
for (direction i=0; i<Ncmpts; ++i)
{
if (!(vs1.v_[i] > vs2.v_[i])) return false;
}
return true;
}
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator<
(
@ -878,6 +863,7 @@ inline bool operator<
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
// Compare all components, stop at first non less-than component
for (direction i=0; i<Ncmpts; ++i)
{
if (!(vs1.v_[i] < vs2.v_[i])) return false;
@ -886,6 +872,28 @@ inline bool operator<
}
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator<=
(
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
return !(vs2 < vs1);
}
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator>
(
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
return (vs2 < vs1);
}
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator>=
(
@ -897,17 +905,6 @@ inline bool operator>=
}
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator<=
(
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
return !(vs1 > vs2);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -135,14 +135,14 @@ Foam::Polynomial<PolySize>::Polynomial(const word& name, Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<int PolySize>
bool Foam::Polynomial<PolySize>::logActive() const
bool Foam::Polynomial<PolySize>::logActive() const noexcept
{
return logActive_;
}
template<int PolySize>
Foam::scalar Foam::Polynomial<PolySize>::logCoeff() const
Foam::scalar Foam::Polynomial<PolySize>::logCoeff() const noexcept
{
return logCoeff_;
}

View File

@ -50,8 +50,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef Polynomial_H
#define Polynomial_H
#ifndef Foam_Polynomial_H
#define Foam_Polynomial_H
#include "word.H"
#include "scalar.H"
@ -125,10 +125,10 @@ public:
// Access
//- Return true if the log term is active
bool logActive() const;
bool logActive() const noexcept;
//- Return the log coefficient
scalar logCoeff() const;
scalar logCoeff() const noexcept;
// Evaluation

View File

@ -81,7 +81,7 @@ public:
// Constructors
//- Construct null
//- Default construct as 'nan'
inline Roots();
//- Construct with a uniform value

View File

@ -96,8 +96,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cubicEqn_H
#define cubicEqn_H
#ifndef Foam_cubicEqn_H
#define Foam_cubicEqn_H
#include "Roots.H"
@ -122,8 +122,8 @@ public:
// Constructors
//- Construct null
inline cubicEqn();
//- Default construct
cubicEqn() = default;
//- Construct initialized to zero
inline cubicEqn(const Foam::zero);
@ -142,15 +142,16 @@ public:
// Access
inline scalar a() const;
inline scalar b() const;
inline scalar c() const;
inline scalar d() const;
scalar a() const noexcept { return this->v_[A]; }
scalar b() const noexcept { return this->v_[B]; }
scalar c() const noexcept { return this->v_[C]; }
scalar d() const noexcept { return this->v_[D]; }
scalar& a() noexcept { return this->v_[A]; }
scalar& b() noexcept { return this->v_[B]; }
scalar& c() noexcept { return this->v_[C]; }
scalar& d() noexcept { return this->v_[D]; }
inline scalar& a();
inline scalar& b();
inline scalar& c();
inline scalar& d();
// Evaluate

View File

@ -27,10 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::cubicEqn::cubicEqn()
{}
inline Foam::cubicEqn::cubicEqn(const Foam::zero)
:
VectorSpace<cubicEqn, scalar, 4>(Foam::zero{})
@ -54,54 +50,6 @@ inline Foam::cubicEqn::cubicEqn
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::scalar Foam::cubicEqn::a() const
{
return this->v_[A];
}
inline Foam::scalar Foam::cubicEqn::b() const
{
return this->v_[B];
}
inline Foam::scalar Foam::cubicEqn::c() const
{
return this->v_[C];
}
inline Foam::scalar Foam::cubicEqn::d() const
{
return this->v_[D];
}
inline Foam::scalar& Foam::cubicEqn::a()
{
return this->v_[A];
}
inline Foam::scalar& Foam::cubicEqn::b()
{
return this->v_[B];
}
inline Foam::scalar& Foam::cubicEqn::c()
{
return this->v_[C];
}
inline Foam::scalar& Foam::cubicEqn::d()
{
return this->v_[D];
}
inline Foam::scalar Foam::cubicEqn::value(const scalar x) const
{
return x*(x*(x*a() + b()) + c()) + d();

View File

@ -44,8 +44,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef linearEqn_H
#define linearEqn_H
#ifndef Foam_linearEqn_H
#define Foam_linearEqn_H
#include "Roots.H"
@ -70,8 +70,8 @@ public:
// Constructors
//- Construct null
inline linearEqn();
//- Default construct
linearEqn() = default;
//- Construct initialized to zero
inline linearEqn(const Foam::zero);
@ -84,11 +84,12 @@ public:
// Access
inline scalar a() const;
inline scalar b() const;
scalar a() const noexcept { return this->v_[A]; }
scalar b() const noexcept { return this->v_[B]; }
scalar& a() noexcept { return this->v_[A]; }
scalar& b() noexcept { return this->v_[B]; }
inline scalar& a();
inline scalar& b();
// Evaluate

View File

@ -28,10 +28,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::linearEqn::linearEqn()
{}
inline Foam::linearEqn::linearEqn(const Foam::zero)
:
VectorSpace<linearEqn, scalar, 2>(Foam::zero{})
@ -47,30 +43,6 @@ inline Foam::linearEqn::linearEqn(const scalar a, const scalar b)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::scalar Foam::linearEqn::a() const
{
return this->v_[A];
}
inline Foam::scalar Foam::linearEqn::b() const
{
return this->v_[B];
}
inline Foam::scalar& Foam::linearEqn::a()
{
return this->v_[A];
}
inline Foam::scalar& Foam::linearEqn::b()
{
return this->v_[B];
}
inline Foam::scalar Foam::linearEqn::value(const scalar x) const
{
return x*a() + b();

View File

@ -72,8 +72,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef quadraticEqn_H
#define quadraticEqn_H
#ifndef Foam_quadraticEqn_H
#define Foam_quadraticEqn_H
#include "Roots.H"
@ -98,8 +98,8 @@ public:
// Constructors
//- Construct null
inline quadraticEqn();
//- Default construct
quadraticEqn() = default;
//- Construct initialized to zero
inline quadraticEqn(const Foam::zero);
@ -112,13 +112,14 @@ public:
// Access
inline scalar a() const;
inline scalar b() const;
inline scalar c() const;
scalar a() const noexcept { return this->v_[A]; }
scalar b() const noexcept { return this->v_[B]; }
scalar c() const noexcept { return this->v_[C]; }
scalar& a() noexcept { return this->v_[A]; }
scalar& b() noexcept { return this->v_[B]; }
scalar& c() noexcept { return this->v_[C]; }
inline scalar& a();
inline scalar& b();
inline scalar& c();
// Evaluate

View File

@ -27,10 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::quadraticEqn::quadraticEqn()
{}
inline Foam::quadraticEqn::quadraticEqn(const Foam::zero)
:
VectorSpace<quadraticEqn, scalar, 3>(Foam::zero{})
@ -52,42 +48,6 @@ inline Foam::quadraticEqn::quadraticEqn
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::scalar Foam::quadraticEqn::a() const
{
return this->v_[A];
}
inline Foam::scalar Foam::quadraticEqn::b() const
{
return this->v_[B];
}
inline Foam::scalar Foam::quadraticEqn::c() const
{
return this->v_[C];
}
inline Foam::scalar& Foam::quadraticEqn::a()
{
return this->v_[A];
}
inline Foam::scalar& Foam::quadraticEqn::b()
{
return this->v_[B];
}
inline Foam::scalar& Foam::quadraticEqn::c()
{
return this->v_[C];
}
inline Foam::scalar Foam::quadraticEqn::value(const scalar x) const
{
return x*(x*a() + b()) + c();

View File

@ -48,8 +48,8 @@ See also
\*---------------------------------------------------------------------------*/
#ifndef CompactSpatialTensor_H
#define CompactSpatialTensor_H
#ifndef Foam_CompactSpatialTensor_H
#define Foam_CompactSpatialTensor_H
#include "SpatialTensor.H"
@ -72,8 +72,8 @@ public:
// Constructors
//- Construct null
inline CompactSpatialTensor();
//- Default construct
CompactSpatialTensor() = default;
inline CompactSpatialTensor(const Foam::zero);
@ -95,7 +95,7 @@ public:
);
//- Construct from Istream
inline CompactSpatialTensor(Istream&);
inline explicit CompactSpatialTensor(Istream&);
};

View File

@ -27,11 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::CompactSpatialTensor<Cmpt>::CompactSpatialTensor()
{}
template<class Cmpt>
inline Foam::CompactSpatialTensor<Cmpt>::CompactSpatialTensor
(

View File

@ -47,8 +47,8 @@ See also
\*---------------------------------------------------------------------------*/
#ifndef CompactSpatialTensorT_H
#define CompactSpatialTensorT_H
#ifndef Foam_CompactSpatialTensorT_H
#define Foam_CompactSpatialTensorT_H
#include "CompactSpatialTensor.H"
@ -71,8 +71,8 @@ public:
// Constructors
//- Construct null
inline CompactSpatialTensorT();
//- Default construct
CompactSpatialTensorT() = default;
inline CompactSpatialTensorT(const Foam::zero);
@ -94,7 +94,7 @@ public:
);
//- Construct from Istream
inline CompactSpatialTensorT(Istream&);
inline explicit CompactSpatialTensorT(Istream&);
};

View File

@ -27,11 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::CompactSpatialTensorT<Cmpt>::CompactSpatialTensorT()
{}
template<class Cmpt>
inline Foam::CompactSpatialTensorT<Cmpt>::CompactSpatialTensorT
(

View File

@ -49,8 +49,8 @@ See also
\*---------------------------------------------------------------------------*/
#ifndef SpatialTensor_H
#define SpatialTensor_H
#ifndef Foam_SpatialTensor_H
#define Foam_SpatialTensor_H
#include "Tensor.H"
#include "SpatialVector.H"
@ -86,8 +86,8 @@ public:
// Constructors
//- Construct null
inline SpatialTensor();
//- Default Construct
SpatialTensor() = default;
//- Construct initialized to zero
inline SpatialTensor(const Foam::zero);
@ -125,7 +125,7 @@ public:
);
//- Construct from Istream
inline SpatialTensor(Istream&);
inline explicit SpatialTensor(Istream&);
};

View File

@ -29,11 +29,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::SpatialTensor<Cmpt>::SpatialTensor()
{}
template<class Cmpt>
inline Foam::SpatialTensor<Cmpt>::SpatialTensor(const Foam::zero)
:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -48,8 +48,8 @@ See also
\*---------------------------------------------------------------------------*/
#ifndef SpatialVector_H
#define SpatialVector_H
#ifndef Foam_SpatialVector_H
#define Foam_SpatialVector_H
#include "Vector.H"
@ -91,8 +91,8 @@ public:
// Constructors
//- Construct null
inline SpatialVector();
//- Default construct
SpatialVector() = default;
//- Construct initialized to zero
inline SpatialVector(const Foam::zero);
@ -119,37 +119,37 @@ public:
);
//- Construct from Istream
inline SpatialVector(Istream&);
inline explicit SpatialVector(Istream&);
// Member Functions
// Component access
// Component Access
inline const Cmpt& wx() const;
inline const Cmpt& wy() const;
inline const Cmpt& wz() const;
const Cmpt& wx() const noexcept { return this->v_[WX]; }
const Cmpt& wy() const noexcept { return this->v_[WY]; }
const Cmpt& wz() const noexcept { return this->v_[WZ]; }
inline const Cmpt& lx() const;
inline const Cmpt& ly() const;
inline const Cmpt& lz() const;
const Cmpt& lx() const noexcept { return this->v_[LX]; }
const Cmpt& ly() const noexcept { return this->v_[LY]; }
const Cmpt& lz() const noexcept { return this->v_[LZ]; }
inline Cmpt& wx();
inline Cmpt& wy();
inline Cmpt& wz();
Cmpt& wx() noexcept { return this->v_[WX]; }
Cmpt& wy() noexcept { return this->v_[WY]; }
Cmpt& wz() noexcept { return this->v_[WZ]; }
inline Cmpt& lx();
inline Cmpt& ly();
inline Cmpt& lz();
Cmpt& lx() noexcept { return this->v_[LX]; }
Cmpt& ly() noexcept { return this->v_[LY]; }
Cmpt& lz() noexcept { return this->v_[LZ]; }
// Sub-vector access.
// Sub-vector access
//- Return the angular part of the spatial vector as a vector
inline Vector<Cmpt> w() const;
//- Return the angular part of the spatial vector as a vector
inline Vector<Cmpt> w() const;
//- Return the linear part of the spatial vector as a vector
inline Vector<Cmpt> l() const;
//- Return the linear part of the spatial vector as a vector
inline Vector<Cmpt> l() const;
// Member Operators

View File

@ -27,11 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::SpatialVector<Cmpt>::SpatialVector()
{}
template<class Cmpt>
inline Foam::SpatialVector<Cmpt>::SpatialVector(const Foam::zero)
:
@ -56,12 +51,12 @@ inline Foam::SpatialVector<Cmpt>::SpatialVector
const Vector<Cmpt>& l
)
{
this->v_[0] = w.x();
this->v_[1] = w.y();
this->v_[2] = w.z();
this->v_[3] = l.x();
this->v_[4] = l.y();
this->v_[5] = l.z();
this->v_[WX] = w.x();
this->v_[WY] = w.y();
this->v_[WZ] = w.z();
this->v_[LX] = l.x();
this->v_[LY] = l.y();
this->v_[LZ] = l.z();
}
@ -76,12 +71,12 @@ inline Foam::SpatialVector<Cmpt>::SpatialVector
const Cmpt& v5
)
{
this->v_[0] = v0;
this->v_[1] = v1;
this->v_[2] = v2;
this->v_[3] = v3;
this->v_[4] = v4;
this->v_[5] = v5;
this->v_[WX] = v0;
this->v_[WY] = v1;
this->v_[WZ] = v2;
this->v_[LX] = v3;
this->v_[LY] = v4;
this->v_[LZ] = v5;
}
@ -101,100 +96,16 @@ inline Foam::SpatialVector<Cmpt>::dual::dual(const SpatialVector& v)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::wx() const
{
return this->v_[WX];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::wy() const
{
return this->v_[WY];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::wz() const
{
return this->v_[WZ];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::lx() const
{
return this->v_[LX];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::ly() const
{
return this->v_[LY];
}
template<class Cmpt>
inline const Cmpt& Foam::SpatialVector<Cmpt>::lz() const
{
return this->v_[LZ];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::wx()
{
return this->v_[WX];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::wy()
{
return this->v_[WY];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::wz()
{
return this->v_[WZ];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::lx()
{
return this->v_[LX];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::ly()
{
return this->v_[LY];
}
template<class Cmpt>
inline Cmpt& Foam::SpatialVector<Cmpt>::lz()
{
return this->v_[LZ];
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SpatialVector<Cmpt>::w() const
{
return Vector<Cmpt>(this->v_[0], this->v_[1], this->v_[2]);
return Vector<Cmpt>(this->v_[WX], this->v_[WY], this->v_[WZ]);
}
template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SpatialVector<Cmpt>::l() const
{
return Vector<Cmpt>(this->v_[3], this->v_[4], this->v_[5]);
return Vector<Cmpt>(this->v_[LX], this->v_[LY], this->v_[LZ]);
}