LUscalarMatrix.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::LUscalarMatrix
26 
27 Description
28  Class to perform the LU decomposition on a symmetric matrix.
29 
30 SourceFiles
31  LUscalarMatrix.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef LUscalarMatrix_H
36 #define LUscalarMatrix_H
37 
38 #include "scalarMatrices.H"
39 #include "labelList.H"
40 #include "FieldField.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 class lduMatrix;
49 class procLduMatrix;
50 
51 /*---------------------------------------------------------------------------*\
52  Class LUscalarMatrix Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class LUscalarMatrix
56 :
57  public scalarSquareMatrix
58 {
59  // Private Data
60 
61  //- Communicator to use
62  const label comm_;
63 
64  //- Processor matrix offsets
65  labelList procOffsets_;
66 
67  //- The pivot indices used in the LU decomposition
68  labelList pivotIndices_;
69 
70 
71  // Private Member Functions
72 
73  //- Convert the given lduMatrix into this LUscalarMatrix
74  void convert
75  (
76  const lduMatrix& ldum,
77  const FieldField<Field, scalar>& interfaceCoeffs,
78  const lduInterfaceFieldPtrsList& interfaces
79  );
80 
81  //- Convert the given list of procLduMatrix into this LUscalarMatrix
82  // on the master processor
83  void convert(const PtrList<procLduMatrix>& lduMatrices);
84 
85 
86  //- Print the ratio of the mag-sum of the off-diagonal coefficients
87  // to the mag-diagonal
88  void printDiagonalDominance() const;
89 
90 
91 public:
92 
93  // Declare name of the class and its debug switch
94  ClassName("LUscalarMatrix");
95 
96 
97  // Constructors
98 
99  //- Construct null
100  LUscalarMatrix();
101 
102  //- Construct given number of rows/columns
103  LUscalarMatrix(const label n);
104 
105  //- Construct from and perform LU decomposition of the matrix M
107 
108  //- Construct from lduMatrix and perform LU decomposition
110  (
111  const lduMatrix&,
112  const FieldField<Field, scalar>& interfaceCoeffs,
113  const lduInterfaceFieldPtrsList& interfaces
114  );
115 
116 
117  // Member Functions
118 
119  //- Perform the LU decomposition of the matrix
120  void decompose();
121 
122  //- Perform the LU decomposition of the matrix M
123  void decompose(const scalarSquareMatrix& M);
124 
125  //- Solve the linear system with the given source
126  // and returning the solution in the Field argument x.
127  // This function may be called with the same field for x and source.
128  template<class Type>
129  void solve(Field<Type>& x, const Field<Type>& source) const;
130 
131  //- Solve the linear system with the given source
132  // returning the solution
133  template<class Type>
134  tmp<Field<Type>> solve(const Field<Type>& source) const;
135 
136  //- Set M to the inverse of this square matrix
137  void inv(scalarSquareMatrix& M) const;
138 };
139 
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 } // End namespace Foam
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #ifdef NoRepository
148  #include "LUscalarMatrixTemplates.C"
149 #endif
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 #endif
154 
155 // ************************************************************************* //
#define M(I)
Generic field type.
Definition: FieldField.H:77
Pre-declare SubField and related Field type.
Definition: Field.H:82
Class to perform the LU decomposition on a symmetric matrix.
LUscalarMatrix()
Construct null.
void inv(scalarSquareMatrix &M) const
Set M to the inverse of this square matrix.
void decompose()
Perform the LU decomposition of the matrix.
ClassName("LUscalarMatrix")
void solve(Field< Type > &x, const Field< Type > &source) const
Solve the linear system with the given source.
label n() const
Return the number of columns.
Definition: MatrixI.H:64
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: lduMatrix.H:80
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.
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:59