OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

diagonalPreconditioner.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2007 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     diagonalPreconditioner
00027 
00028 Description
00029     Diagonal preconditioner for both symmetric and asymmetric matrices.
00030     The reciprocal of the diagonal is calculated and stored for reuse because on
00031     most systems * is faster than /.
00032 
00033 SourceFiles
00034     diagonalPreconditioner.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef diagonalPreconditioner_H
00039 #define diagonalPreconditioner_H
00040 
00041 #include "lduMatrix.H"
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 namespace Foam
00046 {
00047 
00048 /*---------------------------------------------------------------------------*\
00049                            Class diagonalPreconditioner Declaration
00050 \*---------------------------------------------------------------------------*/
00051 
00052 class diagonalPreconditioner
00053 :
00054     public lduMatrix::preconditioner
00055 {
00056     // Private data
00057 
00058         //- The reciprocal diagonal 
00059         scalarField rD;
00060 
00061 
00062     // Private Member Functions
00063 
00064         //- Disallow default bitwise copy construct
00065         diagonalPreconditioner(const diagonalPreconditioner&);
00066 
00067         //- Disallow default bitwise assignment
00068         void operator=(const diagonalPreconditioner&);
00069 
00070 
00071 public:
00072 
00073     //- Runtime type information
00074     TypeName("diagonal");
00075 
00076 
00077     // Constructors
00078 
00079         //- Construct from matrix components and preconditioner data stream
00080         diagonalPreconditioner
00081         (
00082             const lduMatrix::solver& sol,
00083             Istream& preconditionerData
00084         );
00085 
00086 
00087     // Destructor
00088 
00089         virtual ~diagonalPreconditioner()
00090         {}
00091 
00092 
00093     // Member Functions
00094 
00095         //- Read and reset the preconditioner parameters from the given stream
00096         virtual void read(Istream& preconditionerData);
00097 
00098         //- Return wA the preconditioned form of residual rA
00099         virtual void precondition
00100         (
00101             scalarField& wA,
00102             const scalarField& rA,
00103             const direction cmpt=0
00104         ) const;
00105 
00106         //- Return wT the transpose-matrix preconditioned form of
00107         //  residual rT.
00108         virtual void preconditionT
00109         (
00110             scalarField& wT,
00111             const scalarField& rT,
00112             const direction cmpt=0
00113         ) const
00114         {
00115             return(precondition(wT, rT, cmpt));
00116         }
00117 };
00118 
00119 
00120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00121 
00122 } // End namespace Foam
00123 
00124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00125 
00126 #endif
00127 
00128 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd