diagonalPreconditioner.C
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-2015 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 \*---------------------------------------------------------------------------*/
27 
28 #include "diagonalPreconditioner.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(diagonalPreconditioner, 0);
35 
36  lduMatrix::preconditioner::
37  addsymMatrixConstructorToTable<diagonalPreconditioner>
39 
40  lduMatrix::preconditioner::
41  addasymMatrixConstructorToTable<diagonalPreconditioner>
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
48 Foam::diagonalPreconditioner::diagonalPreconditioner
49 (
50  const lduMatrix::solver& sol,
51  const dictionary&
52 )
53 :
55  rD(sol.matrix().diag().size())
56 {
57  solveScalar* __restrict__ rDPtr = rD.begin();
58  const scalar* __restrict__ DPtr = solver_.matrix().diag().begin();
59 
60  const label nCells = rD.size();
61 
62  // Generate reciprocal diagonal
63  for (label cell=0; cell<nCells; cell++)
64  {
65  rDPtr[cell] = 1.0/DPtr[cell];
66  }
67 }
68 
69 
70 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 
73 (
74  solveScalarField& wA,
75  const solveScalarField& rA,
76  const direction
77 ) const
78 {
79  solveScalar* __restrict__ wAPtr = wA.begin();
80  const solveScalar* __restrict__ rAPtr = rA.begin();
81  const solveScalar* __restrict__ rDPtr = rD.begin();
82 
83  const label nCells = wA.size();
84 
85  for (label cell=0; cell<nCells; cell++)
86  {
87  wAPtr[cell] = rDPtr[cell]*rAPtr[cell];
88  }
89 }
90 
91 
92 // ************************************************************************* //
Foam::diagonalPreconditioner::precondition
virtual void precondition(solveScalarField &wA, const solveScalarField &rA, const direction cmpt=0) const
Return wA the preconditioned form of residual rA.
Definition: diagonalPreconditioner.C:73
Foam::lduMatrix::solver
Abstract base-class for lduMatrix solvers.
Definition: lduMatrix.H:98
Foam::adddiagonalPreconditionerSymMatrixConstructorToTable_
lduMatrix::preconditioner::addsymMatrixConstructorToTable< diagonalPreconditioner > adddiagonalPreconditionerSymMatrixConstructorToTable_
Definition: diagonalPreconditioner.C:38
Foam::Field< solveScalar >
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::adddiagonalPreconditionerAsymMatrixConstructorToTable_
lduMatrix::preconditioner::addasymMatrixConstructorToTable< diagonalPreconditioner > adddiagonalPreconditionerAsymMatrixConstructorToTable_
Definition: diagonalPreconditioner.C:42
Foam::lduMatrix::diag
scalarField & diag()
Definition: lduMatrix.C:192
diagonalPreconditioner.H
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::lduMatrix::preconditioner
Abstract base-class for lduMatrix preconditioners.
Definition: lduMatrix.H:433
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:54
Foam::lduMatrix::solver::matrix
const lduMatrix & matrix() const noexcept
Definition: lduMatrix.H:233