LLTMatrix.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) 2016-2020 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::LLTMatrix
26 
27 Description
28  Templated class to perform the Cholesky decomposition on a
29  symmetric positive-definite matrix.
30 
31  Member functions are provided to solve linear systems using the LLT
32  decomposition.
33 
34 SourceFiles
35  LLTMatrix.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef LLTMatrix_H
40 #define LLTMatrix_H
41 
42 #include "SquareMatrix.H"
43 #include "Field.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class LLTMatrix Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 template<class Type>
55 class LLTMatrix
56 :
57  public SquareMatrix<Type>
58 {
59 
60 public:
61 
62  // Constructors
63 
64  //- Construct null
65  LLTMatrix();
66 
67  //- Construct from a square matrix and perform the decomposition
69 
70 
71  // Member Functions
72 
73  //- Perform the Cholesky decomposition of the matrix
74  void decompose(const SquareMatrix<Type>& M);
75 
76  //- Solve the linear system with the given source
77  // and returning the solution in the Field argument x.
78  // This function may be called with the same field for x and source.
79  void solve(Field<Type>& x, const Field<Type>& source) const;
80 
81  //- Solve the linear system with the given source
82  // returning the solution
83  tmp<Field<Type>> solve(const Field<Type>& source) const;
84 };
85 
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 } // End namespace Foam
90 
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93 #ifdef NoRepository
94  #include "LLTMatrix.C"
95 #endif
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 #endif
100 
101 // ************************************************************************* //
Pre-declare SubField and related Field type.
Definition: Field.H:56
void solve(Field< Type > &x, const Field< Type > &source) const
Solve the linear system with the given source.
Definition: LLTMatrix.C:93
LLTMatrix()
Construct null.
Definition: LLTMatrix.C:31
A class for managing temporary objects.
Definition: PtrList.H:53
void decompose(const SquareMatrix< Type > &M)
Perform the Cholesky decomposition of the matrix.
Definition: LLTMatrix.C:45
Templated class to perform the Cholesky decomposition on a symmetric positive-definite matrix...
Definition: LLTMatrix.H:54
#define M(I)
A templated 2D square matrix of objects of <T>, where the n x n matrix dimension is known and used fo...
Definition: SquareMatrix.H:58
Namespace for OpenFOAM.