diff --git a/applications/test/vector/Test-vector.C b/applications/test/vector/Test-vector.C index 417d25aad9..020944dddd 100644 --- a/applications/test/vector/Test-vector.C +++ b/applications/test/vector/Test-vector.C @@ -33,6 +33,7 @@ Description #include "vectorField.H" #include "IOstreams.H" +#include "Random.H" #include #include @@ -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 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 diff --git a/src/OpenFOAM/primitives/Barycentric/Barycentric.H b/src/OpenFOAM/primitives/Barycentric/Barycentric.H index bc5da91964..6a11b7f676 100644 --- a/src/OpenFOAM/primitives/Barycentric/Barycentric.H +++ b/src/OpenFOAM/primitives/Barycentric/Barycentric.H @@ -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 diff --git a/src/OpenFOAM/primitives/Barycentric/BarycentricI.H b/src/OpenFOAM/primitives/Barycentric/BarycentricI.H index dfaf973de7..1d8077c940 100644 --- a/src/OpenFOAM/primitives/Barycentric/BarycentricI.H +++ b/src/OpenFOAM/primitives/Barycentric/BarycentricI.H @@ -63,64 +63,6 @@ inline Foam::Barycentric::Barycentric {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline const Cmpt& Foam::Barycentric::a() const -{ - return this->v_[A]; -} - - -template -inline const Cmpt& Foam::Barycentric::b() const -{ - return this->v_[B]; -} - - -template -inline const Cmpt& Foam::Barycentric::c() const -{ - return this->v_[C]; -} - - -template -inline const Cmpt& Foam::Barycentric::d() const -{ - return this->v_[D]; -} - - -template -inline Cmpt& Foam::Barycentric::a() -{ - return this->v_[A]; -} - - -template -inline Cmpt& Foam::Barycentric::b() -{ - return this->v_[B]; -} - - -template -inline Cmpt& Foam::Barycentric::c() -{ - return this->v_[C]; -} - - -template -inline Cmpt& Foam::Barycentric::d() -{ - return this->v_[D]; -} - - // * * * * * * * * * * * * * * * Member Operations * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/primitives/Barycentric/BarycentricTensor.H b/src/OpenFOAM/primitives/Barycentric/BarycentricTensor.H index ceaa29f01a..05587a2bf5 100644 --- a/src/OpenFOAM/primitives/Barycentric/BarycentricTensor.H +++ b/src/OpenFOAM/primitives/Barycentric/BarycentricTensor.H @@ -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 diff --git a/src/OpenFOAM/primitives/Barycentric/BarycentricTensorI.H b/src/OpenFOAM/primitives/Barycentric/BarycentricTensorI.H index 1c73e89f6c..51be5c802a 100644 --- a/src/OpenFOAM/primitives/Barycentric/BarycentricTensorI.H +++ b/src/OpenFOAM/primitives/Barycentric/BarycentricTensorI.H @@ -88,90 +88,6 @@ inline Foam::BarycentricTensor::BarycentricTensor // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Cmpt& Foam::BarycentricTensor::xa() const -{ - return this->v_[XA]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::xb() const -{ - return this->v_[XB]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::xc() const -{ - return this->v_[XC]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::xd() const -{ - return this->v_[XD]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::ya() const -{ - return this->v_[YA]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::yb() const -{ - return this->v_[YB]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::yc() const -{ - return this->v_[YC]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::yd() const -{ - return this->v_[YD]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::za() const -{ - return this->v_[ZA]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::zb() const -{ - return this->v_[ZB]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::zc() const -{ - return this->v_[ZC]; -} - - -template -inline const Cmpt& Foam::BarycentricTensor::zd() const -{ - return this->v_[ZD]; -} - - template inline Foam::Barycentric Foam::BarycentricTensor::x() const { diff --git a/src/OpenFOAM/primitives/Barycentric2D/Barycentric2D.H b/src/OpenFOAM/primitives/Barycentric2D/Barycentric2D.H index 71a9712a68..9f472f25b6 100644 --- a/src/OpenFOAM/primitives/Barycentric2D/Barycentric2D.H +++ b/src/OpenFOAM/primitives/Barycentric2D/Barycentric2D.H @@ -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 diff --git a/src/OpenFOAM/primitives/Barycentric2D/Barycentric2DI.H b/src/OpenFOAM/primitives/Barycentric2D/Barycentric2DI.H index ab9ec995b0..93cea6b7aa 100644 --- a/src/OpenFOAM/primitives/Barycentric2D/Barycentric2DI.H +++ b/src/OpenFOAM/primitives/Barycentric2D/Barycentric2DI.H @@ -60,50 +60,6 @@ inline Foam::Barycentric2D::Barycentric2D {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline const Cmpt& Foam::Barycentric2D::a() const -{ - return this->v_[A]; -} - - -template -inline const Cmpt& Foam::Barycentric2D::b() const -{ - return this->v_[B]; -} - - -template -inline const Cmpt& Foam::Barycentric2D::c() const -{ - return this->v_[C]; -} - - -template -inline Cmpt& Foam::Barycentric2D::a() -{ - return this->v_[A]; -} - - -template -inline Cmpt& Foam::Barycentric2D::b() -{ - return this->v_[B]; -} - - -template -inline Cmpt& Foam::Barycentric2D::c() -{ - return this->v_[C]; -} - - // * * * * * * * * * * * * * * * Member Operations * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H b/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H index 32f600241b..2f5817037a 100644 --- a/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H +++ b/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H @@ -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]; } }; diff --git a/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H b/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H index 7674e74cae..94f910247f 100644 --- a/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H +++ b/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H @@ -70,46 +70,6 @@ inline Foam::DiagTensor::DiagTensor(Istream& is) {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline const Cmpt& Foam::DiagTensor::xx() const -{ - return this->v_[XX]; -} - -template -inline const Cmpt& Foam::DiagTensor::yy() const -{ - return this->v_[YY]; -} - -template -inline const Cmpt& Foam::DiagTensor::zz() const -{ - return this->v_[ZZ]; -} - - -template -inline Cmpt& Foam::DiagTensor::xx() -{ - return this->v_[XX]; -} - -template -inline Cmpt& Foam::DiagTensor::yy() -{ - return this->v_[YY]; -} - -template -inline Cmpt& Foam::DiagTensor::zz() -{ - return this->v_[ZZ]; -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H index 2d500ca94c..2e62323e78 100644 --- a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H +++ b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H @@ -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 - inline const Cmpt& elmt() const; + inline const Cmpt& elmt() const noexcept; //- Fast element access using compile-time addressing template - 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::type T() const; diff --git a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H index a2d73937e5..f9061dd9bf 100644 --- a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H +++ b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H @@ -125,7 +125,8 @@ Block(msType& matrix) template template -inline const Cmpt& Foam::MatrixSpace::elmt() const +inline const Cmpt& Foam::MatrixSpace::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::elmt() const template template inline Cmpt& Foam::MatrixSpace::elmt() +noexcept { static_assert(Row < Mrows && Col < Ncols, "Address outside matrix"); return this->v_[Row*Ncols + Col]; } -template -inline const Cmpt& Foam::MatrixSpace::xx() const -{ - return elmt<0, 0>(); -} - - -template -inline Cmpt& Foam::MatrixSpace::xx() -{ - return elmt<0, 0>(); -} - - -template -inline const Cmpt& Foam::MatrixSpace::xy() const -{ - return elmt<0,1>(); -} - - -template -inline Cmpt& Foam::MatrixSpace::xy() -{ - return elmt<0,1>(); -} - - -template -inline const Cmpt& Foam::MatrixSpace::xz() const -{ - return elmt<0,2>(); -} - - -template -inline Cmpt& Foam::MatrixSpace::xz() -{ - return elmt<0,2>(); -} - - -template -inline const Cmpt& Foam::MatrixSpace::yx() const -{ - return elmt<1,0>(); -} - - -template -inline Cmpt& Foam::MatrixSpace::yx() -{ - return elmt<1,0>(); -} - - -template -inline const Cmpt& Foam::MatrixSpace::yy() const -{ - return elmt<1,1>(); -} - - -template -inline Cmpt& Foam::MatrixSpace::yy() -{ - return elmt<1,1>(); -} - - -template -inline const Cmpt& Foam::MatrixSpace::yz() const -{ - return elmt<1,2>(); -} - - -template -inline Cmpt& Foam::MatrixSpace::yz() -{ - return elmt<1,2>(); -} - - -template -inline const Cmpt& Foam::MatrixSpace::zx() const -{ - return elmt<2,0>(); -} - - -template -inline Cmpt& Foam::MatrixSpace::zx() -{ - return elmt<2,0>(); -} - - -template -inline const Cmpt& Foam::MatrixSpace::zy() const -{ - return elmt<2,1>(); -} - - -template -inline Cmpt& Foam::MatrixSpace::zy() -{ - return elmt<2,1>(); -} - - -template -inline const Cmpt& Foam::MatrixSpace::zz() const -{ - return elmt<2,2>(); -} - -template -inline Cmpt& Foam::MatrixSpace::zz() -{ - return elmt<2,2>(); -} - template inline Foam::MatrixSpace Foam::MatrixSpace::identity() diff --git a/src/OpenFOAM/primitives/RowVector/RowVector.H b/src/OpenFOAM/primitives/RowVector/RowVector.H index 6c37189afb..4e7497d9a0 100644 --- a/src/OpenFOAM/primitives/RowVector/RowVector.H +++ b/src/OpenFOAM/primitives/RowVector/RowVector.H @@ -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]; } }; diff --git a/src/OpenFOAM/primitives/RowVector/RowVectorI.H b/src/OpenFOAM/primitives/RowVector/RowVectorI.H index 3d2db9242d..d18d556583 100644 --- a/src/OpenFOAM/primitives/RowVector/RowVectorI.H +++ b/src/OpenFOAM/primitives/RowVector/RowVectorI.H @@ -27,11 +27,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline Foam::RowVector::RowVector() -{} - - template inline Foam::RowVector::RowVector(const Foam::zero) : @@ -71,44 +66,4 @@ inline Foam::RowVector::RowVector(Istream& is) {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline const Cmpt& Foam::RowVector::x() const -{ - return this->v_[X]; -} - -template -inline const Cmpt& Foam::RowVector::y() const -{ - return this->v_[Y]; -} - -template -inline const Cmpt& Foam::RowVector::z() const -{ - return this->v_[Z]; -} - - -template -inline Cmpt& Foam::RowVector::x() -{ - return this->v_[X]; -} - -template -inline Cmpt& Foam::RowVector::y() -{ - return this->v_[Y]; -} - -template -inline Cmpt& Foam::RowVector::z() -{ - return this->v_[Z]; -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H index 1b335324af..768f239e8d 100644 --- a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H +++ b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H @@ -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 diff --git a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensorI.H b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensorI.H index 43f8ee9ea7..3485263eaf 100644 --- a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensorI.H +++ b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensorI.H @@ -64,20 +64,6 @@ inline Foam::SphericalTensor::SphericalTensor(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Cmpt& Foam::SphericalTensor::ii() const -{ - return this->v_[II]; -} - - -template -inline Cmpt& Foam::SphericalTensor::ii() -{ - return this->v_[II]; -} - - template inline const Foam::SphericalTensor& Foam::SphericalTensor::T() const diff --git a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H index a61a076afe..e40a4542c2 100644 --- a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H +++ b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H @@ -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]; } }; diff --git a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2DI.H b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2DI.H index 6a4516e33c..3f3297054a 100644 --- a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2DI.H +++ b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2DI.H @@ -61,22 +61,6 @@ inline Foam::SphericalTensor2D::SphericalTensor2D(Istream& is) {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline const Cmpt& Foam::SphericalTensor2D::ii() const -{ - return this->v_[II]; -} - - -template -inline Cmpt& Foam::SphericalTensor2D::ii() -{ - return this->v_[II]; -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H b/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H index ea00c01e83..45ff7aabac 100644 --- a/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H +++ b/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H @@ -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 diff --git a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H index 1be88f3c95..4154cc8f7b 100644 --- a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H +++ b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H @@ -93,116 +93,6 @@ inline Foam::SymmTensor::SymmTensor(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Cmpt& Foam::SymmTensor::xx() const -{ - return this->v_[XX]; -} - -template -inline const Cmpt& Foam::SymmTensor::xy() const -{ - return this->v_[XY]; -} - -template -inline const Cmpt& Foam::SymmTensor::xz() const -{ - return this->v_[XZ]; -} - -template -inline const Cmpt& Foam::SymmTensor::yx() const -{ - return this->v_[XY]; -} - -template -inline const Cmpt& Foam::SymmTensor::yy() const -{ - return this->v_[YY]; -} - -template -inline const Cmpt& Foam::SymmTensor::yz() const -{ - return this->v_[YZ]; -} - -template -inline const Cmpt& Foam::SymmTensor::zx() const -{ - return this->v_[XZ]; -} - -template -inline const Cmpt& Foam::SymmTensor::zy() const -{ - return this->v_[YZ]; -} - -template -inline const Cmpt& Foam::SymmTensor::zz() const -{ - return this->v_[ZZ]; -} - - -template -inline Cmpt& Foam::SymmTensor::xx() -{ - return this->v_[XX]; -} - -template -inline Cmpt& Foam::SymmTensor::xy() -{ - return this->v_[XY]; -} - -template -inline Cmpt& Foam::SymmTensor::xz() -{ - return this->v_[XZ]; -} - -template -inline Cmpt& Foam::SymmTensor::yx() -{ - return this->v_[XY]; -} - -template -inline Cmpt& Foam::SymmTensor::yy() -{ - return this->v_[YY]; -} - -template -inline Cmpt& Foam::SymmTensor::yz() -{ - return this->v_[YZ]; -} - -template -inline Cmpt& Foam::SymmTensor::zx() -{ - return this->v_[XZ]; -} - -template -inline Cmpt& Foam::SymmTensor::zy() -{ - return this->v_[YZ]; -} - -template -inline Cmpt& Foam::SymmTensor::zz() -{ - return this->v_[ZZ]; -} - - template inline Foam::Vector Foam::SymmTensor::x() const { diff --git a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H index 03c18886f7..a10e93ad4b 100644 --- a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H +++ b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H @@ -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 diag() const; + //- Extract the diagonal as a vector + inline Vector2D diag() const; - //- Set values of the diagonal - inline void diag(const Vector2D& v); + //- Set values of the diagonal + inline void diag(const Vector2D& v); + // Tensor Operations + //- Return non-Hermitian transpose inline const SymmTensor2D& T() const; diff --git a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H index c28644c943..5f0ab5fdf0 100644 --- a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H +++ b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H @@ -76,56 +76,6 @@ inline Foam::SymmTensor2D::SymmTensor2D(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Cmpt& Foam::SymmTensor2D::xx() const -{ - return this->v_[XX]; -} - -template -inline const Cmpt& Foam::SymmTensor2D::xy() const -{ - return this->v_[XY]; -} - -template -inline const Cmpt& Foam::SymmTensor2D::yx() const -{ - return this->v_[XY]; -} - -template -inline const Cmpt& Foam::SymmTensor2D::yy() const -{ - return this->v_[YY]; -} - - -template -inline Cmpt& Foam::SymmTensor2D::xx() -{ - return this->v_[XX]; -} - -template -inline Cmpt& Foam::SymmTensor2D::xy() -{ - return this->v_[XY]; -} - -template -inline Cmpt& Foam::SymmTensor2D::yx() -{ - return this->v_[XY]; -} - -template -inline Cmpt& Foam::SymmTensor2D::yy() -{ - return this->v_[YY]; -} - - template inline Foam::Vector2D Foam::SymmTensor2D::diag() const { diff --git a/src/OpenFOAM/primitives/Tensor/Tensor.H b/src/OpenFOAM/primitives/Tensor/Tensor.H index 9830d32720..dfcb5b1c10 100644 --- a/src/OpenFOAM/primitives/Tensor/Tensor.H +++ b/src/OpenFOAM/primitives/Tensor/Tensor.H @@ -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 diff --git a/src/OpenFOAM/primitives/Tensor/TensorI.H b/src/OpenFOAM/primitives/Tensor/TensorI.H index a9fc78d440..80d363f39e 100644 --- a/src/OpenFOAM/primitives/Tensor/TensorI.H +++ b/src/OpenFOAM/primitives/Tensor/TensorI.H @@ -149,132 +149,6 @@ inline Foam::Tensor::Tensor(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Cmpt& Foam::Tensor::xx() const -{ - return this->v_[XX]; -} - - -template -inline const Cmpt& Foam::Tensor::xy() const -{ - return this->v_[XY]; -} - - -template -inline const Cmpt& Foam::Tensor::xz() const -{ - return this->v_[XZ]; -} - - -template -inline const Cmpt& Foam::Tensor::yx() const -{ - return this->v_[YX]; -} - - -template -inline const Cmpt& Foam::Tensor::yy() const -{ - return this->v_[YY]; -} - - -template -inline const Cmpt& Foam::Tensor::yz() const -{ - return this->v_[YZ]; -} - - -template -inline const Cmpt& Foam::Tensor::zx() const -{ - return this->v_[ZX]; -} - - -template -inline const Cmpt& Foam::Tensor::zy() const -{ - return this->v_[ZY]; -} - - -template -inline const Cmpt& Foam::Tensor::zz() const -{ - return this->v_[ZZ]; -} - - -template -inline Cmpt& Foam::Tensor::xx() -{ - return this->v_[XX]; -} - - -template -inline Cmpt& Foam::Tensor::xy() -{ - return this->v_[XY]; -} - - -template -inline Cmpt& Foam::Tensor::xz() -{ - return this->v_[XZ]; -} - - -template -inline Cmpt& Foam::Tensor::yx() -{ - return this->v_[YX]; -} - - -template -inline Cmpt& Foam::Tensor::yy() -{ - return this->v_[YY]; -} - - -template -inline Cmpt& Foam::Tensor::yz() -{ - return this->v_[YZ]; -} - - -template -inline Cmpt& Foam::Tensor::zx() -{ - return this->v_[ZX]; -} - - -template -inline Cmpt& Foam::Tensor::zy() -{ - return this->v_[ZY]; -} - - -template -inline Cmpt& Foam::Tensor::zz() -{ - return this->v_[ZZ]; -} - - template inline Foam::Vector Foam::Tensor::x() const { diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H index e5e82d3379..079aa9501a 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H @@ -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 diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H index b8a16954aa..178ad48496 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H @@ -94,56 +94,6 @@ inline Foam::Tensor2D::Tensor2D(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Cmpt& Foam::Tensor2D::xx() const -{ - return this->v_[XX]; -} - -template -inline const Cmpt& Foam::Tensor2D::xy() const -{ - return this->v_[XY]; -} - -template -inline const Cmpt& Foam::Tensor2D::yx() const -{ - return this->v_[YX]; -} - -template -inline const Cmpt& Foam::Tensor2D::yy() const -{ - return this->v_[YY]; -} - - -template -inline Cmpt& Foam::Tensor2D::xx() -{ - return this->v_[XX]; -} - -template -inline Cmpt& Foam::Tensor2D::xy() -{ - return this->v_[XY]; -} - -template -inline Cmpt& Foam::Tensor2D::yx() -{ - return this->v_[YX]; -} - -template -inline Cmpt& Foam::Tensor2D::yy() -{ - return this->v_[YY]; -} - - template inline Foam::Vector2D Foam::Tensor2D::x() const { diff --git a/src/OpenFOAM/primitives/Vector/Vector.H b/src/OpenFOAM/primitives/Vector/Vector.H index fff9290a98..b47da69fa3 100644 --- a/src/OpenFOAM/primitives/Vector/Vector.H +++ b/src/OpenFOAM/primitives/Vector/Vector.H @@ -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 cross(const Vector& v2) const; + + //- The L2-norm distance from another vector. + //- The mag() of the difference. + inline scalar dist(const Vector& v2) const; + + //- The L2-norm distance squared from another vector. + //- The magSqr() of the difference. + inline scalar distSqr(const Vector& v2) const; + + + // Comparision Operations + + //- Lexicographically compare \em a and \em b with order (x:y:z) + static inline bool less_xyz + ( + const Vector& a, + const Vector& b + ); + + //- Lexicographically compare \em a and \em b with order (y:z:x) + static inline bool less_yzx + ( + const Vector& a, + const Vector& b + ); + + //- Lexicographically compare \em a and \em b with order (z:x:y) + static inline bool less_zxy + ( + const Vector& a, + const Vector& b + ); }; diff --git a/src/OpenFOAM/primitives/Vector/VectorI.H b/src/OpenFOAM/primitives/Vector/VectorI.H index 53373b2713..a257dd7ad3 100644 --- a/src/OpenFOAM/primitives/Vector/VectorI.H +++ b/src/OpenFOAM/primitives/Vector/VectorI.H @@ -67,46 +67,6 @@ inline Foam::Vector::Vector(Istream& is) {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline const Cmpt& Foam::Vector::x() const -{ - return this->v_[X]; -} - -template -inline const Cmpt& Foam::Vector::y() const -{ - return this->v_[Y]; -} - -template -inline const Cmpt& Foam::Vector::z() const -{ - return this->v_[Z]; -} - - -template -inline Cmpt& Foam::Vector::x() -{ - return this->v_[X]; -} - -template -inline Cmpt& Foam::Vector::y() -{ - return this->v_[Y]; -} - -template -inline Cmpt& Foam::Vector::z() -{ - return this->v_[Z]; -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -172,6 +132,99 @@ Foam::Vector::cross(const Vector& v2) const } +template +inline Foam::scalar Foam::Vector::distSqr(const Vector& v2) const +{ + return + ( + Foam::magSqr(v2.x() - this->x()) + + Foam::magSqr(v2.y() - this->y()) + + Foam::magSqr(v2.z() - this->z()) + ); +} + + +template +inline Foam::scalar Foam::Vector::dist(const Vector& v2) const +{ + return ::sqrt(this->distSqr(v2)); +} + + +// * * * * * * * * * * * * * Comparision Operations * * * * * * * * * * * * // + +template +inline bool +Foam::Vector::less_xyz(const Vector& a, const Vector& 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 +inline bool +Foam::Vector::less_yzx(const Vector& a, const Vector& 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 +inline bool +Foam::Vector::less_zxy(const Vector& a, const Vector& 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 diff --git a/src/OpenFOAM/primitives/Vector/bools/boolVector.H b/src/OpenFOAM/primitives/Vector/bools/boolVector.H index c7bac73011..1275b782cd 100644 --- a/src/OpenFOAM/primitives/Vector/bools/boolVector.H +++ b/src/OpenFOAM/primitives/Vector/bools/boolVector.H @@ -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 diff --git a/src/OpenFOAM/primitives/Vector/bools/boolVectorI.H b/src/OpenFOAM/primitives/Vector/bools/boolVectorI.H index f88b12341e..0d7622c957 100644 --- a/src/OpenFOAM/primitives/Vector/bools/boolVectorI.H +++ b/src/OpenFOAM/primitives/Vector/bools/boolVectorI.H @@ -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) diff --git a/src/OpenFOAM/primitives/Vector/floats/floatVectors.C b/src/OpenFOAM/primitives/Vector/floats/floatVectors.C index 278555626d..34d022baa8 100644 --- a/src/OpenFOAM/primitives/Vector/floats/floatVectors.C +++ b/src/OpenFOAM/primitives/Vector/floats/floatVectors.C @@ -104,7 +104,7 @@ const char* const Foam::Vector::vsType::typeName = "doubleVector"; const Foam::Vector Foam::Vector::vsType::rootMin \ ( \ Vector::uniform(-Prefix##ROOTVGREAT) \ - ); \ + ); defineTraits(float, floatScalar); diff --git a/src/OpenFOAM/primitives/Vector2D/Vector2D.H b/src/OpenFOAM/primitives/Vector2D/Vector2D.H index f8126bbf49..b9e65e711b 100644 --- a/src/OpenFOAM/primitives/Vector2D/Vector2D.H +++ b/src/OpenFOAM/primitives/Vector2D/Vector2D.H @@ -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. diff --git a/src/OpenFOAM/primitives/Vector2D/Vector2DI.H b/src/OpenFOAM/primitives/Vector2D/Vector2DI.H index 3095c39ef4..0b823ebeb3 100644 --- a/src/OpenFOAM/primitives/Vector2D/Vector2DI.H +++ b/src/OpenFOAM/primitives/Vector2D/Vector2DI.H @@ -62,34 +62,6 @@ inline Foam::Vector2D::Vector2D(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Cmpt& Foam::Vector2D::x() const -{ - return this->v_[X]; -} - - -template -inline const Cmpt& Foam::Vector2D::y() const -{ - return this->v_[Y]; -} - - -template -inline Cmpt& Foam::Vector2D::x() -{ - return this->v_[X]; -} - - -template -inline Cmpt& Foam::Vector2D::y() -{ - return this->v_[Y]; -} - - template inline Foam::Vector2D& Foam::Vector2D::normalise(const scalar tol) { diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H index 293bdac117..34ba8a1393 100644 --- a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H +++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H @@ -856,21 +856,6 @@ inline bool operator!= } -template -inline bool operator> -( - const VectorSpace& vs1, - const VectorSpace& vs2 -) -{ - for (direction i=0; i vs2.v_[i])) return false; - } - return true; -} - - template inline bool operator< ( @@ -878,6 +863,7 @@ inline bool operator< const VectorSpace& vs2 ) { + // Compare all components, stop at first non less-than component for (direction i=0; i +inline bool operator<= +( + const VectorSpace& vs1, + const VectorSpace& vs2 +) +{ + return !(vs2 < vs1); +} + + +template +inline bool operator> +( + const VectorSpace& vs1, + const VectorSpace& vs2 +) +{ + return (vs2 < vs1); +} + + template inline bool operator>= ( @@ -897,17 +905,6 @@ inline bool operator>= } -template -inline bool operator<= -( - const VectorSpace& vs1, - const VectorSpace& vs2 -) -{ - return !(vs1 > vs2); -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C index 8570e7514a..73bb97b1da 100644 --- a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C +++ b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C @@ -135,14 +135,14 @@ Foam::Polynomial::Polynomial(const word& name, Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -bool Foam::Polynomial::logActive() const +bool Foam::Polynomial::logActive() const noexcept { return logActive_; } template -Foam::scalar Foam::Polynomial::logCoeff() const +Foam::scalar Foam::Polynomial::logCoeff() const noexcept { return logCoeff_; } diff --git a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H index 3e0bc47574..cbf250254a 100644 --- a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H +++ b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H @@ -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 diff --git a/src/OpenFOAM/primitives/polynomialEqns/Roots.H b/src/OpenFOAM/primitives/polynomialEqns/Roots.H index 6c66fca4ec..c50787a5df 100644 --- a/src/OpenFOAM/primitives/polynomialEqns/Roots.H +++ b/src/OpenFOAM/primitives/polynomialEqns/Roots.H @@ -81,7 +81,7 @@ public: // Constructors - //- Construct null + //- Default construct as 'nan' inline Roots(); //- Construct with a uniform value diff --git a/src/OpenFOAM/primitives/polynomialEqns/cubicEqn/cubicEqn.H b/src/OpenFOAM/primitives/polynomialEqns/cubicEqn/cubicEqn.H index 3e90378981..6c74d6812e 100644 --- a/src/OpenFOAM/primitives/polynomialEqns/cubicEqn/cubicEqn.H +++ b/src/OpenFOAM/primitives/polynomialEqns/cubicEqn/cubicEqn.H @@ -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 diff --git a/src/OpenFOAM/primitives/polynomialEqns/cubicEqn/cubicEqnI.H b/src/OpenFOAM/primitives/polynomialEqns/cubicEqn/cubicEqnI.H index c770e64604..17824cef43 100644 --- a/src/OpenFOAM/primitives/polynomialEqns/cubicEqn/cubicEqnI.H +++ b/src/OpenFOAM/primitives/polynomialEqns/cubicEqn/cubicEqnI.H @@ -27,10 +27,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -inline Foam::cubicEqn::cubicEqn() -{} - - inline Foam::cubicEqn::cubicEqn(const Foam::zero) : VectorSpace(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(); diff --git a/src/OpenFOAM/primitives/polynomialEqns/linearEqn/linearEqn.H b/src/OpenFOAM/primitives/polynomialEqns/linearEqn/linearEqn.H index c898aef1ab..bd8df2415e 100644 --- a/src/OpenFOAM/primitives/polynomialEqns/linearEqn/linearEqn.H +++ b/src/OpenFOAM/primitives/polynomialEqns/linearEqn/linearEqn.H @@ -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 diff --git a/src/OpenFOAM/primitives/polynomialEqns/linearEqn/linearEqnI.H b/src/OpenFOAM/primitives/polynomialEqns/linearEqn/linearEqnI.H index 5daaea47a8..396d4f45f8 100644 --- a/src/OpenFOAM/primitives/polynomialEqns/linearEqn/linearEqnI.H +++ b/src/OpenFOAM/primitives/polynomialEqns/linearEqn/linearEqnI.H @@ -28,10 +28,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -inline Foam::linearEqn::linearEqn() -{} - - inline Foam::linearEqn::linearEqn(const Foam::zero) : VectorSpace(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(); diff --git a/src/OpenFOAM/primitives/polynomialEqns/quadraticEqn/quadraticEqn.H b/src/OpenFOAM/primitives/polynomialEqns/quadraticEqn/quadraticEqn.H index c68da9b9ec..aa945b3fba 100644 --- a/src/OpenFOAM/primitives/polynomialEqns/quadraticEqn/quadraticEqn.H +++ b/src/OpenFOAM/primitives/polynomialEqns/quadraticEqn/quadraticEqn.H @@ -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 diff --git a/src/OpenFOAM/primitives/polynomialEqns/quadraticEqn/quadraticEqnI.H b/src/OpenFOAM/primitives/polynomialEqns/quadraticEqn/quadraticEqnI.H index 4dadc77b5d..b1222c1aa3 100644 --- a/src/OpenFOAM/primitives/polynomialEqns/quadraticEqn/quadraticEqnI.H +++ b/src/OpenFOAM/primitives/polynomialEqns/quadraticEqn/quadraticEqnI.H @@ -27,10 +27,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -inline Foam::quadraticEqn::quadraticEqn() -{} - - inline Foam::quadraticEqn::quadraticEqn(const Foam::zero) : VectorSpace(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(); diff --git a/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensor/CompactSpatialTensor.H b/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensor/CompactSpatialTensor.H index 712df82bb4..470617ae9e 100644 --- a/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensor/CompactSpatialTensor.H +++ b/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensor/CompactSpatialTensor.H @@ -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&); }; diff --git a/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensor/CompactSpatialTensorI.H b/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensor/CompactSpatialTensorI.H index 5937d31ca2..fe67ef022d 100644 --- a/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensor/CompactSpatialTensorI.H +++ b/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensor/CompactSpatialTensorI.H @@ -27,11 +27,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline Foam::CompactSpatialTensor::CompactSpatialTensor() -{} - - template inline Foam::CompactSpatialTensor::CompactSpatialTensor ( diff --git a/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensorT/CompactSpatialTensorT.H b/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensorT/CompactSpatialTensorT.H index 45155502f1..c3e9e2441d 100644 --- a/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensorT/CompactSpatialTensorT.H +++ b/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensorT/CompactSpatialTensorT.H @@ -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&); }; diff --git a/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensorT/CompactSpatialTensorTI.H b/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensorT/CompactSpatialTensorTI.H index caa6d415dc..83772368e0 100644 --- a/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensorT/CompactSpatialTensorTI.H +++ b/src/OpenFOAM/primitives/spatialVectorAlgebra/CompactSpatialTensorT/CompactSpatialTensorTI.H @@ -27,11 +27,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline Foam::CompactSpatialTensorT::CompactSpatialTensorT() -{} - - template inline Foam::CompactSpatialTensorT::CompactSpatialTensorT ( diff --git a/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialTensor/SpatialTensor.H b/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialTensor/SpatialTensor.H index a9e235bfc0..f747f2e84a 100644 --- a/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialTensor/SpatialTensor.H +++ b/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialTensor/SpatialTensor.H @@ -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&); }; diff --git a/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialTensor/SpatialTensorI.H b/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialTensor/SpatialTensorI.H index cf34e27729..bdfc4ee6bf 100644 --- a/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialTensor/SpatialTensorI.H +++ b/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialTensor/SpatialTensorI.H @@ -29,11 +29,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline Foam::SpatialTensor::SpatialTensor() -{} - - template inline Foam::SpatialTensor::SpatialTensor(const Foam::zero) : diff --git a/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialVector/SpatialVector.H b/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialVector/SpatialVector.H index 334fa8b050..2e1932c6f3 100644 --- a/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialVector/SpatialVector.H +++ b/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialVector/SpatialVector.H @@ -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 w() const; + //- Return the angular part of the spatial vector as a vector + inline Vector w() const; - //- Return the linear part of the spatial vector as a vector - inline Vector l() const; + //- Return the linear part of the spatial vector as a vector + inline Vector l() const; // Member Operators diff --git a/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialVector/SpatialVectorI.H b/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialVector/SpatialVectorI.H index 5fcd85b620..265b823e57 100644 --- a/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialVector/SpatialVectorI.H +++ b/src/OpenFOAM/primitives/spatialVectorAlgebra/SpatialVector/SpatialVectorI.H @@ -27,11 +27,6 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline Foam::SpatialVector::SpatialVector() -{} - - template inline Foam::SpatialVector::SpatialVector(const Foam::zero) : @@ -56,12 +51,12 @@ inline Foam::SpatialVector::SpatialVector const Vector& 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::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::dual::dual(const SpatialVector& v) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Cmpt& Foam::SpatialVector::wx() const -{ - return this->v_[WX]; -} - - -template -inline const Cmpt& Foam::SpatialVector::wy() const -{ - return this->v_[WY]; -} - - -template -inline const Cmpt& Foam::SpatialVector::wz() const -{ - return this->v_[WZ]; -} - - -template -inline const Cmpt& Foam::SpatialVector::lx() const -{ - return this->v_[LX]; -} - - -template -inline const Cmpt& Foam::SpatialVector::ly() const -{ - return this->v_[LY]; -} - - -template -inline const Cmpt& Foam::SpatialVector::lz() const -{ - return this->v_[LZ]; -} - - -template -inline Cmpt& Foam::SpatialVector::wx() -{ - return this->v_[WX]; -} - - -template -inline Cmpt& Foam::SpatialVector::wy() -{ - return this->v_[WY]; -} - - -template -inline Cmpt& Foam::SpatialVector::wz() -{ - return this->v_[WZ]; -} - - -template -inline Cmpt& Foam::SpatialVector::lx() -{ - return this->v_[LX]; -} - - -template -inline Cmpt& Foam::SpatialVector::ly() -{ - return this->v_[LY]; -} - - -template -inline Cmpt& Foam::SpatialVector::lz() -{ - return this->v_[LZ]; -} - - template inline Foam::Vector Foam::SpatialVector::w() const { - return Vector(this->v_[0], this->v_[1], this->v_[2]); + return Vector(this->v_[WX], this->v_[WY], this->v_[WZ]); } template inline Foam::Vector Foam::SpatialVector::l() const { - return Vector(this->v_[3], this->v_[4], this->v_[5]); + return Vector(this->v_[LX], this->v_[LY], this->v_[LZ]); }