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-------------------------------------------------------------------------------
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#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
40template<class Type>
42:
43 Matrix<SymmetricSquareMatrix<Type>, Type>(n, n)
44{}
45
46
47template<class Type>
49(
50 const label n,
51 const Foam::zero
52)
53:
54 Matrix<SymmetricSquareMatrix<Type>, Type>(n, n, Zero)
55{}
56
57
58template<class Type>
60(
61 const label n,
62 const Type& val
63)
64:
65 Matrix<SymmetricSquareMatrix<Type>, Type>(n, n, val)
66{}
67
68
69template<class Type>
70template<class AnyType>
72(
73 const label n,
75)
76:
77 Matrix<SymmetricSquareMatrix<Type>, Type>(n, n, Zero)
78{
79 for (label i=0; i < n; ++i)
80 {
81 this->operator()(i, i) = pTraits<Type>::one;
82 }
83}
84
85
86template<class Type>
88:
89 Matrix<SymmetricSquareMatrix<Type>, Type>(is)
90{
91 CHECK_MATRIX_IS_SQUARE(this->m(), this->n());
92}
93
94
95template<class Type>
98{
100}
101
102
103// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
104
105template<class Type>
107{
108 Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(Zero);
109}
110
111
112template<class Type>
114{
115 Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(val);
116}
117
118
119// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120
121#undef CHECK_MATRIX_IS_SQUARE
122
123// ************************************************************************* //
#define CHECK_MATRIX_IS_SQUARE(a, b)
Definition: SquareMatrixI.H:29
label n
Templated identity and dual space identity tensors derived from SphericalTensor.
Definition: Identity.H:52
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
Definition: Matrix.H:81
label n() const noexcept
The number of columns.
Definition: MatrixI.H:103
const Type & operator()(const label irow, const label jcol) const
(i, j) const element access operator
Definition: MatrixI.H:585
label m() const noexcept
The number of rows.
Definition: MatrixI.H:96
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix.
SymmetricSquareMatrix()=default
Default construct.
autoPtr< SymmetricSquareMatrix< Type > > clone() const
Clone.
SymmetricSquareMatrix & operator=(const SymmetricSquareMatrix &)=default
Copy assignment.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
Definition: one.H:62
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.