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-2018 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 from and perform LU decomposition of the matrix M
104 
105  //- Construct from lduMatrix and perform LU decomposition
107  (
108  const lduMatrix&,
109  const FieldField<Field, scalar>& interfaceCoeffs,
110  const lduInterfaceFieldPtrsList& interfaces
111  );
112 
113 
114  // Member Functions
115 
116  //- Perform the LU decomposition of the matrix M
117  void decompose(const scalarSquareMatrix& M);
118 
119  //- Solve the linear system with the given source
120  // and returning the solution in the Field argument x.
121  // This function may be called with the same field for x and source.
122  template<class Type>
123  void solve(Field<Type>& x, const Field<Type>& source) const;
124 
125  //- Solve the linear system with the given source
126  // returning the solution
127  template<class Type>
128  tmp<Field<Type>> solve(const Field<Type>& source) const;
129 
130  //- Set M to the inverse of this square matrix
131  void inv(scalarSquareMatrix& M) const;
132 };
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace Foam
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #ifdef NoRepository
142  #include "LUscalarMatrixTemplates.C"
143 #endif
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #endif
148 
149 // ************************************************************************* //
void solve(Field< Type > &x, const Field< Type > &source) const
Solve the linear system with the given source.
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
Class to perform the LU decomposition on a symmetric matrix.
Generic field type.
Definition: FieldField.H:51
void decompose(const scalarSquareMatrix &M)
Perform the LU decomposition of the matrix M.
Pre-declare SubField and related Field type.
Definition: Field.H:57
LUscalarMatrix()
Construct null.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: lduMatrix.H:79
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:63
ClassName("LUscalarMatrix")
A class for managing temporary objects.
Definition: PtrList.H:53
#define M(I)
Namespace for OpenFOAM.
void inv(scalarSquareMatrix &M) const
Set M to the inverse of this square matrix.