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,
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  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 
95 template<class Type>
97 (
98  const labelPair& dims
99 )
100 :
101  RectangularMatrix<Type>(dims.first(), dims.second())
102 {}
103 
104 
105 template<class Type>
107 (
108  const labelPair& dims,
109  Foam::zero
110 )
111 :
112  RectangularMatrix<Type>(dims.first(), dims.second(), Foam::zero{})
113 {}
114 
115 
116 template<class Type>
118 (
119  const labelPair& dims,
120  const Type& val
121 )
122 :
123  RectangularMatrix<Type>(dims.first(), dims.second(), val)
124 {}
125 
126 
127 template<class Type>
128 template<class MatrixType>
130 (
132 )
133 :
134  Matrix<RectangularMatrix<Type>, Type>(mat)
135 {}
136 
137 
138 template<class Type>
139 template<class MatrixType>
141 (
142  const MatrixBlock<MatrixType>& mat
143 )
144 :
145  Matrix<RectangularMatrix<Type>, Type>(mat)
146 {}
147 
148 
149 template<class Type>
151 (
152  const SquareMatrix<Type>& mat
153 )
154 :
155  Matrix<RectangularMatrix<Type>, Type>(mat)
156 {}
157 
158 
159 template<class Type>
161 :
162  Matrix<RectangularMatrix<Type>, Type>(is)
163 {}
164 
165 
166 template<class Type>
169 {
171 }
172 
173 
174 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
175 
176 template<class Type>
178 (
180 )
181 {
182  this->transfer(mat);
183 }
184 
185 
186 template<class Type>
188 {
189  Matrix<RectangularMatrix<Type>, Type>::operator=(Foam::zero{});
190 }
191 
192 
193 template<class Type>
194 inline void Foam::RectangularMatrix<Type>::operator=(const Type& val)
195 {
196  Matrix<RectangularMatrix<Type>, Type>::operator=(val);
197 }
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 namespace Foam
203 {
204 
205 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
206 
207 template<class Type>
209 {
210 public:
211 
213 };
215 
216 template<class Type>
217 class typeOfInnerProduct<Type, RectangularMatrix<Type>, SquareMatrix<Type>>
218 {
219 public:
220 
222 };
224 
225 template<class Type>
226 class typeOfInnerProduct<Type, SquareMatrix<Type>, RectangularMatrix<Type>>
227 {
228 public:
229 
231 };
233 
234 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
235 
236 // Return the outer product of Field-Field as RectangularMatrix
237 template<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 // ************************************************************************* //
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:114
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:61
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:801
Generic templated field type.
Definition: Field.H:63
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:57
Namespace for OpenFOAM.