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 "vectorField.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "Random.H"
#include <algorithm> #include <algorithm>
#include <random> #include <random>
@ -74,8 +75,12 @@ void doTest(vector& vec1, vector& vec2)
printInfo(vec1); printInfo(vec1);
printInfo(vec2); printInfo(vec2);
Info<< "min of " << vec1 << " and " << vec2 << " = " Info<< "vector: " << vec1 << nl
<< min(vec1, vec2) << nl << 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()); std::shuffle(vec2.begin(), vec2.end(), std::default_random_engine());
Info<< "shuffled: " << vec2 << nl; 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 // Basic tests for fields

View File

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

View File

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

View File

@ -88,90 +88,6 @@ inline Foam::BarycentricTensor<Cmpt>::BarycentricTensor
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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> template<class Cmpt>
inline Foam::Barycentric<Cmpt> Foam::BarycentricTensor<Cmpt>::x() const inline Foam::Barycentric<Cmpt> Foam::BarycentricTensor<Cmpt>::x() const
{ {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -64,20 +64,6 @@ inline Foam::SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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> template<class Cmpt>
inline const Foam::SphericalTensor<Cmpt>& inline const Foam::SphericalTensor<Cmpt>&
Foam::SphericalTensor<Cmpt>::T() const Foam::SphericalTensor<Cmpt>::T() const

View File

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

View File

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

View File

@ -93,116 +93,6 @@ inline Foam::SymmTensor<Cmpt>::SymmTensor(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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> template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::x() const inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::x() const
{ {

View File

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

View File

@ -76,56 +76,6 @@ inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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> template<class Cmpt>
inline Foam::Vector2D<Cmpt> Foam::SymmTensor2D<Cmpt>::diag() const inline Foam::Vector2D<Cmpt> Foam::SymmTensor2D<Cmpt>::diag() const
{ {

View File

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

View File

@ -149,132 +149,6 @@ inline Foam::Tensor<Cmpt>::Tensor(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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> template<class Cmpt>
inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::x() const inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::x() const
{ {

View File

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

View File

@ -94,56 +94,6 @@ inline Foam::Tensor2D<Cmpt>::Tensor2D(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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> template<class Cmpt>
inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::x() const inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::x() const
{ {

View File

@ -112,23 +112,25 @@ public:
// Member Functions // Member Functions
//- Access to the vector x component // Component Access
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;
//- Access to the vector x component //- Access to the vector x component
inline Cmpt& x(); const Cmpt& x() const noexcept { return this->v_[X]; }
//- Access to the vector y component //- Access to the vector y component
inline Cmpt& y(); const Cmpt& y() const noexcept { return this->v_[Y]; }
//- Access to the vector z component //- 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 // Vector Operations
@ -153,6 +155,38 @@ public:
//- Cross-product of \c this with another Vector. //- Cross-product of \c this with another Vector.
inline Vector<Cmpt> cross(const Vector<Cmpt>& v2) const; 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt> 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
namespace Foam namespace Foam

View File

@ -40,8 +40,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef boolVector_H #ifndef Foam_boolVector_H
#define boolVector_H #define Foam_boolVector_H
#include "FixedList.H" #include "FixedList.H"
@ -126,25 +126,25 @@ public:
inline unsigned int count(const bool on=true) const; inline unsigned int count(const bool on=true) const;
// Access // Component Access
//- The x component //- The x component
inline bool x() const; bool x() const { return operator[](boolVector::X); }
//- The y component //- The y component
inline bool y() const; bool y() const { return operator[](boolVector::Y); }
//- The z component //- The z component
inline bool z() const; bool z() const { return operator[](boolVector::Z); }
//- The x component //- The x component
inline bool& x(); bool& x() { return operator[](boolVector::X); }
//- The y component //- The y component
inline bool& y(); bool& y() { return operator[](boolVector::Y); }
//- The z component //- The z component
inline bool& z(); bool& z() { return operator[](boolVector::Z); }
// Edit // 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() inline void Foam::boolVector::flip()
{ {
for (bool& val : *this) 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 \ const Foam::Vector<Type> Foam::Vector<Type>::vsType::rootMin \
( \ ( \
Vector<Type>::uniform(-Prefix##ROOTVGREAT) \ Vector<Type>::uniform(-Prefix##ROOTVGREAT) \
); \ );
defineTraits(float, floatScalar); defineTraits(float, floatScalar);

View File

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

View File

@ -62,34 +62,6 @@ inline Foam::Vector2D<Cmpt>::Vector2D(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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> template<class Cmpt>
inline Foam::Vector2D<Cmpt>& Foam::Vector2D<Cmpt>::normalise(const scalar tol) 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> template<class Form, class Cmpt, direction Ncmpts>
inline bool operator< inline bool operator<
( (
@ -878,6 +863,7 @@ inline bool operator<
const VectorSpace<Form, Cmpt, Ncmpts>& vs2 const VectorSpace<Form, Cmpt, Ncmpts>& vs2
) )
{ {
// Compare all components, stop at first non less-than component
for (direction i=0; i<Ncmpts; ++i) for (direction i=0; i<Ncmpts; ++i)
{ {
if (!(vs1.v_[i] < vs2.v_[i])) return false; 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> template<class Form, class Cmpt, direction Ncmpts>
inline bool operator>= 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 } // End namespace Foam

View File

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

View File

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

View File

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

View File

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

View File

@ -27,10 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::cubicEqn::cubicEqn()
{}
inline Foam::cubicEqn::cubicEqn(const Foam::zero) inline Foam::cubicEqn::cubicEqn(const Foam::zero)
: :
VectorSpace<cubicEqn, scalar, 4>(Foam::zero{}) VectorSpace<cubicEqn, scalar, 4>(Foam::zero{})
@ -54,54 +50,6 @@ inline Foam::cubicEqn::cubicEqn
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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 inline Foam::scalar Foam::cubicEqn::value(const scalar x) const
{ {
return x*(x*(x*a() + b()) + c()) + d(); return x*(x*(x*a() + b()) + c()) + d();

View File

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

View File

@ -28,10 +28,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::linearEqn::linearEqn()
{}
inline Foam::linearEqn::linearEqn(const Foam::zero) inline Foam::linearEqn::linearEqn(const Foam::zero)
: :
VectorSpace<linearEqn, scalar, 2>(Foam::zero{}) VectorSpace<linearEqn, scalar, 2>(Foam::zero{})
@ -47,30 +43,6 @@ inline Foam::linearEqn::linearEqn(const scalar a, const scalar b)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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 inline Foam::scalar Foam::linearEqn::value(const scalar x) const
{ {
return x*a() + b(); return x*a() + b();

View File

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

View File

@ -27,10 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::quadraticEqn::quadraticEqn()
{}
inline Foam::quadraticEqn::quadraticEqn(const Foam::zero) inline Foam::quadraticEqn::quadraticEqn(const Foam::zero)
: :
VectorSpace<quadraticEqn, scalar, 3>(Foam::zero{}) VectorSpace<quadraticEqn, scalar, 3>(Foam::zero{})
@ -52,42 +48,6 @@ inline Foam::quadraticEqn::quadraticEqn
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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 inline Foam::scalar Foam::quadraticEqn::value(const scalar x) const
{ {
return x*(x*a() + b()) + c(); return x*(x*a() + b()) + c();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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