diff --git a/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H b/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H index 8d5f5d43bf93cc1ee756b6a0ebbd4b35164d6182..76db32c69adf1ceecec7c5b7d7be260a5739b6a7 100644 --- a/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H +++ b/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H @@ -41,7 +41,7 @@ SourceFiles #define SymmTensor_H #include "contiguous.H" -#include "VectorSpace.H" +#include "Vector.H" #include "SphericalTensor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -104,12 +104,12 @@ public: ); //- Construct from Istream - SymmTensor(Istream&); + inline SymmTensor(Istream&); // Member Functions - // Access + // Component access inline const Cmpt& xx() const; inline const Cmpt& xy() const; @@ -125,6 +125,18 @@ public: inline Cmpt& yz(); inline Cmpt& zz(); + + // Diagonal access. + + //- Extract the diagonal as a vector + inline Vector<Cmpt> diag() const; + + //- Set values of the diagonal + inline void diag(const Vector<Cmpt>& v); + + + // Tensor Operations + //- Transpose inline const SymmTensor<Cmpt>& T() const; diff --git a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H index 2f43ad41d33f13e701833c5874c3dae157c24d70..9893b83c30901e60859ced2893c956cea1f44bcb 100644 --- a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H +++ b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -25,7 +25,6 @@ License \*---------------------------------------------------------------------------*/ -#include "Vector.H" #include "Tensor.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -159,6 +158,20 @@ inline Cmpt& Foam::SymmTensor<Cmpt>::zz() } +template<class Cmpt> +inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::diag() const +{ + return Vector<Cmpt>(this->v_[XX], this->v_[YY], this->v_[ZZ]); +} + + +template<class Cmpt> +inline void Foam::SymmTensor<Cmpt>::diag(const Vector<Cmpt>& v) +{ + this->v_[XX] = v.x(); this->v_[YY] = v.y(); this->v_[ZZ] = v.z(); +} + + template<class Cmpt> inline const Foam::SymmTensor<Cmpt>& Foam::SymmTensor<Cmpt>::T() const { diff --git a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H index f76790d29ae7f218a25b7273c2d6b0c18c7ebead..e1ec619ca9480e2b328133a312cf0c3d7450afb0 100644 --- a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H +++ b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H @@ -41,7 +41,7 @@ SourceFiles #define SymmTensor2D_H #include "contiguous.H" -#include "VectorSpace.H" +#include "Vector2D.H" #include "SphericalTensor2D.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -102,7 +102,7 @@ public: ); //- Construct from Istream - SymmTensor2D(Istream&); + inline SymmTensor2D(Istream&); // Member Functions @@ -117,6 +117,16 @@ public: inline Cmpt& xy(); inline Cmpt& yy(); + + // Diagonal access. + + //- Extract the diagonal as a vector + inline Vector2D<Cmpt> diag() const; + + //- Set values of the diagonal + inline void diag(const Vector2D<Cmpt>& v); + + //- Transpose inline const SymmTensor2D<Cmpt>& T() const; diff --git a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H index c91a38e4272389b83f9183c33faf30fca9c55a81..e957c88debe94801109d5d0f56c720aadf1ef82b 100644 --- a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H +++ b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -25,7 +25,6 @@ License \*---------------------------------------------------------------------------*/ -#include "Vector2D.H" #include "Tensor2D.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -119,6 +118,20 @@ inline Cmpt& Foam::SymmTensor2D<Cmpt>::yy() } +template<class Cmpt> +inline Foam::Vector2D<Cmpt> Foam::SymmTensor2D<Cmpt>::diag() const +{ + return Vector2D<Cmpt>(this->v_[XX], this->v_[YY]); +} + + +template<class Cmpt> +inline void Foam::SymmTensor2D<Cmpt>::diag(const Vector2D<Cmpt>& v) +{ + this->v_[XX] = v.x(); this->v_[YY] = v.y(); +} + + template<class Cmpt> inline const Foam::SymmTensor2D<Cmpt>& Foam::SymmTensor2D<Cmpt>::T() const { diff --git a/src/OpenFOAM/primitives/Tensor/Tensor.H b/src/OpenFOAM/primitives/Tensor/Tensor.H index 322e6b31e289762b02b2cf513b0110f81ae039be..94f8b388ba7c0ea2f00fd7d2cb6f0813f40fd901 100644 --- a/src/OpenFOAM/primitives/Tensor/Tensor.H +++ b/src/OpenFOAM/primitives/Tensor/Tensor.H @@ -229,9 +229,14 @@ public: // Runtime check of row index. inline void row(const direction r, const Vector<Cmpt>& v); - //- Return vector for given row (0,1,2) - // Runtime check of row index. - inline Vector<Cmpt> vectorComponent(const direction cmpt) const; + + // Diagonal access. + + //- Extract the diagonal as a vector + inline Vector<Cmpt> diag() const; + + //- Set values of the diagonal + inline void diag(const Vector<Cmpt>& v); // Tensor Operations @@ -269,6 +274,16 @@ public: //- Assign to a triad of row vectors inline void operator=(const Vector<Vector<Cmpt>>&); + + + // Housekeeping + + //- Deprecated(2018-12) Return vector for given row (0,1) + // \deprecated(2018-12) use row() method + Vector<Cmpt> vectorComponent(const direction cmpt) const + { + return row(cmpt); + } }; diff --git a/src/OpenFOAM/primitives/Tensor/TensorI.H b/src/OpenFOAM/primitives/Tensor/TensorI.H index b5cbada94daee21502b1d231b8654862f1f45b81..afb86da786ad5e0074c1eb1adebc2174beb667ee 100644 --- a/src/OpenFOAM/primitives/Tensor/TensorI.H +++ b/src/OpenFOAM/primitives/Tensor/TensorI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -460,12 +460,16 @@ inline void Foam::Tensor<Cmpt>::row(const direction r, const Vector<Cmpt>& v) template<class Cmpt> -inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::vectorComponent -( - const direction cmpt -) const +inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::diag() const +{ + return Vector<Cmpt>(this->v_[XX], this->v_[YY], this->v_[ZZ]); +} + + +template<class Cmpt> +inline void Foam::Tensor<Cmpt>::diag(const Vector<Cmpt>& v) { - return row(cmpt); + this->v_[XX] = v.x(); this->v_[YY] = v.y(); this->v_[ZZ] = v.z(); } diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H index f0cff04b734a62b7212c3e67b26613d22b8ae017..e6865f6abcf421fd20bd975f851a7d4b240db033 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H @@ -185,9 +185,14 @@ public: // Runtime check of row index. inline void row(const direction r, const Vector2D<Cmpt>& v); - //- Return vector for given row (0,1) - // Runtime check of row index. - inline Vector2D<Cmpt> vectorComponent(const direction cmpt) const; + + // Diagonal access. + + //- Extract the diagonal as a vector + inline Vector2D<Cmpt> diag() const; + + //- Set values of the diagonal + inline void diag(const Vector2D<Cmpt>& v); // Tensor Operations @@ -209,6 +214,16 @@ public: //- Copy assign from SphericalTensor2D inline void operator=(const SphericalTensor2D<Cmpt>&); + + + // Housekeeping + + //- Deprecated(2018-12) Return vector for given row (0,1) + // \deprecated(2018-12) use row() method + Vector2D<Cmpt> vectorComponent(const direction cmpt) const + { + return row(cmpt); + } }; diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H index f5a88023e8da087816535e7b36a1dff43d4bce7b..fd8079a02e7407b66d53f41f710fd3f38ebbea11 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H @@ -305,12 +305,16 @@ inline void Foam::Tensor2D<Cmpt>::row template<class Cmpt> -inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::vectorComponent -( - const direction cmpt -) const +inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::diag() const +{ + return Vector2D<Cmpt>(this->v_[XX], this->v_[YY]); +} + + +template<class Cmpt> +inline void Foam::Tensor2D<Cmpt>::diag(const Vector2D<Cmpt>& v) { - return row(cmpt); + this->v_[XX] = v.x(); this->v_[YY] = v.y(); }