Loading...
Searching...
No Matches
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
37:
38 Matrix<RectangularMatrix<Type>, Type>(m, n)
39{}
40
41
42template<class Type>
44(
45 const label n
47:
48 Matrix<RectangularMatrix<Type>, Type>(n, n)
49{}
50
51
52template<class Type>
54(
55 const label m,
56 const label n,
59:
60 Matrix<RectangularMatrix<Type>, Type>(m, n, Foam::zero{})
61{}
62
63
64template<class Type>
66(
67 const label m,
68 const label n,
69 const Type& val
70)
72 Matrix<RectangularMatrix<Type>, Type>(m, n, val)
73{}
74
75
76template<class Type>
77template<class AnyType>
79(
80 const labelPair& dims,
82)
83:
84 RectangularMatrix<Type>(dims.first(), dims.second(), Foam::zero{})
85{
86 const label len = Foam::min(dims.first(), dims.second());
87
88 for (label i = 0; i < len; ++i)
89 {
90 this->operator()(i, i) = pTraits<Type>::one;
91 }
92}
93
94
95template<class Type>
97(
98 const labelPair& dims
100:
101 RectangularMatrix<Type>(dims.first(), dims.second())
102{}
103
104
105template<class Type>
107(
108 const labelPair& dims,
111:
112 RectangularMatrix<Type>(dims.first(), dims.second(), Foam::zero{})
113{}
114
115
116template<class Type>
118(
119 const labelPair& dims,
120 const Type& val
121)
123 RectangularMatrix<Type>(dims.first(), dims.second(), val)
124{}
125
126
127template<class Type>
128template<class MatrixType>
130(
132)
134 Matrix<RectangularMatrix<Type>, Type>(mat)
135{}
136
137
138template<class Type>
139template<class MatrixType>
141(
142 const MatrixBlock<MatrixType>& mat
144:
145 Matrix<RectangularMatrix<Type>, Type>(mat)
146{}
147
148
149template<class Type>
151(
152 const SquareMatrix<Type>& mat
154:
155 Matrix<RectangularMatrix<Type>, Type>(mat)
156{}
157
158
159template<class Type>
162 Matrix<RectangularMatrix<Type>, Type>(is)
163{}
164
165
166template<class Type>
169{
171}
172
173
174// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
175
176template<class Type>
178(
181{
182 this->transfer(mat);
183}
184
185
186template<class Type>
191
192
193template<class Type>
194inline void Foam::RectangularMatrix<Type>::operator=(const Type& val)
195{
196 Matrix<RectangularMatrix<Type>, Type>::operator=(val);
197}
198
199
200// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202namespace Foam
203{
204
205// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
206
207template<class Type>
209{
210public:
211
213};
215
216template<class Type>
217class typeOfInnerProduct<Type, RectangularMatrix<Type>, SquareMatrix<Type>>
218{
219public:
220
222};
224
225template<class Type>
226class typeOfInnerProduct<Type, SquareMatrix<Type>, RectangularMatrix<Type>>
227{
228public:
229
232
233
234// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
235
236// Return the outer product of Field-Field as RectangularMatrix
237template<class Type>
239(
240 const Field<Type>& f1,
241 const Field<Type>& f2
242)
243{
244 RectangularMatrix<Type> f1f2T(f1.size(), f2.size());
245
246 for (label i = 0; i < f1f2T.m(); ++i)
247 {
248 for (label j = 0; j < f1f2T.n(); ++j)
249 {
250 f1f2T(i, j) = f1[i]*f2[j];
251 }
252 }
253
254 return f1f2T;
255}
256
257
258// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259
260} // End namespace Foam
261
262// ************************************************************************* //
label n
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition Identity.H:46
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A templated block of an (m x n) matrix of type <MatrixType>.
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
Definition Matrix.H:77
const Type & operator()(const label irow, const label jcol) const
Definition MatrixI.H:559
void transfer(Matrix< RectangularMatrix< Type >, Type > &mat)
Definition Matrix.C:294
const T & first() const noexcept
Access the first element.
Definition Pair.H:137
const T & second() const noexcept
Access the second element.
Definition Pair.H:147
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.
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
Abstract template class to provide the form resulting from the inner-product of two forms.
Definition products.H:48
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
Namespace for OpenFOAM.
Pair< label > labelPair
A pair of labels.
Definition Pair.H:54
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)