deal.II version GIT relicensing-2291-g668cd86249 2024-12-24 11:30:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Functions
SparseMatrixTools Namespace Reference

Functions

template<typename SparseMatrixType , typename SparsityPatternType , typename SparseMatrixType2 , typename SparsityPatternType2 >
void restrict_to_serial_sparse_matrix (const SparseMatrixType &sparse_matrix_in, const SparsityPatternType &sparsity_pattern, const IndexSet &requested_is, SparseMatrixType2 &system_matrix_out, SparsityPatternType2 &sparsity_pattern_out)
 
template<typename SparseMatrixType , typename SparsityPatternType , typename SparseMatrixType2 , typename SparsityPatternType2 >
void restrict_to_serial_sparse_matrix (const SparseMatrixType &sparse_matrix_in, const SparsityPatternType &sparsity_pattern, const IndexSet &index_set_0, const IndexSet &index_set_1, SparseMatrixType2 &system_matrix_out, SparsityPatternType2 &sparsity_pattern_out)
 
template<int dim, int spacedim, typename SparseMatrixType , typename SparsityPatternType , typename Number >
void restrict_to_cells (const SparseMatrixType &system_matrix, const SparsityPatternType &sparsity_pattern, const DoFHandler< dim, spacedim > &dof_handler, std::vector< FullMatrix< Number > > &blocks)
 
template<typename SparseMatrixType , typename SparsityPatternType , typename Number >
void restrict_to_full_matrices (const SparseMatrixType &sparse_matrix_in, const SparsityPatternType &sparsity_pattern, const std::vector< std::vector< types::global_dof_index > > &indices, std::vector< FullMatrix< Number > > &blocks)
 

Detailed Description

A namespace to process sparse matrices.

Function Documentation

◆ restrict_to_serial_sparse_matrix() [1/2]

template<typename SparseMatrixType , typename SparsityPatternType , typename SparseMatrixType2 , typename SparsityPatternType2 >
void SparseMatrixTools::restrict_to_serial_sparse_matrix ( const SparseMatrixType &  sparse_matrix_in,
const SparsityPatternType &  sparsity_pattern,
const IndexSet requested_is,
SparseMatrixType2 &  system_matrix_out,
SparsityPatternType2 &  sparsity_pattern_out 
)

Given a sparse matrix (system_matrix, sparsity_pattern), construct a new sparse matrix (system_matrix_out, sparsity_pattern_out) by restriction

\[ A_i = R_i A R_i^T, \]

where the Boolean matrix \(R_i\) is defined by the entries of requested_is.

The function can be called by multiple processes with different sets of indices, allowing to assign each process a different \(A_i\).

Such a function is useful to implement Schwarz methods, where operations of type

\[ u^{n} = u^{n-1} + \sum_{i} R_i^T A_i^{-1} R_i (f - A u^{n-1}) \]

are performed to iteratively solve a system of type \(Au=f\).

Warning
This is a collective call that needs to be executed by all processes in the communicator of sparse_matrix_in.

◆ restrict_to_serial_sparse_matrix() [2/2]

template<typename SparseMatrixType , typename SparsityPatternType , typename SparseMatrixType2 , typename SparsityPatternType2 >
void SparseMatrixTools::restrict_to_serial_sparse_matrix ( const SparseMatrixType &  sparse_matrix_in,
const SparsityPatternType &  sparsity_pattern,
const IndexSet index_set_0,
const IndexSet index_set_1,
SparseMatrixType2 &  system_matrix_out,
SparsityPatternType2 &  sparsity_pattern_out 
)

Similar to the above function, but taking two index sets (index_set_0, index_set_1), allowing to block the matrix. This is particularly useful, when dealing with vectors of type parallel::distributed::Vector, where the vector is blocked according to locally owned and ghost indices. As a consequence, the most typical usecase will be to pass in the set of locally owned DoFs and set of active or locally relevant DoFs.

Warning
This is a collective call that needs to be executed by all processes in the communicator of sparse_matrix_in.

◆ restrict_to_cells()

template<int dim, int spacedim, typename SparseMatrixType , typename SparsityPatternType , typename Number >
void SparseMatrixTools::restrict_to_cells ( const SparseMatrixType &  system_matrix,
const SparsityPatternType &  sparsity_pattern,
const DoFHandler< dim, spacedim > &  dof_handler,
std::vector< FullMatrix< Number > > &  blocks 
)

A restriction operation similar to the above one. However, the operation is performed for each locally owned active cell individually and index sets are given by their DoFs. The correct entries in the resulting vector can accessed by CellAccessor::active_cell_index().

Note
In a certain sense, this is the reversion of the cell loop during matrix assembly. However, doing this on a distributed matrix is not trivial, since 1) rows might be owned by different processes and 2) degrees of freedom might be constrained, resulting in "missing" entries in the matrix.
Warning
This is a collective call that needs to be executed by all processes in the communicator of sparse_matrix_in.

◆ restrict_to_full_matrices()

template<typename SparseMatrixType , typename SparsityPatternType , typename Number >
void SparseMatrixTools::restrict_to_full_matrices ( const SparseMatrixType &  sparse_matrix_in,
const SparsityPatternType &  sparsity_pattern,
const std::vector< std::vector< types::global_dof_index > > &  indices,
std::vector< FullMatrix< Number > > &  blocks 
)

A restriction operation similar to the above one. However, the indices of the blocks can be chosen arbitrarily. If the indices of cells are given, the output is the same as of the above function. However, one can also provide, e.g., indices that are also part of a halo around a cell to implement element-block based overlapping Schwarz methods.

If no indices are provided for a block, the resulting matrix of this block is empty.

Warning
This is a collective call that needs to be executed by all processes in the communicator of sparse_matrix_in.