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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::simpleMatrix
28
29Description
30 A simple square matrix solver with scalar coefficients.
31
32SourceFiles
33 simpleMatrix.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef simpleMatrix_H
38#define simpleMatrix_H
39
40#include "scalarMatrices.H"
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace Foam
45{
46
47// Forward declaration of friend functions and operators
48
49template<class Type>
50class simpleMatrix;
51
52template<class Type>
53Ostream& operator<<
54(
55 Ostream&,
57);
58
59
60/*---------------------------------------------------------------------------*\
61 Class simpleMatrix Declaration
62\*---------------------------------------------------------------------------*/
63
64template<class Type>
65class simpleMatrix
66:
68{
69 // Private data
70
71 Field<Type> source_;
72
73
74public:
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
128 friend Ostream& operator<< <Type>
129 (
130 Ostream&,
131 const simpleMatrix<Type>&
132 );
133};
134
135
136// Global operators
137
138template<class Type>
139simpleMatrix<Type> operator+
140(
141 const simpleMatrix<Type>&,
142 const simpleMatrix<Type>&
143);
144
145template<class Type>
146simpleMatrix<Type> operator-
147(
148 const simpleMatrix<Type>&,
149 const simpleMatrix<Type>&
150);
151
152template<class Type>
153simpleMatrix<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// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A simple square matrix solver with scalar coefficients.
Definition: simpleMatrix.H:67
void operator=(const simpleMatrix< Type > &)
Definition: simpleMatrix.C:103
simpleMatrix(const simpleMatrix< Type > &)
Construct as copy.
const Field< Type > & source() const
Return const-access to the source.
Definition: simpleMatrix.H:105
Field< Type > & source()
Return access to the source.
Definition: simpleMatrix.H:99
Field< Type > solve() const
Solve the matrix using Gaussian elimination with pivoting.
Definition: simpleMatrix.C:77
Field< Type > LUsolve() const
Solve the matrix using LU decomposition with pivoting.
Definition: simpleMatrix.C:89
Namespace for OpenFOAM.