Reference documentation for deal.II version 9.1.0-pre
sparse_direct.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2001 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_sparse_direct_h
17 #define dealii_sparse_direct_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/exceptions.h>
23 #include <deal.II/base/subscriptor.h>
24 #include <deal.II/base/thread_management.h>
25 
26 #include <deal.II/lac/block_sparse_matrix.h>
27 #include <deal.II/lac/sparse_matrix.h>
28 #include <deal.II/lac/sparse_matrix_ez.h>
29 #include <deal.II/lac/vector.h>
30 
31 #ifdef DEAL_II_WITH_UMFPACK
32 # include <umfpack.h>
33 #endif
34 #ifndef SuiteSparse_long
35 # define SuiteSparse_long long int
36 #endif
37 
38 DEAL_II_NAMESPACE_OPEN
39 
85 {
86 public:
91 
97  {};
98 
99 
105 
109  ~SparseDirectUMFPACK() override;
110 
122  void
123  initialize(const SparsityPattern &sparsity_pattern);
124 
142  template <class Matrix>
143  void
144  factorize(const Matrix &matrix);
145 
149  template <class Matrix>
150  void
151  initialize(const Matrix & matrix,
152  const AdditionalData additional_data = AdditionalData());
153 
174  void
175  vmult(Vector<double> &dst, const Vector<double> &src) const;
176 
180  void
181  vmult(BlockVector<double> &dst, const BlockVector<double> &src) const;
182 
187  void
188  Tvmult(Vector<double> &dst, const Vector<double> &src) const;
189 
193  void
194  Tvmult(BlockVector<double> &dst, const BlockVector<double> &src) const;
195 
200  size_type
201  m() const;
202 
207  size_type
208  n() const;
209 
236  void
237  solve(Vector<double> &rhs_and_solution, const bool transpose = false) const;
238 
242  void
243  solve(BlockVector<double> &rhs_and_solution,
244  const bool transpose = false) const;
245 
252  template <class Matrix>
253  void
254  solve(const Matrix & matrix,
255  Vector<double> &rhs_and_solution,
256  const bool transpose = false);
257 
261  template <class Matrix>
262  void
263  solve(const Matrix & matrix,
264  BlockVector<double> &rhs_and_solution,
265  const bool transpose = false);
266 
278  std::string,
279  int,
280  << "UMFPACK routine " << arg1 << " returned error status " << arg2 << "."
281  << "\n\n"
282  << ("A complete list of error codes can be found in the file "
283  "<bundled/umfpack/UMFPACK/Include/umfpack.h>."
284  "\n\n"
285  "That said, the two most common errors that can happen are "
286  "that your matrix cannot be factorized because it is "
287  "rank deficient, and that UMFPACK runs out of memory "
288  "because your problem is too large."
289  "\n\n"
290  "The first of these cases most often happens if you "
291  "forget terms in your bilinear form necessary to ensure "
292  "that the matrix has full rank, or if your equation has a "
293  "spatially variable coefficient (or nonlinearity) that is "
294  "supposed to be strictly positive but, for whatever "
295  "reasons, is negative or zero. In either case, you probably "
296  "want to check your assembly procedure. Similarly, a "
297  "matrix can be rank deficient if you forgot to apply the "
298  "appropriate boundary conditions. For example, the "
299  "Laplace equation without boundary conditions has a "
300  "single zero eigenvalue and its rank is therefore "
301  "deficient by one."
302  "\n\n"
303  "The other common situation is that you run out of memory."
304  "On a typical laptop or desktop, it should easily be possible "
305  "to solve problems with 100,000 unknowns in 2d. If you are "
306  "solving problems with many more unknowns than that, in "
307  "particular if you are in 3d, then you may be running out "
308  "of memory and you will need to consider iterative "
309  "solvers instead of the direct solver employed by "
310  "UMFPACK."));
311 
312 private:
317 
322 
329  void *numeric_decomposition;
330 
334  void
335  clear();
336 
343  template <typename number>
344  void
346 
347  template <typename number>
348  void
350 
351  template <typename number>
352  void
354 
360  std::vector<SuiteSparse_long> Ap;
361  std::vector<SuiteSparse_long> Ai;
362  std::vector<double> Ax;
363 
367  std::vector<double> control;
368 };
369 
370 DEAL_II_NAMESPACE_CLOSE
371 
372 #endif // dealii_sparse_direct_h
static::ExceptionBase & ExcUMFPACKError(std::string arg1, int arg2)
size_type n() const
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:420
size_type m() const
void solve(Vector< double > &rhs_and_solution, const bool transpose=false) const
void Tvmult(Vector< double > &dst, const Vector< double > &src) const
unsigned long long int global_dof_index
Definition: types.h:72
void factorize(const Matrix &matrix)
types::global_dof_index size_type
Definition: sparse_direct.h:90
std::vector< SuiteSparse_long > Ap
SymmetricTensor< rank_, dim, Number > transpose(const SymmetricTensor< rank_, dim, Number > &t)
std::vector< double > control
void initialize(const SparsityPattern &sparsity_pattern)
~SparseDirectUMFPACK() override
void sort_arrays(const SparseMatrixEZ< number > &)
void vmult(Vector< double > &dst, const Vector< double > &src) const