Loading...
Searching...
No Matches
DiagonalMatrix.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-2025 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
27Class
28 Foam::DiagonalMatrix
29
30Description
31 A templated (N x N) diagonal matrix of objects of <Type>, effectively
32 containing N elements, derived from List.
33
34See also
35 Test-DiagonalMatrix.C
36
37SourceFiles
38 DiagonalMatrix.C
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef Foam_DiagonalMatrix_H
43#define Foam_DiagonalMatrix_H
44
45#include "List.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52// Forward Declarations
53template<class Form, class Type> class Matrix;
54
55/*---------------------------------------------------------------------------*\
56 Class DiagonalMatrix Declaration
57\*---------------------------------------------------------------------------*/
58
59template<class Type>
61:
62 public List<Type>
63{
64public:
65
66 // Generated Methods
67
68 //- Default construct
69 DiagonalMatrix() = default;
70
71 //- Copy construct
72 DiagonalMatrix(const DiagonalMatrix&) = default;
73
74 //- Copy assignment
75 DiagonalMatrix& operator=(const DiagonalMatrix&) = default;
77
78 // Constructors
79
80 //- Construct from size, uninitialised content
81 explicit DiagonalMatrix(const label n);
82
83 //- Construct from size and initialise all elems to zero
85
86 //- Construct from size and initialise all elems to value
87 DiagonalMatrix(const label n, const Type& val);
88
89 //- Construct from the diagonal of a Matrix
90 template<class Form>
92
93
94 // Member Functions
95
96 //- Return the matrix inverse into itself
97 void invert();
98
99 //- Return a sort permutation labelList according to
100 //- a given comparison on the diagonal entries
101 template<class CompOp>
102 labelList sortPermutation(const CompOp& compare) const;
103
104 //- Column-reorder this Matrix according to
105 //- a given permutation labelList
106 void applyPermutation(const labelUList& p);
107};
109
110// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111
112} // End namespace Foam
113
114// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116#ifdef NoRepository
117 #include "DiagonalMatrix.C"
118#endif
119
120// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122#endif
123
124// ************************************************************************* //
label n
DiagonalMatrix(const Matrix< Form, Type > &mat)
Construct from the diagonal of a Matrix.
labelList sortPermutation(const CompOp &compare) const
Return a sort permutation labelList according to a given comparison on the diagonal entries.
DiagonalMatrix(const DiagonalMatrix &)=default
Copy construct.
DiagonalMatrix()=default
Default construct.
DiagonalMatrix(const label n, Foam::zero)
Construct from size and initialise all elems to zero.
void invert()
Return the matrix inverse into itself.
DiagonalMatrix(const label n)
Construct from size, uninitialised content.
DiagonalMatrix & operator=(const DiagonalMatrix &)=default
Copy assignment.
void applyPermutation(const labelUList &p)
Column-reorder this Matrix according to a given permutation labelList.
DiagonalMatrix(const label n, const Type &val)
Construct from size and initialise all elems to value.
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
Definition Matrix.H:77
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
volScalarField & p
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
UList< label > labelUList
A UList of labels.
Definition UList.H:75