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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
40 //- Return the determinant of a tensor
41 inline scalar det(const tensor3& t)
45 t[0]*t[4]*t[8] + t[1]*t[5]*t[6]
46 + t[2]*t[3]*t[7] - t[0]*t[5]*t[7]
47 - t[1]*t[3]*t[8] - t[2]*t[4]*t[6]
52 //- Return the inverse of a tensor given the determinant
53 inline tensor3 inv(const tensor3& t)
57 cofactor[0] = t[4]*t[8] - t[7]*t[5];
58 cofactor[1] = t[6]*t[5] - t[3]*t[8];
59 cofactor[2] = t[3]*t[7] - t[4]*t[6];
60 cofactor[3] = t[2]*t[7] - t[1]*t[8];
61 cofactor[4] = t[0]*t[8] - t[2]*t[6];
62 cofactor[5] = t[1]*t[6] - t[0]*t[7];
63 cofactor[6] = t[1]*t[5] - t[2]*t[4];
64 cofactor[7] = t[3]*t[2] - t[0]*t[5];
65 cofactor[8] = t[0]*t[4] - t[3]*t[1];
67 return cofactor/det(t);
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 } // End namespace Foam
74 // ************************************************************************* //