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-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
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 DiagonalMatrix_H
43#define DiagonalMatrix_H
44
45#include "List.H"
46#include <numeric>
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53// Forward Declarations
54template<class Form, class Type> class Matrix;
55
56/*---------------------------------------------------------------------------*\
57 Class DiagonalMatrix Declaration
58\*---------------------------------------------------------------------------*/
59
60template<class Type>
62:
63 public List<Type>
64{
65public:
66
67 // Generated Methods
68
69 //- Default construct
70 DiagonalMatrix() = default;
71
72 //- Copy construct
73 DiagonalMatrix(const DiagonalMatrix&) = default;
74
75 //- Copy assignment
76 DiagonalMatrix& operator=(const DiagonalMatrix&) = default;
77
78
79 // Constructors
80
81 //- Construct empty from size
82 explicit DiagonalMatrix<Type>(const label n);
83
84 //- Construct from size and initialise all elems to zero
85 DiagonalMatrix<Type>(const label n, const Foam::zero);
86
87 //- Construct from size and initialise all elems to value
88 DiagonalMatrix<Type>(const label n, const Type& val);
89
90 //- Construct from the diagonal of a Matrix
91 template<class Form>
93
94
95 // Member Functions
96
97 //- Return the matrix inverse into itself if no elem is equal to zero
98 void invert();
99
100 //- Return a sort permutation labelList according to
101 //- a given comparison on the diagonal entries
102 template<class CompOp>
103 List<label> sortPermutation(CompOp& compare) const;
104
105 //- Column-reorder this Matrix according to
106 //- a given permutation labelList
107 void applyPermutation(const List<label>& p);
108};
109
110
111// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112
113} // End namespace Foam
114
115// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116
117#ifdef NoRepository
118 #include "DiagonalMatrix.C"
119#endif
120
121// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122
123#endif
124
125// ************************************************************************* //
label n
A templated (N x N) diagonal matrix of objects of <Type>, effectively containing N elements,...
List< label > sortPermutation(CompOp &compare) const
DiagonalMatrix(const DiagonalMatrix &)=default
Copy construct.
DiagonalMatrix()=default
Default construct.
void applyPermutation(const List< label > &p)
void invert()
Return the matrix inverse into itself if no elem is equal to zero.
DiagonalMatrix & operator=(const DiagonalMatrix &)=default
Copy assignment.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:
Definition: Matrix.H:81
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
volScalarField & p
Namespace for OpenFOAM.