Reference documentation for deal.II version 9.3.3
|
#include <deal.II/lac/sparse_direct.h>
Classes | |
class | AdditionalData |
Public Types | |
using | size_type = types::global_dof_index |
Public Member Functions | |
SparseDirectUMFPACK () | |
~SparseDirectUMFPACK () override | |
Setting up a sparse factorization | |
void | initialize (const SparsityPattern &sparsity_pattern) |
template<class Matrix > | |
void | factorize (const Matrix &matrix) |
template<class Matrix > | |
void | initialize (const Matrix &matrix, const AdditionalData additional_data=AdditionalData()) |
Functions that represent the inverse of a matrix | |
void | vmult (Vector< double > &dst, const Vector< double > &src) const |
void | vmult (BlockVector< double > &dst, const BlockVector< double > &src) const |
void | Tvmult (Vector< double > &dst, const Vector< double > &src) const |
void | Tvmult (BlockVector< double > &dst, const BlockVector< double > &src) const |
size_type | m () const |
size_type | n () const |
Functions that solve linear systems | |
void | solve (Vector< double > &rhs_and_solution, const bool transpose=false) const |
void | solve (Vector< std::complex< double > > &rhs_and_solution, const bool transpose=false) const |
void | solve (BlockVector< double > &rhs_and_solution, const bool transpose=false) const |
void | solve (BlockVector< std::complex< double > > &rhs_and_solution, const bool transpose=false) const |
template<class Matrix > | |
void | solve (const Matrix &matrix, Vector< double > &rhs_and_solution, const bool transpose=false) |
template<class Matrix > | |
void | solve (const Matrix &matrix, Vector< std::complex< double > > &rhs_and_solution, const bool transpose=false) |
template<class Matrix > | |
void | solve (const Matrix &matrix, BlockVector< double > &rhs_and_solution, const bool transpose=false) |
template<class Matrix > | |
void | solve (const Matrix &matrix, BlockVector< std::complex< double > > &rhs_and_solution, const bool transpose=false) |
Static Public Member Functions | |
static ::ExceptionBase & | ExcUMFPACKError (std::string arg1, int arg2) |
Private Member Functions | |
void | clear () |
template<typename number > | |
void | sort_arrays (const SparseMatrixEZ< number > &) |
template<typename number > | |
void | sort_arrays (const SparseMatrix< number > &) |
template<typename number > | |
void | sort_arrays (const BlockSparseMatrix< number > &) |
Private Attributes | |
size_type | n_rows |
size_type | n_cols |
void * | symbolic_decomposition |
void * | numeric_decomposition |
std::vector< types::suitesparse_index > | Ap |
std::vector< types::suitesparse_index > | Ai |
std::vector< double > | Ax |
std::vector< double > | Az |
std::vector< double > | control |
Subscriptor functionality | |
Classes derived from Subscriptor provide a facility to subscribe to this object. This is mostly used by the SmartPointer class. | |
std::atomic< unsigned int > | counter |
std::map< std::string, unsigned int > | counter_map |
std::vector< std::atomic< bool > * > | validity_pointers |
const std::type_info * | object_info |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
template<typename StreamType > | |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
void | check_no_subscribers () const noexcept |
using | map_value_type = decltype(counter_map)::value_type |
using | map_iterator = decltype(counter_map)::iterator |
static std::mutex | mutex |
This class provides an interface to the sparse direct solver UMFPACK, which is part of the SuiteSparse library (see this link). UMFPACK is a set of routines for solving non-symmetric sparse linear systems, Ax=b, using the Unsymmetric-pattern MultiFrontal method and direct sparse LU factorization. Matrices may have symmetric or unsymmetric sparsity patterns, and may have unsymmetric entries. The use of this class is explained in the step-22 and step-29 tutorial programs.
This matrix class implements the usual interface of preconditioners, that is a function initialize(const SparseMatrix<double>&matrix,const AdditionalData) for initializing and the whole set of vmult() functions common to all matrices. Implemented here are only vmult() and vmult_add(), which perform multiplication with the inverse matrix. Furthermore, this class provides an older interface, consisting of the functions factorize() and solve(). Both interfaces are interchangeable.
There are instantiations of this class for SparseMatrix<double>, SparseMatrix<float>, SparseMatrixEZ<float>, SparseMatrixEZ<double>, BlockSparseMatrix<double>, and BlockSparseMatrix<float>.
Definition at line 87 of file sparse_direct.h.
Declare type for container size.
Definition at line 93 of file sparse_direct.h.
SparseDirectUMFPACK::SparseDirectUMFPACK | ( | ) |
Constructor. See the documentation of this class for the meaning of the parameters to this function.
Definition at line 55 of file sparse_direct.cc.
|
override |
Destructor.
Definition at line 42 of file sparse_direct.cc.
void SparseDirectUMFPACK::initialize | ( | const SparsityPattern & | sparsity_pattern | ) |
This function does nothing. It is only here to provide a interface consistent with other sparse direct solvers.
Definition at line 49 of file sparse_direct.cc.
void SparseDirectUMFPACK::factorize | ( | const Matrix & | matrix | ) |
Factorize the matrix. This function may be called multiple times for different matrices, after the object of this class has been initialized for a certain sparsity pattern. You may therefore save some computing time if you want to invert several matrices with the same sparsity pattern. However, note that the bulk of the computing time is actually spent in the factorization, so this functionality may not always be of large benefit.
In contrast to the other direct solver classes, the initialization method does nothing. Therefore initialize is not automatically called by this method, when the initialization step has not been performed yet.
This function copies the contents of the matrix into its own storage; the matrix can therefore be deleted after this operation, even if subsequent solves are required.
Definition at line 214 of file sparse_direct.cc.
void SparseDirectUMFPACK::initialize | ( | const Matrix & | matrix, |
const AdditionalData | additional_data = AdditionalData() |
||
) |
Initialize memory and call SparseDirectUMFPACK::factorize.
Definition at line 755 of file sparse_direct.cc.
Preconditioner interface function. Usually, given the source vector, this method returns an approximate solution of Ax = b. As this class provides a wrapper to a direct solver, here it is actually the exact solution (exact within the range of numerical accuracy of course).
In other words, this function actually multiplies with the exact inverse of the matrix, \(A^{-1}\).
Definition at line 762 of file sparse_direct.cc.
void SparseDirectUMFPACK::vmult | ( | BlockVector< double > & | dst, |
const BlockVector< double > & | src | ||
) | const |
Same as before, but for block vectors.
Definition at line 771 of file sparse_direct.cc.
Same as before, but uses the transpose of the matrix, i.e. this function multiplies with \(A^{-T}\).
Definition at line 780 of file sparse_direct.cc.
void SparseDirectUMFPACK::Tvmult | ( | BlockVector< double > & | dst, |
const BlockVector< double > & | src | ||
) | const |
Same as before, but for block vectors
Definition at line 790 of file sparse_direct.cc.
SparseDirectUMFPACK::size_type SparseDirectUMFPACK::m | ( | ) | const |
Return the dimension of the codomain (or range) space. Note that the matrix is of dimension \(m \times n\).
Definition at line 798 of file sparse_direct.cc.
SparseDirectUMFPACK::size_type SparseDirectUMFPACK::n | ( | ) | const |
Return the dimension of the domain space. Note that the matrix is of dimension \(m \times n\).
Definition at line 805 of file sparse_direct.cc.
void SparseDirectUMFPACK::solve | ( | Vector< double > & | rhs_and_solution, |
const bool | transpose = false |
||
) | const |
Solve for a certain right hand side vector. This function may be called multiple times for different right hand side vectors after the matrix has been factorized. This yields substantial savings in computing time, since the actual solution is fast, compared to the factorization of the matrix.
The solution will be returned in place of the right hand side vector.
[in,out] | rhs_and_solution | A vector that contains the right hand side \(b\) of a linear system \(Ax=b\) upon calling this function, and that contains the solution \(x\) of the linear system after calling this function. |
[in] | transpose | If set to true, this function solves the linear \(A^T x = b\) instead of \(Ax=b\). |
Definition at line 344 of file sparse_direct.cc.
void SparseDirectUMFPACK::solve | ( | Vector< std::complex< double > > & | rhs_and_solution, |
const bool | transpose = false |
||
) | const |
Like the previous function, but for a complex-valued right hand side and solution vector.
If the matrix that was previously factorized had complex-valued entries, then the rhs_and_solution
vector will, upon return from this function, simply contain the solution of the linear system \(Ax=b\). If the matrix was real-valued, then this is also true, but the solution will simply be computed by applying the factorized \(A^{-1}\) to both the real and imaginary parts of the right hand side vector.
Definition at line 384 of file sparse_direct.cc.
void SparseDirectUMFPACK::solve | ( | BlockVector< double > & | rhs_and_solution, |
const bool | transpose = false |
||
) | const |
Same as before, but for block vectors.
Definition at line 499 of file sparse_direct.cc.
void SparseDirectUMFPACK::solve | ( | BlockVector< std::complex< double > > & | rhs_and_solution, |
const bool | transpose = false |
||
) | const |
Same as before, but for complex-valued block vectors.
Definition at line 514 of file sparse_direct.cc.
void SparseDirectUMFPACK::solve | ( | const Matrix & | matrix, |
Vector< double > & | rhs_and_solution, | ||
const bool | transpose = false |
||
) |
Call the two functions factorize() and solve() in that order, i.e. perform the whole solution process for the given right hand side vector.
The solution will be returned in place of the right hand side vector.
Definition at line 540 of file sparse_direct.cc.
void SparseDirectUMFPACK::solve | ( | const Matrix & | matrix, |
Vector< std::complex< double > > & | rhs_and_solution, | ||
const bool | transpose = false |
||
) |
Same as before, but for complex-valued solution vectors.
Definition at line 552 of file sparse_direct.cc.
void SparseDirectUMFPACK::solve | ( | const Matrix & | matrix, |
BlockVector< double > & | rhs_and_solution, | ||
const bool | transpose = false |
||
) |
Same as before, but for block vectors.
Definition at line 576 of file sparse_direct.cc.
void SparseDirectUMFPACK::solve | ( | const Matrix & | matrix, |
BlockVector< std::complex< double > > & | rhs_and_solution, | ||
const bool | transpose = false |
||
) |
Same as before, but for complex-valued block vectors.
Definition at line 588 of file sparse_direct.cc.
|
private |
Free all memory that hasn't been freed yet.
Definition at line 68 of file sparse_direct.cc.
|
private |
Make sure that the arrays Ai and Ap are sorted in each row. UMFPACK wants it this way. We need to have three versions of this function, one for the usual SparseMatrix, one for the SparseMatrixEZ, and one for the BlockSparseMatrix classes
Definition at line 150 of file sparse_direct.cc.
|
private |
Definition at line 110 of file sparse_direct.cc.
|
private |
Definition at line 173 of file sparse_direct.cc.
|
private |
The dimension of the range space, i.e., the number of rows of the matrix.
Definition at line 364 of file sparse_direct.h.
|
private |
The dimension of the domain space, i.e., the number of columns of the matrix.
Definition at line 370 of file sparse_direct.h.
|
private |
The UMFPACK routines allocate objects in which they store information about symbolic and numeric values of the decomposition. The actual data type of these objects is opaque, and only passed around as void pointers.
Definition at line 377 of file sparse_direct.h.
|
private |
Definition at line 378 of file sparse_direct.h.
|
private |
The arrays in which we store the data for the solver. These are documented in the descriptions of the umfpack_*_symbolic() and umfpack_*_numeric() functions, but in short:
Ap
is the array saying which row starts where in Ai
Ai
is the array that stores the column indices of nonzero entriesAx
is the array that stores the values of nonzero entries; if the matrix is complex-valued, then it stores the real partsAz
is the array that stores the imaginary parts of nonzero entries, and is used only if the matrix is complex-valued. Definition at line 415 of file sparse_direct.h.
|
private |
Definition at line 416 of file sparse_direct.h.
|
private |
Definition at line 417 of file sparse_direct.h.
|
private |
Definition at line 418 of file sparse_direct.h.
|
private |
Control and work arrays for the solver routines.
Definition at line 423 of file sparse_direct.h.