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