Mumps.hxx
1 // Copyright (C) 2003-2015 Marc DuruflĂ©
2 //
3 // This file is part of the linear-algebra library Seldon,
4 // http://seldon.sourceforge.net/.
5 //
6 // Seldon is free software; you can redistribute it and/or modify it under the
7 // terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 2.1 of the License, or (at your option)
9 // any later version.
10 //
11 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 // more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with Seldon. If not, see http://www.gnu.org/licenses/.
18 
19 
20 #ifndef SELDON_FILE_MUMPS_HXX
21 
22 // including Mumps headers
23 extern "C"
24 {
25 #include "dmumps_c.h"
26 #include "zmumps_c.h"
27 }
28 
29 namespace Seldon
30 {
31  template<class T>
32  class TypeMumps
33  {
34  };
35 
36 
38  template<>
39  class TypeMumps<double>
40  {
41  public :
42  typedef DMUMPS_STRUC_C data;
43  typedef double* pointer;
44  };
45 
46 
48  template<>
49  class TypeMumps<complex<double> >
50  {
51  public :
52  typedef ZMUMPS_STRUC_C data;
53  typedef mumps_double_complex* pointer;
54  };
55 
56 
58  template<class T>
60  {
61  protected :
63  bool parallel_ordering;
67  typedef typename TypeMumps<T>::pointer pointer;
68  int print_level;
69  int info_facto;
70  bool out_of_core;
71  Vector<MUMPS_INT> num_row_glob, num_col_glob;
72  Vector<MUMPS_INT> perm;
73  double coef_overestimate;
74  double coef_increase_memory;
75  double coef_max_overestimate;
76  double threshold_pivot;
77 
78  // internal methods
79  void CallMumps();
80  void IterateFacto();
81 
82  void InitMatrix(bool sym, bool dist = false);
83 
84  public :
85  MatrixMumps();
86  ~MatrixMumps();
87 
88  bool UseInteger8() const;
89  void Clear();
90 
91  void SelectOrdering(int num_ordering);
92  void SelectParallelOrdering(int num_ordering);
93  void SetPermutation(const IVect& permut);
94  void SetPivotThreshold(double);
95 
96  void HideMessages();
97  void ShowMessages();
98 
99  void EnableOutOfCore();
100  void DisableOutOfCore();
101 
105 
106  size_t GetMemorySize() const;
107  int GetInfoFactorization() const;
108 
109  template<class T0, class Prop, class Storage, class Allocator>
111  IVect& numbers, bool keep_matrix = false);
112 
113  template<class T0, class Prop, class Storage, class Allocator>
115  bool keep_matrix = false);
116 
117  void FactorizeCoordinate1(int n, Vector<MUMPS_INT>& num_row,
118  Vector<MUMPS_INT>& num_col,
119  Vector<T>& values, bool sym);
120 
121  template<class Prop, class Storage, class Allocator>
123 
124  template<class Prop, class Allocator>
126 
127  template<class Prop, class Allocator>
129 
130  template<class Prop, class Storage, class Allocator>
132 
133  template<class Prop1, class Storage1, class Allocator1,
134  class Prop2, class Storage2, class Allocator2>
135  void GetSchurMatrix(Matrix<T, Prop1, Storage1, Allocator1>& mat,
136  const IVect& num,
138  bool keep_matrix = false);
139 
140  template<class Allocator2>
141  void Solve(const SeldonTranspose& TransA,
143 
144  void Solve(const SeldonTranspose&, T* x_ptr, int nrhs);
145 
146  template<class Allocator2>
148 
149  template<class Allocator2, class Prop>
150  void Solve(const SeldonTranspose& TransA,
152 
153 #ifdef SELDON_WITH_MPI
154  void FactorizeDistributedMatrix(MPI_Comm& comm_facto, Vector<long>& Ptr,
155  Vector<int>& IndRow, Vector<T>& Val,
156  const Vector<int>& glob_number,
157  bool sym, bool keep_matrix = false);
158 
159  void FactorizeDistributedMatrix(MPI_Comm& comm_facto, Vector<int64_t>& Ptr,
160  Vector<int64_t>& IndRow, Vector<T>& Val,
161  const Vector<int>& glob_number,
162  bool sym, bool keep_matrix = false);
163 
164  void FactorizeParallel(MPI_Comm& comm_facto, Vector<long>& Ptr,
165  Vector<MUMPS_INT>& IndRow, Vector<T>& Val,
166  const Vector<int>& glob_number,
167  bool sym, bool keep_matrix = false);
168 
169  void PerformAnalysisDistributed(MPI_Comm& comm_facto, Vector<long>& Ptr,
170  Vector<int>& IndRow, Vector<T>& Val,
171  const Vector<int>& glob_number,
172  bool sym, bool keep_matrix = false);
173 
174  void PerformAnalysisDistributed(MPI_Comm& comm_facto, Vector<int64_t>& Ptr,
175  Vector<int64_t>& IndRow, Vector<T>& Val,
176  const Vector<int>& glob_number,
177  bool sym, bool keep_matrix = false);
178 
179  void PerformFactorizationDistributed(MPI_Comm& comm_facto, Vector<long>& Ptr,
180  Vector<int>& IndRow, Vector<T>& Val,
181  const Vector<int>& glob_number,
182  bool sym, bool keep_matrix = false);
183 
184  void PerformFactorizationDistributed(MPI_Comm& comm_facto, Vector<int64_t>& Ptr,
185  Vector<int64_t>& IndRow, Vector<T>& Val,
186  const Vector<int>& glob_number,
187  bool sym, bool keep_matrix = false);
188 
189  template<class Allocator2>
190  void SolveDistributed(MPI_Comm& comm_facto,
191  const SeldonTranspose& TransA,
193  const IVect& glob_num);
194 
195  template<class Allocator2, class Prop>
196  void SolveDistributed(MPI_Comm& comm_facto,
197  const SeldonTranspose& TransA,
199  const IVect& glob_num);
200 
201  void SolveDistributed(MPI_Comm& comm_facto,
202  const SeldonTranspose& TransA,
203  T* x_ptr, int nrhs,
204  const IVect& glob_num);
205 #endif
206 
207  };
208 
209  template<class T0, class Prop, class Storage, class Allocator, class T>
211  bool keep_matrix = false);
212 
213  template<class T, class Storage, class Allocator, class MatrixFull>
215  MatrixMumps<T>& mat_lu, const IVect& num,
216  MatrixFull& schur_matrix, bool keep_matrix = false);
217 
218  template<class T, class Storage, class Allocator, class MatrixFull>
220  MatrixMumps<T>& mat_lu, const IVect& num,
221  MatrixFull& schur_matrix, bool keep_matrix = false);
222 
223  template<class T, class Allocator>
224  void SolveLU(MatrixMumps<T>& mat_lu, Vector<T, VectFull, Allocator>& x);
225 
226  template<class T, class Allocator>
227  void SolveLU(const SeldonTranspose& TransA,
229 
230  template<class Allocator>
231  void SolveLU(MatrixMumps<double>& mat_lu,
232  Vector<complex<double>, VectFull, Allocator>& x);
233 
234  template<class Allocator>
235  void SolveLU(const SeldonTranspose& TransA,
236  MatrixMumps<double>& mat_lu,
237  Vector<complex<double>, VectFull, Allocator>& x);
238 
239  template<class Allocator>
240  void SolveLU(MatrixMumps<complex<double> >& mat_lu,
242 
243  template<class Allocator>
244  void SolveLU(const SeldonTranspose& TransA,
245  MatrixMumps<complex<double> >& mat_lu,
247 
248  template<class T, class Prop, class Allocator>
249  void SolveLU(MatrixMumps<T>& mat_lu,
251 
252  template<class T, class Allocator, class Prop>
253  void SolveLU(const SeldonTranspose& TransA,
255 
256  template<class Prop, class Allocator>
257  void SolveLU(MatrixMumps<double>& mat_lu,
258  Matrix<complex<double>, Prop, ColMajor, Allocator>& x);
259 
260  template<class Prop, class Allocator>
261  void SolveLU(const SeldonTranspose& TransA,
262  MatrixMumps<double>& mat_lu,
263  Matrix<complex<double>, Prop, ColMajor, Allocator>& x);
264 
265  template<class Prop, class Allocator>
266  void SolveLU(MatrixMumps<complex<double> >& mat_lu,
268 
269  template<class Prop, class Allocator>
270  void SolveLU(const SeldonTranspose& TransA,
271  MatrixMumps<complex<double> >& mat_lu,
273 
274 }
275 
276 #define SELDON_FILE_MUMPS_HXX
277 #endif
278 
279 
280 
Seldon::MatrixMumps::SetIncreaseCoefficientEstimationNeededMemory
void SetIncreaseCoefficientEstimationNeededMemory(double)
Sets multiplication factor for each try to factorize the matrix.
Definition: Mumps.cxx:323
Seldon::SeldonTranspose
Definition: MatrixFlag.hxx:32
Seldon::GetSchurMatrix
void GetSchurMatrix(Matrix< T, Symmetric, Storage, Allocator > &A, MatrixMumps< T > &mat_lu, const IVect &num, MatrixFull &schur_matrix, bool keep_matrix)
computes Schur complement of a symmetric matrix
Definition: Mumps.cxx:1230
Seldon::MatrixMumps::FactorizeMatrix
void FactorizeMatrix(Matrix< T0, Prop, Storage, Allocator > &mat, bool keep_matrix=false)
Factorizes a given matrix.
Definition: Mumps.cxx:375
Seldon::MatrixMumps::SetCoefficientEstimationNeededMemory
void SetCoefficientEstimationNeededMemory(double)
Sets the coefficient used to overestimate the needed memory.
Definition: Mumps.cxx:307
Seldon::Vector< MUMPS_INT >
Seldon::MatrixMumps::FindOrdering
void FindOrdering(Matrix< T0, Prop, Storage, Allocator > &mat, IVect &numbers, bool keep_matrix=false)
Computes an ordering for matrix renumbering.
Definition: Mumps.cxx:336
Seldon::MatrixMumps::DisableOutOfCore
void DisableOutOfCore()
Disables writing on the disk (incore).
Definition: Mumps.cxx:299
Seldon::MatrixMumps::GetInfoFactorization
int GetInfoFactorization() const
Returns information about factorization performed.
Definition: Mumps.cxx:541
Seldon::MatrixMumps::MatrixMumps
MatrixMumps()
Default constructor.
Definition: Mumps.cxx:54
Seldon::MatrixMumps
object used to solve linear system by calling mumps subroutines
Definition: Mumps.hxx:59
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::MatrixMumps::PerformAnalysis
void PerformAnalysis(Matrix< T, Prop, Storage, Allocator > &mat)
Symbolic factorization.
Definition: Mumps.cxx:419
Seldon::MatrixMumps::InitMatrix
void InitMatrix(bool sym, bool dist=false)
Calls initialization routine provided by Mumps.
Definition: Mumps.cxx:125
Seldon::Matrix< T, Prop, RowSparse, Allocator >
Row-major sparse-matrix class.
Definition: Matrix_Sparse.hxx:223
Seldon::MatrixMumps::ShowMessages
void ShowMessages()
Informs Mumps to display standard output.
Definition: Mumps.cxx:277
Seldon::VectFull
Definition: StorageInline.cxx:74
Seldon::MatrixMumps::pointer
TypeMumps< T >::pointer pointer
double* or complex<double>*
Definition: Mumps.hxx:67
Seldon::MatrixMumps::FactorizeCoordinate1
void FactorizeCoordinate1(int n, Vector< MUMPS_INT > &num_row, Vector< MUMPS_INT > &num_col, Vector< T > &values, bool sym)
Factorizes a coordinate matrix with 1-index numbering.
Definition: Mumps.cxx:392
Seldon::MatrixMumps::Clear
void Clear()
Clears factorization.
Definition: Mumps.cxx:246
Seldon::MatrixMumps::SelectParallelOrdering
void SelectParallelOrdering(int num_ordering)
Selects another ordering scheme (for distributed matrices)
Definition: Mumps.cxx:211
Seldon::MatrixMumps::struct_mumps
TypeMumps< T >::data struct_mumps
object containing Mumps data structure
Definition: Mumps.hxx:65
Seldon::MatrixMumps::SetPivotThreshold
void SetPivotThreshold(double)
Sets the threshold for pivot.
Definition: Mumps.cxx:230
Seldon::MatrixMumps::SetMaximumCoefficientEstimationNeededMemory
void SetMaximumCoefficientEstimationNeededMemory(double)
Sets the maximal allowed coefficient for the memory space multiplication.
Definition: Mumps.cxx:315
Seldon::MatrixMumps::~MatrixMumps
~MatrixMumps()
Destructor.
Definition: Mumps.cxx:238
Seldon::Vector< T, VectFull, Allocator >
Full vector class.
Definition: Vector.hxx:88
Seldon::GetLU
void GetLU(Matrix< T0, Prop0, Storage0, Allocator0 > &A)
Returns the LU factorization of a matrix.
Definition: Functions_Matrix.cxx:2073
Seldon::VirtualSparseDirectSolver
Base class for an interface with a direct solver.
Definition: SparseSolver.hxx:30
Seldon::Matrix< T, Prop, RowSymSparse, Allocator >
Row-major sparse-matrix class.
Definition: Matrix_SymSparse.hxx:218
Seldon::MatrixMumps::PerformFactorization
void PerformFactorization(Matrix< T, Prop, RowSparse, Allocator > &mat)
Numerical factorization.
Definition: Mumps.cxx:452
Seldon::MatrixMumps::type_ordering
int type_ordering
ordering scheme (AMD, Metis, etc)
Definition: Mumps.hxx:62
Seldon::TypeMumps
Definition: Mumps.hxx:32
Seldon::MatrixMumps::Solve
void Solve(const SeldonTranspose &TransA, Vector< T, VectFull, Allocator2 > &x)
Solves a linear system using the computed factorization.
Definition: Mumps.cxx:630
Seldon::MatrixMumps::EnableOutOfCore
void EnableOutOfCore()
Enables writing on the disk (out of core).
Definition: Mumps.cxx:291
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::MatrixMumps::IterateFacto
void IterateFacto()
Function used to force factorisation when estimated space was too small.
Definition: Mumps.cxx:91
Seldon::MatrixMumps::SelectOrdering
void SelectOrdering(int num_ordering)
Selects another ordering scheme.
Definition: Mumps.cxx:203
Seldon::MatrixMumps::GetMemorySize
size_t GetMemorySize() const
Returns memory used by the factorisation in bytes.
Definition: Mumps.cxx:517
Seldon::MatrixMumps::SetPermutation
void SetPermutation(const IVect &permut)
Provides the permutation array.
Definition: Mumps.cxx:220
Seldon::Matrix< T, Prop, ColMajor, Allocator >
Column-major full-matrix class.
Definition: Matrix_Pointers.hxx:176
Seldon::MatrixMumps::HideMessages
void HideMessages()
Informs Mumps that no message should be displayed.
Definition: Mumps.cxx:263
Seldon::ColMajor
Definition: Storage.hxx:33