FreeFOAM The Cross-Platform CFD Toolkit
simpleMatrix.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::simpleMatrix
26 
27 Description
28  A simple square matrix solver with scalar coefficients.
29 
30 SourceFiles
31  simpleMatrix.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef simpleMatrix_H
36 #define simpleMatrix_H
37 
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 // Forward declaration of friend functions and operators
46 
47 template<class Type>
48 class simpleMatrix;
49 
50 template<class Type>
51 Ostream& operator<<
52 (
53  Ostream&,
54  const simpleMatrix<Type>&
55 );
56 
57 
58 /*---------------------------------------------------------------------------*\
59  Class simpleMatrix Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 template<class Type>
64 :
65  public scalarSquareMatrix
66 {
67  // Private data
68 
69  Field<Type> source_;
70 
71 
72 public:
73 
74  // Constructors
75 
76  //- Construct given size
77  // Note: this does not initialise the coefficients or the source.
78  simpleMatrix(const label);
79 
80  //- Construct given size and initial values for the
81  // coefficients and source
82  simpleMatrix(const label, const scalar, const Type&);
83 
84  //- Construct from components
86 
87  //- Construct from Istream
89 
90  //- Construct as copy
92 
93 
94  // Member Functions
95 
96  // Access
97 
98  //- Return access to the source
100  {
101  return source_;
102  }
103 
104  //- Return const-access to the source
105  const Field<Type>& source() const
106  {
107  return source_;
108  }
109 
110 
111  //- Solve the matrix using Gaussian elimination with pivoting
112  // and return the solution
113  Field<Type> solve() const;
114 
115  //- Solve the matrix using LU decomposition with pivoting
116  // and return the solution
117  Field<Type> LUsolve() const;
118 
119 
120  // Member Operators
121 
122  void operator=(const simpleMatrix<Type>&);
123 
124 
125  // Ostream Operator
126 
127  friend Ostream& operator<< <Type>
128  (
129  Ostream&,
130  const simpleMatrix<Type>&
131  );
132 };
133 
134 
135 // Global operators
136 
137 template<class Type>
138 simpleMatrix<Type> operator+
139 (
140  const simpleMatrix<Type>&,
141  const simpleMatrix<Type>&
142 );
143 
144 template<class Type>
145 simpleMatrix<Type> operator-
146 (
147  const simpleMatrix<Type>&,
148  const simpleMatrix<Type>&
149 );
150 
151 template<class Type>
152 simpleMatrix<Type> operator*
153 (
154  const scalar,
155  const simpleMatrix<Type>&
156 );
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #ifdef NoRepository
166 # include "simpleMatrix.C"
167 #endif
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************ vim: set sw=4 sts=4 et: ************************ //