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 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>()
44 {}
45 
46 
47 template<class Type>
49 :
50  Matrix<SymmetricSquareMatrix<Type>, Type>(n, n)
51 {}
52 
53 
54 template<class Type>
56 (
57  const label n,
58  const zero
59 )
60 :
62 {}
63 
64 
65 template<class Type>
67 (
68  const label n,
69  const Type& val
70 )
71 :
73 {}
74 
75 
76 template<class Type>
77 template<class AnyType>
79 (
80  const label n,
81  const Identity<AnyType>
82 )
83 :
85 {
86  for (label i=0; i < n; ++i)
87  {
88  this->operator()(i, i) = pTraits<Type>::one;
89  }
90 }
91 
92 
93 template<class Type>
95 :
96  Matrix<SymmetricSquareMatrix<Type>, Type>(is)
97 {
98  CHECK_MATRIX_IS_SQUARE(this->m(), this->n());
99 }
100 
101 
102 template<class Type>
105 {
107 }
108 
109 
110 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
111 
112 template<class Type>
114 {
115  Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(Zero);
116 }
117 
118 
119 template<class Type>
121 {
122  Matrix<SymmetricSquareMatrix<Type>, Type>::operator=(val);
123 }
124 
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 #undef CHECK_MATRIX_IS_SQUARE
129 
130 // ************************************************************************* //
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::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::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::operator=
void operator=(const zero)
Assign all elements to zero.
Definition: SymmetricSquareMatrixI.H:113
Foam::Matrix< SymmetricSquareMatrix< Type >, Type >::n
label n() const noexcept
The number of columns.
Foam::SymmetricSquareMatrix
A templated 2D square symmetric matrix of objects of <T>, where the n x n matrix dimension is known a...
Definition: SymmetricSquareMatrix.H:54
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:95
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:52
Foam::SymmetricSquareMatrix::SymmetricSquareMatrix
SymmetricSquareMatrix()
Construct null.
Definition: SymmetricSquareMatrixI.H:41
Foam::SymmetricSquareMatrix::clone
autoPtr< SymmetricSquareMatrix< Type > > clone() const
Clone.
Definition: SymmetricSquareMatrixI.H:104
Foam::zero
A class representing the concept of 0 (zero), which can be used to avoid manipulating objects that ar...
Definition: zero.H:61