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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::simpleMatrix
28 
29 Description
30  A simple square matrix solver with scalar coefficients.
31 
32 SourceFiles
33  simpleMatrix.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef simpleMatrix_H
38 #define simpleMatrix_H
39 
40 #include "scalarMatrices.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of friend functions and operators
48 
49 template<class Type>
50 class simpleMatrix;
51 
52 template<class Type>
53 Ostream& operator<<
54 (
55  Ostream&,
56  const simpleMatrix<Type>&
57 );
58 
59 
60 /*---------------------------------------------------------------------------*\
61  Class simpleMatrix Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 template<class Type>
65 class simpleMatrix
66 :
67  public scalarSquareMatrix
68 {
69  // Private data
70 
71  Field<Type> source_;
72 
73 
74 public:
75 
76  // Constructors
77 
78  //- Construct given size
79  // Note: this does not initialise the coefficients or the source.
80  simpleMatrix(const label);
81 
82  //- Construct given size and initial values for coefficients and source
83  simpleMatrix(const label, const scalar, const Type&);
84 
85  //- Construct from components
87 
88  //- Construct from Istream
90 
91  //- Construct as copy
93 
94 
95  // Member Functions
96 
97  // Access
98 
99  //- Return access to the source
101  {
102  return source_;
103  }
104 
105  //- Return const-access to the source
106  const Field<Type>& source() const
107  {
108  return source_;
109  }
110 
111 
112  //- Solve the matrix using Gaussian elimination with pivoting
113  // and return the solution
114  Field<Type> solve() const;
115 
116  //- Solve the matrix using LU decomposition with pivoting
117  // and return the solution
118  Field<Type> LUsolve() const;
119 
120 
121  // Member Operators
122 
123  void operator=(const simpleMatrix<Type>&);
124 
125 
126  // Ostream Operator
127 
128  friend Ostream& operator<< <Type>
129  (
130  Ostream&,
131  const simpleMatrix<Type>&
132  );
133 };
134 
135 
136 // Global operators
137 
138 template<class Type>
139 simpleMatrix<Type> operator+
140 (
141  const simpleMatrix<Type>&,
142  const simpleMatrix<Type>&
143 );
144 
145 template<class Type>
146 simpleMatrix<Type> operator-
147 (
148  const simpleMatrix<Type>&,
149  const simpleMatrix<Type>&
150 );
151 
152 template<class Type>
153 simpleMatrix<Type> operator*
154 (
155  const scalar,
156  const simpleMatrix<Type>&
157 );
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #ifdef NoRepository
167  #include "simpleMatrix.C"
168 #endif
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #endif
173 
174 // ************************************************************************* //
Foam::simpleMatrix::operator=
void operator=(const simpleMatrix< Type > &)
Definition: simpleMatrix.C:103
Foam::simpleMatrix
A simple square matrix solver with scalar coefficients.
Definition: simpleMatrix.H:49
Foam::simpleMatrix::LUsolve
Field< Type > LUsolve() const
Solve the matrix using LU decomposition with pivoting.
Definition: simpleMatrix.C:89
Foam::simpleMatrix::source
Field< Type > & source()
Return access to the source.
Definition: simpleMatrix.H:99
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::simpleMatrix::simpleMatrix
simpleMatrix(const label)
Construct given size.
Definition: simpleMatrix.C:34
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SquareMatrix< scalar >
scalarMatrices.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::simpleMatrix::solve
Field< Type > solve() const
Solve the matrix using Gaussian elimination with pivoting.
Definition: simpleMatrix.C:77
simpleMatrix.C
Foam::simpleMatrix::source
const Field< Type > & source() const
Return const-access to the source.
Definition: simpleMatrix.H:105