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 -------------------------------------------------------------------------------
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 Class
28  Foam::DiagonalMatrix
29 
30 Description
31  A templated (N x N) diagonal matrix of objects of <Type>, effectively
32  containing N elements, derived from List.
33 
34 See also
35  Test-DiagonalMatrix.C
36 
37 SourceFiles
38  DiagonalMatrix.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef Foam_DiagonalMatrix_H
43 #define Foam_DiagonalMatrix_H
44 
45 #include "List.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 template<class Form, class Type> class Matrix;
54 
55 /*---------------------------------------------------------------------------*\
56  Class DiagonalMatrix Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 template<class Type>
60 class DiagonalMatrix
61 :
62  public List<Type>
63 {
64 public:
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;
76 
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
84  DiagonalMatrix(const label n, Foam::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 };
108 
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 } // End namespace Foam
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 #ifdef NoRepository
117  #include "DiagonalMatrix.C"
118 #endif
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 #endif
123 
124 // ************************************************************************* //
DiagonalMatrix()=default
Default construct.
labelList sortPermutation(const CompOp &compare) const
Return a sort permutation labelList according to a given comparison on the diagonal entries...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
DiagonalMatrix & operator=(const DiagonalMatrix &)=default
Copy assignment.
A templated (N x N) diagonal matrix of objects of <Type>, effectively containing N elements...
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order: ...
void invert()
Return the matrix inverse into itself.
void applyPermutation(const labelUList &p)
Column-reorder this Matrix according to a given permutation labelList.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
label n
volScalarField & p
Namespace for OpenFOAM.