SymmetricSquareMatrixI.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-2020 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 #define CHECK_MATRIX_IS_SQUARE(a, b) \
30  if (a != b) \
31  { \
32  FatalErrorInFunction \
33  << "Attempt to create a non-square matrix (" \
34  << a << ", " << b << ')' << nl << abort(FatalError); \
35  }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
40 template<class Type>
42 :
43  Matrix<SymmetricSquareMatrix<Type>, Type>(n, n)
44 {}
45 
46 
47 template<class Type>
49 (
50  const label n,
51  const Foam::zero
52 )
53 :
55 {}
56 
57 
58 template<class Type>
60 (
61  const label n,
62  const Type& val
63 )
64 :
66 {}
67 
68 
69 template<class Type>
70 template<class AnyType>
72 (
73  const label n,
74  const Identity<AnyType>
75 )
76 :
78 {
79  for (label i=0; i < n; ++i)
80  {
81  this->operator()(i, i) = pTraits<Type>::one;
82  }
83 }
84 
85 
86 template<class Type>
88 :
89  Matrix<SymmetricSquareMatrix<Type>, Type>(is)
90 {
91  CHECK_MATRIX_IS_SQUARE(this->m(), this->n());
92 }
93 
94 
95 template<class Type>
98 {
100 }
101 
102 
103 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
104 
105 template<class Type>
107 {
108  Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(Zero);
109 }
110 
111 
112 template<class Type>
114 {
115  Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(val);
116 }
117 
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 #undef CHECK_MATRIX_IS_SQUARE
122 
123 // ************************************************************************* //
Foam::SymmetricSquareMatrix::operator=
SymmetricSquareMatrix & operator=(const SymmetricSquareMatrix &)=default
Copy assignment.
Foam::Matrix< SymmetricSquareMatrix< Type >, Type >::n
label n() const noexcept
The number of columns.
Definition: MatrixI.H:103
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::Matrix
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
Definition: DiagonalMatrix.H:53
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::Identity
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:49
CHECK_MATRIX_IS_SQUARE
#define CHECK_MATRIX_IS_SQUARE(a, b)
Definition: SymmetricSquareMatrixI.H:29
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::SymmetricSquareMatrix::SymmetricSquareMatrix
SymmetricSquareMatrix()=default
Default construct.
Foam::SymmetricSquareMatrix
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix.
Definition: SymmetricSquareMatrix.H:57
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::Matrix< SymmetricSquareMatrix< Type >, Type >::m
label m() const noexcept
The number of rows.
Definition: MatrixI.H:96
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::SymmetricSquareMatrix::clone
autoPtr< SymmetricSquareMatrix< Type > > clone() const
Clone.
Definition: SymmetricSquareMatrixI.H:97
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62