00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::simpleMatrix 00026 00027 Description 00028 A simple square matrix solver with scalar coefficients. 00029 00030 SourceFiles 00031 simpleMatrix.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef simpleMatrix_H 00036 #define simpleMatrix_H 00037 00038 #include <OpenFOAM/scalarMatrices.H> 00039 00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00041 00042 namespace Foam 00043 { 00044 00045 // Forward declaration of friend functions and operators 00046 00047 template<class Type> 00048 class simpleMatrix; 00049 00050 template<class Type> 00051 Ostream& operator<< 00052 ( 00053 Ostream&, 00054 const simpleMatrix<Type>& 00055 ); 00056 00057 00058 /*---------------------------------------------------------------------------*\ 00059 Class simpleMatrix Declaration 00060 \*---------------------------------------------------------------------------*/ 00061 00062 template<class Type> 00063 class simpleMatrix 00064 : 00065 public scalarSquareMatrix 00066 { 00067 // Private data 00068 00069 Field<Type> source_; 00070 00071 00072 public: 00073 00074 // Constructors 00075 00076 //- Construct given size 00077 // Note: this does not initialise the coefficients or the source. 00078 simpleMatrix(const label); 00079 00080 //- Construct given size and initial values for the 00081 // coefficients and source 00082 simpleMatrix(const label, const scalar, const Type&); 00083 00084 //- Construct from components 00085 simpleMatrix(const scalarSquareMatrix&, const Field<Type>&); 00086 00087 //- Construct from Istream 00088 simpleMatrix(Istream&); 00089 00090 //- Construct as copy 00091 simpleMatrix(const simpleMatrix<Type>&); 00092 00093 00094 // Member Functions 00095 00096 // Access 00097 00098 //- Return access to the source 00099 Field<Type>& source() 00100 { 00101 return source_; 00102 } 00103 00104 //- Return const-access to the source 00105 const Field<Type>& source() const 00106 { 00107 return source_; 00108 } 00109 00110 00111 //- Solve the matrix using Gaussian elimination with pivoting 00112 // and return the solution 00113 Field<Type> solve() const; 00114 00115 //- Solve the matrix using LU decomposition with pivoting 00116 // and return the solution 00117 Field<Type> LUsolve() const; 00118 00119 00120 // Member Operators 00121 00122 void operator=(const simpleMatrix<Type>&); 00123 00124 00125 // Ostream Operator 00126 00127 friend Ostream& operator<< <Type> 00128 ( 00129 Ostream&, 00130 const simpleMatrix<Type>& 00131 ); 00132 }; 00133 00134 00135 // Global operators 00136 00137 template<class Type> 00138 simpleMatrix<Type> operator+ 00139 ( 00140 const simpleMatrix<Type>&, 00141 const simpleMatrix<Type>& 00142 ); 00143 00144 template<class Type> 00145 simpleMatrix<Type> operator- 00146 ( 00147 const simpleMatrix<Type>&, 00148 const simpleMatrix<Type>& 00149 ); 00150 00151 template<class Type> 00152 simpleMatrix<Type> operator* 00153 ( 00154 const scalar, 00155 const simpleMatrix<Type>& 00156 ); 00157 00158 00159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00160 00161 } // End namespace Foam 00162 00163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00164 00165 #ifdef NoRepository 00166 # include "simpleMatrix.C" 00167 #endif 00168 00169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00170 00171 #endif 00172 00173 // ************************ vim: set sw=4 sts=4 et: ************************ //