1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
30 \*---------------------------------------------------------------------------*/
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
41 //- Return tensor transpose
43 inline tensor2 tensor2::T() const
47 transpose[0] = this->operator[](0);
48 transpose[1] = this->operator[](2);
49 transpose[2] = this->operator[](1);
50 transpose[3] = this->operator[](3);
56 //- Assign to a sphericalTensor2
58 inline void tensor2::operator=(const sphericalTensor2& st)
67 //- Assign to a diagTensor2
69 inline void tensor2::operator=(const diagTensor2& dt)
77 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
79 //- Inner-product between two tensors
81 operator&(const tensor2& t1, const tensor2& t2)
85 result[0] = t1[0]*t2[0] + t1[1]*t2[2];
86 result[1] = t1[0]*t2[1] + t1[1]*t2[3];
87 result[2] = t1[2]*t2[0] + t1[3]*t2[2];
88 result[3] = t1[2]*t2[1] + t1[3]*t2[3];
94 //- Inner-product between a diagonal tensors and a tensor
96 operator&(const diagTensor2& dt1, const tensor2& t2)
100 result[0] = dt1[0]*t2[0];
101 result[1] = dt1[0]*t2[1];
102 result[2] = dt1[1]*t2[2];
103 result[3] = dt1[1]*t2[3];
108 //- Inner-product between a tensor and diagonal tensor
110 operator&(const tensor2& t1, const diagTensor2& dt2)
114 result[0] = t1[0]*dt2[0];
115 result[1] = t1[1]*dt2[1];
116 result[2] = t1[2]*dt2[0];
117 result[3] = t1[3]*dt2[1];
123 //- Inner-product between a spherical tensor and a tensor
125 operator&(const sphericalTensor2& st1, const tensor2& t2)
129 result[0] = st1[0]*t2[0];
130 result[1] = st1[0]*t2[1];
131 result[2] = st1[0]*t2[2];
132 result[3] = st1[0]*t2[3];
137 //- Inner-product between a tensor and spherical tensor
139 operator&(const tensor2& t1, const sphericalTensor2& st2)
143 result[0] = t1[0]*st2[0];
144 result[1] = t1[1]*st2[0];
145 result[2] = t1[2]*st2[0];
146 result[3] = t1[3]*st2[0];
152 //- Inner-product between a tensor and a vector
154 operator&(const tensor2& t, const vector2& v)
158 result[0] = t[0]*v[0] + t[1]*v[1];
159 result[1] = t[2]*v[0] + t[3]*v[1];
165 //- Inner-product between a vector and a tensor
167 operator&(const vector2& v, const tensor2& t)
171 result[0] = v[0]*t[0] + v[1]*t[2];
172 result[1] = v[0]*t[1] + v[1]*t[3];
178 //- Outer-product between two vectors
180 operator*(const vector2& v1, const vector2& v2)
184 result[0] = v1[0]*v2[0];
185 result[1] = v1[0]*v2[1];
186 result[2] = v1[1]*v2[0];
187 result[3] = v1[1]*v2[1];
193 //- Return the determinant of a tensor
194 inline scalar det(const tensor2& t)
202 //- Return the inverse of a tensor given the determinant
203 inline tensor2 inv(const tensor2& t)
212 return cofactor/det(t);
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 } // End namespace Foam
220 // ************************************************************************* //