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 -------------------------------------------------------------------------------
11 License
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 
31 template<class Type>
33 (
34  const label m,
35  const label n
36 )
37 :
38  Matrix<RectangularMatrix<Type>, Type>(m, n)
39 {}
40 
41 
42 template<class Type>
44 (
45  const label n
46 )
47 :
48  Matrix<RectangularMatrix<Type>, Type>(n, n)
49 {}
50 
51 
52 template<class Type>
54 (
55  const label m,
56  const label n,
57  const Foam::zero
58 )
59 :
60  Matrix<RectangularMatrix<Type>, Type>(m, n, Foam::zero{})
61 {}
62 
63 
64 template<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 
76 template<class Type>
77 template<class AnyType>
79 (
80  const labelPair& dims,
81  const Identity<AnyType>
82 )
83 :
84  RectangularMatrix<Type>(dims.first(), dims.second(), Foam::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 
93 template<class Type>
95 (
96  const labelPair& dims
97 )
98 :
99  RectangularMatrix<Type>(dims.first(), dims.second())
100 {}
101 
102 
103 template<class Type>
105 (
106  const labelPair& dims,
107  const Foam::zero
108 )
109 :
110  RectangularMatrix<Type>(dims.first(), dims.second(), Foam::zero{})
111 {}
112 
113 
114 template<class Type>
116 (
117  const labelPair& dims,
118  const Type& val
119 )
120 :
121  RectangularMatrix<Type>(dims.first(), dims.second(), val)
122 {}
123 
124 
125 template<class Type>
126 template<class MatrixType>
128 (
130 )
131 :
132  Matrix<RectangularMatrix<Type>, Type>(mat)
133 {}
134 
135 
136 template<class Type>
137 template<class MatrixType>
139 (
140  const MatrixBlock<MatrixType>& mat
141 )
142 :
143  Matrix<RectangularMatrix<Type>, Type>(mat)
144 {}
145 
146 
147 template<class Type>
149 (
150  const SquareMatrix<Type>& mat
151 )
152 :
153  Matrix<RectangularMatrix<Type>, Type>(mat)
154 {}
155 
156 
157 template<class Type>
159 :
160  Matrix<RectangularMatrix<Type>, Type>(is)
161 {}
162 
163 
164 template<class Type>
167 {
169 }
170 
171 
172 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
173 
174 template<class Type>
176 (
178 )
179 {
180  this->transfer(mat);
181 }
182 
183 
184 template<class Type>
186 {
187  Matrix<RectangularMatrix<Type>, Type>::operator=(Foam::zero{});
188 }
189 
190 
191 template<class Type>
192 inline void Foam::RectangularMatrix<Type>::operator=(const Type& val)
193 {
194  Matrix<RectangularMatrix<Type>, Type>::operator=(val);
195 }
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 namespace Foam
201 {
202 
203 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
204 
205 template<class Type>
207 {
208 public:
209 
211 };
213 
214 template<class Type>
215 class typeOfInnerProduct<Type, RectangularMatrix<Type>, SquareMatrix<Type>>
216 {
217 public:
218 
220 };
222 
223 template<class Type>
224 class typeOfInnerProduct<Type, SquareMatrix<Type>, RectangularMatrix<Type>>
225 {
226 public:
227 
229 };
231 
232 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
233 
234 // Return the outer product of Field-Field as RectangularMatrix
235 template<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 // ************************************************************************* //
const T & first() const noexcept
Access the first element.
Definition: Pair.H:137
Abstract template class to provide the form resulting from the inner-product of two forms...
Definition: products.H:47
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
RectangularMatrix & operator=(const RectangularMatrix &)=default
Copy assignment.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
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.
A templated block of an (m x n) matrix of type <MatrixType>.
Definition: Matrix.H:62
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
Generic templated field type.
Definition: Field.H:62
RectangularMatrix()=default
Default construct.
A templated (M x N) rectangular matrix of objects of <Type>, containing M*N elements, derived from Matrix.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order: ...
autoPtr< RectangularMatrix< Type > > clone() const
Clone.
Pair< label > labelPair
A pair of labels.
Definition: Pair.H:51
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
label n
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:43
const T & second() const noexcept
Access the second element.
Definition: Pair.H:147
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix...
Definition: SquareMatrix.H:59
Namespace for OpenFOAM.