OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

simpleMatrix.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2007 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     simpleMatrix
00027 
00028 Description
00029 
00030 SourceFiles
00031     simpleMatrix.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef simpleMatrix_H
00036 #define simpleMatrix_H
00037 
00038 #include "scalarMatrix.H"
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044 
00045 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00046 
00047 template<class T>
00048 class simpleMatrix;
00049 
00050 template<class T>
00051 simpleMatrix<T> operator+
00052 (
00053     const simpleMatrix<T>&,
00054     const simpleMatrix<T>&
00055 );
00056 
00057 template<class T>
00058 simpleMatrix<T> operator-
00059 (
00060     const simpleMatrix<T>&,
00061     const simpleMatrix<T>&
00062 );
00063 
00064 template<class T>
00065 simpleMatrix<T> operator*
00066 (
00067     const scalar,
00068     const simpleMatrix<T>&
00069 );
00070 
00071 template<class T>
00072 Ostream& operator<<
00073 (
00074     Ostream&,
00075     const simpleMatrix<T>&
00076 );
00077 
00078 
00079 /*---------------------------------------------------------------------------*\
00080                            Class simpleMatrix Declaration
00081 \*---------------------------------------------------------------------------*/
00082 
00083 template<class T>
00084 class simpleMatrix
00085 :
00086     public scalarMatrix
00087 {
00088     // Private data
00089 
00090         Field<T> source_;
00091 
00092 
00093 public:
00094 
00095     // Constructors
00096 
00097         //- Construct given size
00098         simpleMatrix(const label);
00099 
00100         //- Construct from components
00101         simpleMatrix(const scalarMatrix&, const Field<T>&);
00102 
00103         //- Construct from Istream
00104         simpleMatrix(Istream&);
00105 
00106         //- Construct as copy
00107         simpleMatrix(const simpleMatrix<T>&);
00108 
00109 
00110     // Member Functions
00111 
00112         // Access
00113 
00114             Field<T>& source()
00115             {
00116                 return source_;
00117             }
00118 
00119             const Field<T>& source() const
00120             {
00121                 return source_;
00122             }
00123 
00124 
00125         //- Solve the matrix using Gaussian elimination with pivoting
00126         //  and return the solution
00127         Field<T> solve() const;
00128 
00129         //- Solve the matrix using LU decomposition with pivoting
00130         //  and return the solution
00131         Field<T> LUsolve() const;
00132 
00133 
00134     // Member Operators
00135 
00136         void operator=(const simpleMatrix<T>&);
00137 
00138 
00139     // Friend Operators
00140 
00141         friend simpleMatrix<T> operator+ <T>
00142         (
00143             const simpleMatrix<T>&,
00144             const simpleMatrix<T>&
00145         );
00146 
00147         friend simpleMatrix<T> operator- <T>
00148         (
00149             const simpleMatrix<T>&,
00150             const simpleMatrix<T>&
00151         );
00152 
00153         friend simpleMatrix<T> operator* <T>
00154         (
00155             const scalar,
00156             const simpleMatrix<T>&
00157         );
00158 
00159 
00160     // Ostream Operator
00161 
00162         friend Ostream& operator<< <T>
00163         (
00164             Ostream&,
00165             const simpleMatrix<T>&
00166         );
00167 };
00168 
00169 
00170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00171 
00172 } // End namespace Foam
00173 
00174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00175 
00176 #ifdef NoRepository
00177 #   include "simpleMatrix.C"
00178 #endif
00179 
00180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00181 
00182 #endif
00183 
00184 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd