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 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  Matrix<RectangularMatrix<Type>, Type>()
35 {}
36 
37 
38 template<class Type>
40 (
41  const label m,
42  const label n
43 )
44 :
46 {}
47 
48 
49 template<class Type>
51 (
52  const label n
53 )
54 :
56 {}
57 
58 
59 template<class Type>
61 (
62  const label m,
63  const label n,
64  const zero
65 )
66 :
68 {}
69 
70 
71 template<class Type>
73 (
74  const label m,
75  const label n,
76  const Type& val
77 )
78 :
80 {}
81 
82 
83 template<class Type>
84 template<class AnyType>
86 (
87  const labelPair& dims,
88  const Identity<AnyType>
89 )
90 :
91  Matrix<RectangularMatrix<Type>, Type>(dims.first(), dims.second(), Zero)
92 {
93  for (label i = 0; i < min(dims.first(), dims.second()); ++i)
94  {
95  this->operator()(i, i) = pTraits<Type>::one;
96  }
97 }
98 
99 
100 template<class Type>
102 (
103  const labelPair& dims
104 )
105 :
106  RectangularMatrix<Type>(dims.first(), dims.second())
107 {}
108 
109 
110 template<class Type>
112 (
113  const labelPair& dims,
114  const zero
115 )
116 :
117  RectangularMatrix<Type>(dims.first(), dims.second(), Zero)
118 {}
119 
120 
121 template<class Type>
123 (
124  const labelPair& dims,
125  const Type& val
126 )
127 :
128  RectangularMatrix<Type>(dims.first(), dims.second(), val)
129 {}
130 
131 
132 template<class Type>
133 template<class MatrixType>
135 (
137 )
138 :
140 {}
141 
142 
143 template<class Type>
144 template<class MatrixType>
146 (
147  const MatrixBlock<MatrixType>& mat
148 )
149 :
151 {}
152 
153 
154 template<class Type>
156 (
157  const SquareMatrix<Type>& mat
158 )
159 :
161 {}
162 
163 
164 template<class Type>
166 :
167  Matrix<RectangularMatrix<Type>, Type>(is)
168 {}
169 
170 
171 template<class Type>
174 {
176 }
177 
178 
179 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
180 
181 template<class Type>
183 {
184  Matrix<RectangularMatrix<Type>, Type>::operator=(Zero);
185 }
186 
187 
188 template<class Type>
190 {
191  Matrix<RectangularMatrix<Type>, Type>::operator=(val);
192 }
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 namespace Foam
198 {
199 
200 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
201 
202 template<class Type>
204 (
205  const Field<Type>& f1,
206  const Field<Type>& f2
207 )
208 {
209  RectangularMatrix<Type> f1f2T(f1.size(), f2.size());
210 
211  for (label i = 0; i < f1f2T.m(); ++i)
212  {
213  for (label j = 0; j < f1f2T.n(); ++j)
214  {
215  f1f2T(i, j) = f1[i]*f2[j];
216  }
217  }
218 
219  return f1f2T;
220 }
221 
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 } // End namespace Foam
226 
227 
228 // ************************************************************************* //
Foam::Pair::second
const T & second() const noexcept
Return second element, which is also the last element.
Definition: PairI.H:122
Foam::val
label ListType::const_reference val
Definition: ListOps.H:407
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::Matrix
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
Definition: DiagonalMatrix.H:48
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::label
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:62
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::Identity
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:49
Foam::MatrixBlock
A templated block of an (m x n) matrix of type <MatrixType>.
Definition: Matrix.H:66
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::RectangularMatrix
A templated 2D rectangular m x n matrix of objects of <Type>.
Definition: RectangularMatrix.H:56
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::SquareMatrix
A templated 2D square matrix of objects of <T>, where the n x n matrix dimension is known and used fo...
Definition: SquareMatrix.H:59
Foam::Pair
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: Pair.H:54
Foam::RectangularMatrix::operator=
void operator=(const zero)
Assign all elements to zero.
Definition: RectangularMatrixI.H:182
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:52
Foam::outer
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:942
Foam::RectangularMatrix::clone
autoPtr< RectangularMatrix< Type > > clone() const
Clone.
Definition: RectangularMatrixI.H:173
Foam::ConstMatrixBlock
Definition: Matrix.H:65
Foam::RectangularMatrix::RectangularMatrix
RectangularMatrix()
Construct null.
Definition: RectangularMatrixI.H:32
Foam::zero
A class representing the concept of 0 (zero), which can be used to avoid manipulating objects that ar...
Definition: zero.H:61