matrix2D.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh 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.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  matrix2D
26 
27 Description
28  Implementation of 2 x 2 matrix
29 
30 SourceFiles
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef matrix2D_H
35 #define matrix2D_H
36 
37 #include "scalar.H"
38 #include "FixedList.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class matrix2D Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class matrix2D
50 : public FixedList<FixedList<scalar, 2>, 2>
51 {
52  // Private members
53  scalar det_;
54  bool calculatedDet_;
55 
56  // Private member functions
57  //- calculate matrix determinant
58  inline void calculateDeterminant();
59 
60 public:
61 
62  // Constructors
63  //- Null constructor
64  explicit inline matrix2D();
65 
66  //- Copy constructor
67  inline matrix2D(const matrix2D&);
68 
69  // Destructor
70  inline ~matrix2D();
71 
72  // Member functions
73  //- return matrix determinant
74  inline scalar determinant();
75 
76  //- return inverse matrix
77  inline matrix2D inverse();
78 
79  //- find the solution of the system with the given rhs
81  (
82  const FixedList<scalar, 2>& source
83  );
84 
85  //- return the first component of the solution vector
86  inline scalar solveFirst(const FixedList<scalar, 2>& source);
87 
88  //- return the second component of the solution vector
89  inline scalar solveSecond(const FixedList<scalar, 2>& source);
90 };
91 
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 
94 } // End namespace Foam
95 
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97 
98 #include "matrix2DI.H"
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 #endif
103 
104 // ************************************************************************* //
Foam::matrix2D::determinant
scalar determinant()
return matrix determinant
Definition: matrix2DI.H:70
Foam::matrix2D::solveSecond
scalar solveSecond(const FixedList< scalar, 2 > &source)
return the second component of the solution vector
Definition: matrix2DI.H:117
Foam::matrix2D::matrix2D
matrix2D()
Null constructor.
Definition: matrix2DI.H:52
Foam::matrix2D::solveFirst
scalar solveFirst(const FixedList< scalar, 2 > &source)
return the first component of the solution vector
Definition: matrix2DI.H:104
Foam::matrix2D::calculatedDet_
bool calculatedDet_
Definition: matrix2D.H:53
Foam::matrix2D
Definition: matrix2D.H:48
Foam::matrix2D::inverse
matrix2D inverse()
return inverse matrix
Definition: matrix2DI.H:77
scalar.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
matrix2DI.H
Foam::FixedList
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
Foam::matrix2D::solve
FixedList< scalar, 2 > solve(const FixedList< scalar, 2 > &source)
find the solution of the system with the given rhs
Definition: matrix2DI.H:93
Foam::matrix2D::~matrix2D
~matrix2D()
Definition: matrix2DI.H:65
FixedList.H
Foam::matrix2D::calculateDeterminant
void calculateDeterminant()
calculate matrix determinant
Definition: matrix2DI.H:39
Foam::matrix2D::det_
scalar det_
Definition: matrix2D.H:52