OpenFOAM logo
Open Source CFD Toolkit

GaussSeidel.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-2005 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     GaussSeidel
00027 
00028 Description
00029 
00030 SourceFiles
00031     GaussSeidel.C
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef GaussSeidel_H
00036 #define GaussSeidel_H
00037 
00038 #include "lduMatrix.H"
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044 
00045 /*---------------------------------------------------------------------------*\
00046                            Class GaussSeidel Declaration
00047 \*---------------------------------------------------------------------------*/
00048 
00049 class GaussSeidel
00050 :
00051     public lduMatrix::solver
00052 {
00053 private:
00054 
00055     // Static data
00056 
00057         //- Maximum number of iterations in the solver
00058         static label maxIter_;
00059 
00060 
00061     // Private Member Functions
00062 
00063         //- Disallow default bitwise copy construct
00064         GaussSeidel(const GaussSeidel&);
00065 
00066         //- Disallow default bitwise assignment
00067         void operator=(const GaussSeidel&);
00068 
00069 
00070 protected:
00071 
00072     // Protected data
00073 
00074         scalar tolerance_;
00075         scalar relTol_;
00076 
00077         //- Number of sweeps before the evaluation of residual
00078         label nSweeps_;
00079 
00080 
00081 public:
00082 
00083     //- Runtime type information
00084     TypeName("GaussSeidel");
00085 
00086 
00087     // Constructors
00088 
00089         //- Construct from components
00090         GaussSeidel
00091         (
00092             const word& fieldName,
00093             scalarField& psi,
00094             const lduMatrix& matrix,
00095             const scalarField& source,
00096             const FieldField<Field, scalar>& coupleBouCoeffs,
00097             const FieldField<Field, scalar>& coupleIntCoeffs,
00098             const lduCoupledInterfacePtrsList& interfaces,
00099             const direction cmpt,
00100             const label nSweeps,
00101             const scalar tolerance,
00102             const scalar relTol = 0.0
00103         );
00104 
00105         //- Construct from matrix components and solver data stream
00106         GaussSeidel
00107         (
00108             const word& fieldName,
00109             scalarField& psi,
00110             const lduMatrix& matrix,
00111             const scalarField& source,
00112             const FieldField<Field, scalar>& coupleBouCoeffs,
00113             const FieldField<Field, scalar>& coupleIntCoeffs,
00114             const lduCoupledInterfacePtrsList& interfaces,
00115             const direction cmpt,
00116             Istream& solverData
00117         );
00118 
00119 
00120     // Member Functions
00121 
00122         //- Smooth for the given number of sweeps
00123         static void smooth
00124         (
00125             const word& fieldName,
00126             scalarField& psi,
00127             const lduMatrix& matrix,
00128             const scalarField& Source,
00129             const FieldField<Field, scalar>& bouCoeffs,
00130             const lduCoupledInterfacePtrsList& interfaces,
00131             const direction cmpt,
00132             const label nSweeps
00133         );
00134 
00135 
00136         //- Solve the matrix with this solver
00137         lduMatrix::solverPerformance solve();
00138 
00139         //- Set maximum number of iterations
00140         static label setMaxIter(const label mIter)
00141         {
00142             label oldMaxIter = maxIter_;
00143             maxIter_ = mIter;
00144 
00145             return oldMaxIter;
00146         }
00147 };
00148 
00149 
00150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00151 
00152 } // End namespace Foam
00153 
00154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00155 
00156 #endif
00157 
00158 // ************************************************************************* //
For further information go to www.openfoam.org