diff --git a/src/OpenFOAM/primitives/Tensor/Tensor.H b/src/OpenFOAM/primitives/Tensor/Tensor.H index 4a82e7ba2f..985ca6b081 100644 --- a/src/OpenFOAM/primitives/Tensor/Tensor.H +++ b/src/OpenFOAM/primitives/Tensor/Tensor.H @@ -152,11 +152,11 @@ public: inline Cmpt& zz(); // Access vector components. - // Note: returning const only to find out lhs usage - inline const Vector x() const; - inline const Vector y() const; - inline const Vector z() const; + inline Vector x() const; + inline Vector y() const; + inline Vector z() const; + inline Vector vectorComponent(const direction) const; //- Transpose inline Tensor T() const; diff --git a/src/OpenFOAM/primitives/Tensor/TensorI.H b/src/OpenFOAM/primitives/Tensor/TensorI.H index 06c52b75c3..8ba9d24a12 100644 --- a/src/OpenFOAM/primitives/Tensor/TensorI.H +++ b/src/OpenFOAM/primitives/Tensor/TensorI.H @@ -118,24 +118,42 @@ inline Tensor::Tensor(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline const Vector Tensor::x() const +inline Vector Tensor::x() const { return Vector(this->v_[XX], this->v_[XY], this->v_[XZ]); } template -inline const Vector Tensor::y() const +inline Vector Tensor::y() const { return Vector(this->v_[YX], this->v_[YY], this->v_[YZ]); } template -inline const Vector Tensor::z() const +inline Vector Tensor::z() const { return Vector(this->v_[ZX], this->v_[ZY], this->v_[ZZ]); } +template +inline Vector Tensor::vectorComponent(const direction cmpt) const +{ + switch (cmpt) + { + case 0: + return x(); + break; + case 1: + return y(); + break; + case 2: + return z(); + break; + } +} + + template inline const Cmpt& Tensor::xx() const {