RectangularMatrixI.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 Copyright (C) 2019-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
31template<class Type>
33(
34 const label m,
35 const label n
36)
37:
38 Matrix<RectangularMatrix<Type>, Type>(m, n)
39{}
40
41
42template<class Type>
44(
45 const label n
46)
47:
48 Matrix<RectangularMatrix<Type>, Type>(n, n)
49{}
50
51
52template<class Type>
54(
55 const label m,
56 const label n,
57 const Foam::zero
58)
59:
60 Matrix<RectangularMatrix<Type>, Type>(m, n, Zero)
61{}
62
63
64template<class Type>
66(
67 const label m,
68 const label n,
69 const Type& val
70)
71:
72 Matrix<RectangularMatrix<Type>, Type>(m, n, val)
73{}
74
75
76template<class Type>
77template<class AnyType>
80 const labelPair& dims,
83:
84 Matrix<RectangularMatrix<Type>, Type>(dims.first(), dims.second(), Zero)
85{
86 for (label i = 0; i < min(dims.first(), dims.second()); ++i)
87 {
88 this->operator()(i, i) = pTraits<Type>::one;
89 }
90}
91
92
93template<class Type>
96 const labelPair& dims
97)
98:
101
102
103template<class Type>
105(
106 const labelPair& dims,
108)
109:
110 RectangularMatrix<Type>(dims.first(), dims.second(), Zero)
112
113
114template<class Type>
116(
117 const labelPair& dims,
118 const Type& val
120:
121 RectangularMatrix<Type>(dims.first(), dims.second(), val)
122{}
124
125template<class Type>
126template<class MatrixType>
128(
130)
131:
132 Matrix<RectangularMatrix<Type>, Type>(mat)
133{}
134
135
136template<class Type>
137template<class MatrixType>
139(
140 const MatrixBlock<MatrixType>& mat
142:
143 Matrix<RectangularMatrix<Type>, Type>(mat)
145
146
147template<class Type>
149(
150 const SquareMatrix<Type>& mat
151)
152:
153 Matrix<RectangularMatrix<Type>, Type>(mat)
154{}
155
156
157template<class Type>
159:
160 Matrix<RectangularMatrix<Type>, Type>(is)
161{}
162
163
164template<class Type>
167{
169}
170
171
172// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
173
174template<class Type>
176(
178)
179{
180 this->transfer(mat);
181}
182
183
184template<class Type>
186{
187 Matrix<RectangularMatrix<Type>, Type>::operator=(Zero);
188}
189
190
191template<class Type>
193{
194 Matrix<RectangularMatrix<Type>, Type>::operator=(val);
195}
196
197
198// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199
200namespace Foam
201{
202
203// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
204
205template<class Type>
207{
208public:
209
211};
212
213
214template<class Type>
216{
217public:
218
220};
221
222
223template<class Type>
225{
226public:
227
229};
230
231
232// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
233
234// Return the outer product of Field-Field as RectangularMatrix
235template<class Type>
237(
238 const Field<Type>& f1,
239 const Field<Type>& f2
240)
241{
242 RectangularMatrix<Type> f1f2T(f1.size(), f2.size());
243
244 for (label i = 0; i < f1f2T.m(); ++i)
245 {
246 for (label j = 0; j < f1f2T.n(); ++j)
247 {
248 f1f2T(i, j) = f1[i]*f2[j];
249 }
250 }
251
252 return f1f2T;
253}
254
255
256// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257
258} // End namespace Foam
259
260// ************************************************************************* //
label n
Generic templated field type.
Definition: Field.H:82
T & first() noexcept
The first element of the list, position [0].
Definition: FixedListI.H:207
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:52
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A templated block of an (m x n) matrix of type <MatrixType>.
Definition: MatrixBlock.H:132
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
Definition: Matrix.H:81
label n() const noexcept
The number of columns.
Definition: MatrixI.H:103
label m() const noexcept
The number of rows.
Definition: MatrixI.H:96
const T & second() const noexcept
Return second element, which is also the last element.
Definition: PairI.H:120
A templated (M x N) rectangular matrix of objects of <Type>, containing M*N elements,...
RectangularMatrix & operator=(const RectangularMatrix &)=default
Copy assignment.
autoPtr< RectangularMatrix< Type > > clone() const
Clone.
RectangularMatrix()=default
Default construct.
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix.
Definition: SquareMatrix.H:66
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition: one.H:62
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
Namespace for OpenFOAM.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)