00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef simpleMatrix_H
00036 #define simpleMatrix_H
00037
00038 #include "Matrix.H"
00039 #include "Field.H"
00040 #include "scalar.H"
00041 #include "labelList.H"
00042
00043
00044
00045 namespace Foam
00046 {
00047
00048 class Istream;
00049 class Ostream;
00050
00051
00052
00053 template<class T>
00054 class simpleMatrix;
00055
00056 template<class T>
00057 simpleMatrix<T> operator+
00058 (
00059 const simpleMatrix<T>&,
00060 const simpleMatrix<T>&
00061 );
00062
00063 template<class T>
00064 simpleMatrix<T> operator-
00065 (
00066 const simpleMatrix<T>&,
00067 const simpleMatrix<T>&
00068 );
00069
00070 template<class T>
00071 simpleMatrix<T> operator*
00072 (
00073 const scalar,
00074 const simpleMatrix<T>&
00075 );
00076
00077 template<class T>
00078 Ostream& operator<<
00079 (
00080 Ostream&,
00081 const simpleMatrix<T>&
00082 );
00083
00084
00085
00086
00087
00088
00089 template<class T>
00090 class simpleMatrix
00091 {
00092
00093
00094 Matrix<scalar> matrix_;
00095 Field<T> source_;
00096
00097
00098 public:
00099
00100
00101
00102
00103 simpleMatrix(const label);
00104
00105
00106 simpleMatrix(const Matrix<scalar>&, const Field<T>&);
00107
00108
00109 simpleMatrix(Istream&);
00110
00111
00112 simpleMatrix(const simpleMatrix<T>&);
00113
00114
00115
00116
00117
00118
00119 Matrix<scalar>& matrix()
00120 {
00121 return matrix_;
00122 }
00123
00124 Field<T>& source()
00125 {
00126 return source_;
00127 }
00128
00129 const Matrix<scalar>& matrix() const
00130 {
00131 return matrix_;
00132 }
00133
00134 const Field<T>& source() const
00135 {
00136 return source_;
00137 }
00138
00139
00140
00141 static void solve(Matrix<scalar>& matrix, Field<T>& source);
00142
00143
00144
00145 Field<T> solve() const;
00146
00147
00148
00149 static void LUDecompose
00150 (
00151 Matrix<scalar>& matrix,
00152 labelList& pivotIndices
00153 );
00154
00155
00156
00157 static void LUBacksubstitute
00158 (
00159 const Matrix<scalar>& luMmatrix,
00160 const labelList& pivotIndices,
00161 Field<T>& source
00162 );
00163
00164
00165
00166 static void LUsolve(Matrix<scalar>& matrix, Field<T>& source);
00167
00168
00169
00170 Field<T> LUsolve() const;
00171
00172
00173
00174
00175 void operator=(const simpleMatrix<T>&);
00176
00177
00178
00179
00180 friend simpleMatrix<T> operator+ <T>
00181 (
00182 const simpleMatrix<T>&,
00183 const simpleMatrix<T>&
00184 );
00185
00186 friend simpleMatrix<T> operator- <T>
00187 (
00188 const simpleMatrix<T>&,
00189 const simpleMatrix<T>&
00190 );
00191
00192 friend simpleMatrix<T> operator* <T>
00193 (
00194 const scalar,
00195 const simpleMatrix<T>&
00196 );
00197
00198
00199
00200
00201 friend Ostream& operator<< <T>
00202 (
00203 Ostream&,
00204 const simpleMatrix<T>&
00205 );
00206 };
00207
00208
00209
00210
00211 }
00212
00213
00214
00215 #ifdef NoRepository
00216 # include "simpleMatrix.C"
00217 #endif
00218
00219
00220
00221 #endif
00222
00223