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