/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "Vector2D.H" #include "Tensor2D.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template inline Foam::SymmTensor2D::SymmTensor2D() {} template inline Foam::SymmTensor2D::SymmTensor2D(const Foam::zero) : SymmTensor2D::vsType(Zero) {} template inline Foam::SymmTensor2D::SymmTensor2D ( const VectorSpace, Cmpt, 3>& vs ) : SymmTensor2D::vsType(vs) {} template inline Foam::SymmTensor2D::SymmTensor2D(const SphericalTensor2D& st) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[YY] = st.ii(); } template inline Foam::SymmTensor2D::SymmTensor2D ( const Cmpt txx, const Cmpt txy, const Cmpt tyy ) { this->v_[XX] = txx; this->v_[XY] = txy; this->v_[YY] = tyy; } template inline Foam::SymmTensor2D::SymmTensor2D(Istream& is) : SymmTensor2D::vsType(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::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::yy() { return this->v_[YY]; } template inline const Foam::SymmTensor2D& Foam::SymmTensor2D::T() const { return *this; } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template inline void Foam::SymmTensor2D::operator= ( const SphericalTensor2D& st ) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[YY] = st.ii(); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // //- Inner-product between two symmetric tensors template inline Tensor2D operator&(const SymmTensor2D& st1, const SymmTensor2D& st2) { return Tensor2D ( st1.xx()*st2.xx() + st1.xy()*st2.xy(), st1.xx()*st2.xy() + st1.xy()*st2.yy(), st1.xy()*st2.xx() + st1.yy()*st2.xy(), st1.xy()*st2.xy() + st1.yy()*st2.yy() ); } //- Double-dot-product between a symmetric tensor and a symmetric tensor template inline Cmpt operator&&(const SymmTensor2D& st1, const SymmTensor2D& st2) { return ( st1.xx()*st2.xx() + 2*st1.xy()*st2.xy() + st1.yy()*st2.yy() ); } //- Inner-product between a symmetric tensor and a vector template inline Vector2D operator&(const SymmTensor2D& st, const Vector2D& v) { return Vector2D ( st.xx()*v.x() + st.xy()*v.y(), st.xy()*v.x() + st.yy()*v.y() ); } //- Inner-product between a vector and a symmetric tensor template inline Vector2D operator&(const Vector2D& v, const SymmTensor2D& st) { return Vector2D ( v.x()*st.xx() + v.y()*st.xy(), v.x()*st.xy() + v.y()*st.yy() ); } //- Inner-sqr of a symmetric tensor template inline SymmTensor2D innerSqr(const SymmTensor2D& st) { return SymmTensor2D ( st.xx()*st.xx() + st.xy()*st.xy(), st.xx()*st.xy() + st.xy()*st.yy(), st.xy()*st.xy() + st.yy()*st.yy() ); } template inline Cmpt magSqr(const SymmTensor2D& st) { return ( magSqr(st.xx()) + 2*magSqr(st.xy()) + magSqr(st.yy()) ); } //- Return the trace of a symmetric tensor template inline Cmpt tr(const SymmTensor2D& st) { return st.xx() + st.yy(); } //- Return the spherical part of a symmetric tensor template inline SphericalTensor2D sph(const SymmTensor2D& st) { return (1.0/2.0)*tr(st); } //- Return the symmetric part of a symmetric tensor, i.e. itself template inline const SymmTensor2D& symm(const SymmTensor2D& st) { return st; } //- Return twice the symmetric part of a symmetric tensor template inline SymmTensor2D twoSymm(const SymmTensor2D& st) { return 2*st; } //- Return the deviatoric part of a symmetric tensor template inline SymmTensor2D dev(const SymmTensor2D& st) { return st - SphericalTensor2D::oneThirdI*tr(st); } //- Return the deviatoric part of a symmetric tensor template inline SymmTensor2D dev2(const SymmTensor2D& st) { return st - SphericalTensor2D::twoThirdsI*tr(st); } //- Return the determinant of a symmetric tensor template inline Cmpt det(const SymmTensor2D& st) { return ( st.xx()*st.yy() - st.xy()*st.xy() ); } //- Return the cofactor symmetric tensor of a symmetric tensor template inline SymmTensor2D cof(const SymmTensor2D& st) { return SymmTensor2D ( st.yy(), -st.xy(), st.xx() ); } //- Return the inverse of a symmetric tensor give the determinant template inline SymmTensor2D inv(const SymmTensor2D& st, const Cmpt detst) { return cof(st)/detst; } //- Return the inverse of a symmetric tensor template inline SymmTensor2D inv(const SymmTensor2D& st) { return inv(st, det(st)); } //- Return the 1st invariant of a symmetric tensor template inline Cmpt invariantI(const SymmTensor2D& st) { return tr(st); } //- Return the 2nd invariant of a symmetric tensor template inline Cmpt invariantII(const SymmTensor2D& st) { return ( 0.5*sqr(tr(st)) - 0.5* ( st.xx()*st.xx() + st.xy()*st.xy() + st.xy()*st.xy() + st.yy()*st.yy() ) ); } //- Return the 3rd invariant of a symmetric tensor template inline Cmpt invariantIII(const SymmTensor2D& st) { return det(st); } template inline SymmTensor2D operator+(const SphericalTensor2D& spt1, const SymmTensor2D& st2) { return SymmTensor2D ( spt1.ii() + st2.xx(), st2.xy(), spt1.ii() + st2.yy() ); } template inline SymmTensor2D operator+(const SymmTensor2D& st1, const SphericalTensor2D& spt2) { return SymmTensor2D ( st1.xx() + spt2.ii(), st1.xy(), st1.yy() + spt2.ii() ); } template inline SymmTensor2D operator-(const SphericalTensor2D& spt1, const SymmTensor2D& st2) { return SymmTensor2D ( spt1.ii() - st2.xx(), -st2.xy(), spt1.ii() - st2.yy() ); } template inline SymmTensor2D operator-(const SymmTensor2D& st1, const SphericalTensor2D& spt2) { return SymmTensor2D ( st1.xx() - spt2.ii(), st1.xy(), st1.yy() - spt2.ii() ); } //- Inner-product between a spherical symmetric tensor and a symmetric tensor template inline SymmTensor2D operator&(const SphericalTensor2D& spt1, const SymmTensor2D& st2) { return SymmTensor2D ( spt1.ii()*st2.xx(), spt1.ii()*st2.xy(), spt1.ii()*st2.yy() ); } //- Inner-product between a tensor and a spherical tensor template inline SymmTensor2D operator&(const SymmTensor2D& st1, const SphericalTensor2D& spt2) { return SymmTensor2D ( st1.xx()*spt2.ii(), st1.xy()*spt2.ii(), st1.yy()*spt2.ii() ); } //- Double-dot-product between a spherical tensor and a symmetric tensor template inline Cmpt operator&&(const SphericalTensor2D& spt1, const SymmTensor2D& st2) { return(spt1.ii()*st2.xx() + spt1.ii()*st2.yy()); } //- Double-dot-product between a tensor and a spherical tensor template inline Cmpt operator&&(const SymmTensor2D& st1, const SphericalTensor2D& spt2) { return(st1.xx()*spt2.ii() + st1.yy()*spt2.ii()); } template inline SymmTensor2D sqr(const Vector2D& v) { return SymmTensor2D ( v.x()*v.x(), v.x()*v.y(), v.y()*v.y() ); } template class outerProduct, Cmpt> { public: typedef SymmTensor2D type; }; template class outerProduct> { public: typedef SymmTensor2D type; }; template class innerProduct, SymmTensor2D> { public: typedef Tensor2D type; }; template class innerProduct, Vector2D> { public: typedef Vector2D type; }; template class innerProduct, SymmTensor2D> { public: typedef Vector2D type; }; template class typeOfSum, SymmTensor2D> { public: typedef SymmTensor2D type; }; template class typeOfSum, SphericalTensor2D> { public: typedef SymmTensor2D type; }; template class innerProduct, SymmTensor2D> { public: typedef SymmTensor2D type; }; template class innerProduct, SphericalTensor2D> { public: typedef SymmTensor2D type; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // ************************************************************************* //