computation/solver/preconditioner/IlutPreconditioning.hxx

00001 // Copyright (C) 2010 Marc Duruflé
00002 //
00003 // This file is part of the linear-algebra library Seldon,
00004 // http://seldon.sourceforge.net/.
00005 //
00006 // Seldon is free software; you can redistribute it and/or modify it under the
00007 // terms of the GNU Lesser General Public License as published by the Free
00008 // Software Foundation; either version 2.1 of the License, or (at your option)
00009 // any later version.
00010 //
00011 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
00012 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
00014 // more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public License
00017 // along with Seldon. If not, see http://www.gnu.org/licenses/.
00018 
00019 
00020 #ifndef SELDON_FILE_ILUT_PRECONDITIONING_HXX
00021 
00022 namespace Seldon
00023 {
00024 
00025   template<class real, class cplx,
00026            class Allocator = SELDON_DEFAULT_ALLOCATOR<cplx> >
00027   class IlutPreconditioning
00028   {
00029   protected :
00031     int print_level;
00033     bool symmetric_algorithm;
00035     int type_ilu;
00039     int fill_level;
00043     int additional_fill;
00045     int mbloc;
00047     real alpha;
00049     real droptol;
00051     real permtol;
00053     IVect permutation_row, permutation_col;
00055     Matrix<cplx, Symmetric, ArrayRowSymSparse, Allocator> mat_sym;
00057     Matrix<cplx, General, ArrayRowSparse, Allocator> mat_unsym;
00059     Vector<cplx, VectFull, Allocator> xtmp;
00060 
00061   public :
00062 
00064     enum {ILUT, ILU_D, ILUT_K, ILU_0, MILU_0, ILU_K};
00065 
00066     IlutPreconditioning();
00067 
00068     void Clear();
00069 
00070     int GetFactorisationType() const;
00071     int GetFillLevel() const;
00072     int GetAdditionalFillNumber() const;
00073     int GetPrintLevel() const;
00074     int GetPivotBlockInteger() const;
00075 
00076     void SetFactorisationType(int);
00077     void SetFillLevel(int);
00078     void SetAdditionalFillNumber(int);
00079     void SetPrintLevel(int);
00080     void SetPivotBlockInteger(int);
00081     void SetSymmetricAlgorithm();
00082     void SetUnsymmetricAlgorithm();
00083 
00084     real GetDroppingThreshold() const;
00085     real GetDiagonalCoefficient() const;
00086     real GetPivotThreshold() const;
00087 
00088     void SetDroppingThreshold(real);
00089     void SetDiagonalCoefficient(real);
00090     void SetPivotThreshold(real);
00091 
00092     template<class MatrixSparse>
00093     void FactorizeSymMatrix(const IVect& perm,
00094                             MatrixSparse& mat, bool keep_matrix = false);
00095 
00096     template<class MatrixSparse>
00097     void FactorizeUnsymMatrix(const IVect& perm,
00098                               MatrixSparse& mat, bool keep_matrix = false);
00099 
00100     template<class T0, class Storage0, class Allocator0>
00101     void FactorizeMatrix(const IVect& perm,
00102                          Matrix<T0, General, Storage0, Allocator0>& mat,
00103                          bool keep_matrix = false);
00104 
00105     template<class T0, class Storage0, class Allocator0>
00106     void FactorizeMatrix(const IVect& perm,
00107                          Matrix<T0, Symmetric, Storage0, Allocator0>& mat,
00108                          bool keep_matrix = false);
00109 
00110     template<class Matrix1, class Vector1>
00111     void TransSolve(const Matrix1& A, const Vector1& r, Vector1& z);
00112 
00113     template<class Matrix1, class Vector1>
00114     void Solve(const Matrix1& A, const Vector1& r, Vector1& z);
00115 
00116     template<class Vector1>
00117     void TransSolve(Vector1& z);
00118 
00119     template<class Vector1>
00120     void Solve(Vector1& z);
00121 
00122     template<class TransStatus, class Vector1>
00123     void Solve(const TransStatus& transA, Vector1& z);
00124 
00125   };
00126 
00127 }
00128 
00129 #define SELDON_FILE_ILUT_PRECONDITIONING_HXX
00130 #endif