computation/interfaces/direct/Mumps.hxx

00001 // Copyright (C) 2003-2009 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_MUMPS_HXX
00021 
00022 // including Mumps headers
00023 extern "C"
00024 {
00025 #include "dmumps_c.h"
00026 #include "zmumps_c.h"
00027 
00028   // including mpi from sequential version of Mumps if the
00029   // compilation is not made on a parallel machine
00030 #ifndef SELDON_WITH_MPI
00031 #include "mpi.h"
00032 #endif
00033 
00034 }
00035 
00036 namespace Seldon
00037 {
00038   template<class T>
00039   class TypeMumps
00040   {
00041   };
00042 
00043 
00045   template<>
00046   class TypeMumps<double>
00047   {
00048   public :
00049     typedef DMUMPS_STRUC_C data;
00050     typedef double* pointer;
00051   };
00052 
00053 
00055   template<>
00056   class TypeMumps<complex<double> >
00057   {
00058   public :
00059     typedef ZMUMPS_STRUC_C data;
00060     typedef mumps_double_complex* pointer;
00061   };
00062 
00063 
00065   template<class T>
00066   class MatrixMumps
00067   {
00068   protected :
00069     int type_ordering; 
00070 
00071     typename TypeMumps<T>::data struct_mumps;
00073     typedef typename TypeMumps<T>::pointer pointer;
00074     int print_level;
00075     bool out_of_core;
00076     IVect num_row_glob, num_col_glob;
00077     IVect perm;
00078 
00079     // internal methods
00080     void CallMumps();
00081     template<class MatrixSparse>
00082     void InitMatrix(const MatrixSparse&, bool dist = false);
00083 
00084   public :
00085     MatrixMumps();
00086     ~MatrixMumps();
00087 
00088     void Clear();
00089 
00090     void SelectOrdering(int num_ordering);
00091     void SetPermutation(const IVect& permut);
00092 
00093     void HideMessages();
00094     void ShowMessages();
00095 
00096     void EnableOutOfCore();
00097     void DisableOutOfCore();
00098 
00099     int GetInfoFactorization() const;
00100 
00101     template<class Prop, class Storage, class Allocator>
00102     void FindOrdering(Matrix<T, Prop, Storage, Allocator> & mat,
00103                       IVect& numbers, bool keep_matrix = false);
00104 
00105     template<class Prop, class Storage, class Allocator>
00106     void FactorizeMatrix(Matrix<T, Prop, Storage, Allocator> & mat,
00107                          bool keep_matrix = false);
00108 
00109     template<class Prop, class Storage, class Allocator>
00110     void PerformAnalysis(Matrix<T, Prop, Storage, Allocator> & mat);
00111 
00112     template<class Prop, class Storage, class Allocator>
00113     void PerformFactorization(Matrix<T, Prop, Storage, Allocator> & mat);
00114 
00115     template<class Prop1, class Storage1, class Allocator1,
00116              class Prop2, class Storage2, class Allocator2>
00117     void GetSchurMatrix(Matrix<T, Prop1, Storage1, Allocator1>& mat,
00118                         const IVect& num,
00119                         Matrix<T, Prop2, Storage2, Allocator2> & mat_schur,
00120                         bool keep_matrix = false);
00121 
00122     template<class Allocator2>
00123     void Solve(Vector<T, VectFull, Allocator2>& x);
00124 
00125     template<class Allocator2, class Transpose_status>
00126     void Solve(const Transpose_status& TransA,
00127                Vector<T, VectFull, Allocator2>& x);
00128 
00129     template<class Allocator2, class Transpose_status, class Prop>
00130     void Solve(const Transpose_status& TransA,
00131                Matrix<T, Prop, ColMajor, Allocator2>& x);
00132 
00133 #ifdef SELDON_WITH_MPI
00134     template<class Alloc1, class Alloc2, class Alloc3, class Tint>
00135     void FactorizeDistributedMatrix(MPI::Comm& comm_facto,
00136                                     Vector<Tint, VectFull, Alloc1>&,
00137                                     Vector<Tint, VectFull, Alloc2>&,
00138                                     Vector<T, VectFull, Alloc3>&,
00139                                     const Vector<Tint>& glob_number,
00140                                     bool sym, bool keep_matrix = false);
00141 
00142     template<class Allocator2, class Tint>
00143     void SolveDistributed(MPI::Comm& comm_facto,
00144                           Vector<T, Vect_Full, Allocator2>& x,
00145                           const Vector<Tint>& glob_num);
00146 
00147     template<class Allocator2, class Transpose_status>
00148     void SolveDistributed(MPI::Comm& comm_facto,
00149                           const Transpose_status& TransA,
00150                           Vector<T, VectFull, Allocator2>& x,
00151                           const IVect& glob_num);
00152 
00153 #endif
00154 
00155   };
00156 
00157 }
00158 
00159 #define SELDON_FILE_MUMPS_HXX
00160 #endif
00161 
00162 
00163