Reference documentation for deal.II version 8.5.1
|
#include <deal.II/matrix_free/operators.h>
Public Types | |
typedef VectorType::value_type | value_type |
typedef VectorType::size_type | size_type |
Public Member Functions | |
Base () | |
virtual | ~Base () |
virtual void | clear () |
void | initialize (std_cxx11::shared_ptr< const MatrixFree< dim, value_type > > data, const std::vector< unsigned int > &selected_row_blocks=std::vector< unsigned int >(), const std::vector< unsigned int > &selected_column_blocks=std::vector< unsigned int >()) |
void | initialize (std_cxx11::shared_ptr< const MatrixFree< dim, value_type > > data, const MGConstrainedDoFs &mg_constrained_dofs, const unsigned int level, const std::vector< unsigned int > &selected_row_blocks=std::vector< unsigned int >()) |
void | initialize (std_cxx11::shared_ptr< const MatrixFree< dim, value_type > > data_, const std::vector< MGConstrainedDoFs > &mg_constrained_dofs, const unsigned int level, const std::vector< unsigned int > &selected_row_blocks=std::vector< unsigned int >()) |
size_type | m () const |
size_type | n () const |
void | vmult_interface_down (VectorType &dst, const VectorType &src) const |
void | vmult_interface_up (VectorType &dst, const VectorType &src) const |
void | vmult (VectorType &dst, const VectorType &src) const |
void | Tvmult (VectorType &dst, const VectorType &src) const |
void | vmult_add (VectorType &dst, const VectorType &src) const |
void | Tvmult_add (VectorType &dst, const VectorType &src) const |
value_type | el (const unsigned int row, const unsigned int col) const |
virtual std::size_t | memory_consumption () const |
void | initialize_dof_vector (VectorType &vec) const |
virtual void | compute_diagonal ()=0 |
std_cxx11::shared_ptr< const MatrixFree< dim, value_type > > | get_matrix_free () const |
const std_cxx11::shared_ptr< DiagonalMatrix< VectorType > > & | get_matrix_diagonal_inverse () const |
void | precondition_Jacobi (VectorType &dst, const VectorType &src, const value_type omega) const |
Public Member Functions inherited from Subscriptor | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
Subscriptor (Subscriptor &&) | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (const Subscriptor &) |
Subscriptor & | operator= (Subscriptor &&) |
void | subscribe (const char *identifier=0) const |
void | unsubscribe (const char *identifier=0) const |
unsigned int | n_subscriptions () const |
void | list_subscribers () const |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Protected Member Functions | |
void | set_constrained_entries_to_one (VectorType &dst) const |
virtual void | apply_add (VectorType &dst, const VectorType &src) const =0 |
virtual void | Tapply_add (VectorType &dst, const VectorType &src) const |
Protected Attributes | |
std_cxx11::shared_ptr< const MatrixFree< dim, value_type > > | data |
std_cxx11::shared_ptr< DiagonalMatrix< VectorType > > | inverse_diagonal_entries |
std::vector< unsigned int > | selected_rows |
std::vector< unsigned int > | selected_columns |
Private Member Functions | |
void | mult_add (VectorType &dst, const VectorType &src, const bool transpose) const |
void | adjust_ghost_range_if_necessary (const VectorType &vec, const bool is_row) const |
Private Attributes | |
std::vector< std::vector< unsigned int > > | edge_constrained_indices |
std::vector< std::vector< std::pair< value_type, value_type > > > | edge_constrained_values |
bool | have_interface_matrices |
Additional Inherited Members | |
Static Public Member Functions inherited from Subscriptor | |
static ::ExceptionBase & | ExcInUse (int arg1, char *arg2, std::string &arg3) |
static ::ExceptionBase & | ExcNoSubscriber (char *arg1, char *arg2) |
Abstract base class for matrix-free operators which can be used both at the finest mesh or at a certain level in geometric multigrid.
A derived class has to implement apply_add() method as well as compute_diagonal() to initialize the protected member inverse_diagonal_entries. In case of a non-symmetric operator, Tapply_add() should be additionally implemented.
Currently, the only supported vectors are LinearAlgebra::distributed::Vector and LinearAlgebra::distributed::BlockVector.
MatrixFree allows to use several DoFHandler/ConstraintMatrix combinations by passing an std::vector with pointers to the respective objects into the MatrixFree::reinit function. This class supports to select only some of the blocks in the underlying MatrixFree object by optional integer lists that specify the chosen blocks.
One application of selection is in problems with a Newton-type iteration or problems with inhomogeneous boundary conditions. In such a case, one has to deal with two different sets of constraints: One set of constraints applies to the solution vector which might include hanging node constraints or periodicity constraints but no constraints on inhomogeneous Dirichlet boundaries. Before the nonlinear iteration, the boundary values are set to the expected value in the vector representing the initial guess. In each iteration of the Newton method, a linear system subject to zero Dirichlet boundary conditions is solved that is then added to the initial guess. This setup can be realized by using a vector of two pointers pointing to the same DoFHandler object and a vector of two pointers to the two ConstraintMatrix objects. If the first constraint matrix is the one including the zero Dirichlet constraints, one would give an std::vector<unsigned int>(1, 0) to the initialize() function, i.e., a vector of length 1 that selects exactly the first constraint matrix with index 0.
A second application of using selectively constructing a matrix-free operator would be the setting of the step-32 tutorial program: This problem has three blocks, one for the velocity, one for the pressure, and one for temperature. The time lag scheme used for temporal evolution splits the temperature equation away from the Stokes system in velocity and pressure. However, there are cross terms like the velocity that enters the temperature advection-diffusion equation or the temperature that enters the right hand side of the velocity. In order to be sure that MatrixFree uses the same integer indexing to the different blocks, one needs to put all three blocks into the same MatrixFree object. However, when solving a linear system the operators involved either address the first two in the Stokes solver, or the last one for the temperature solver. In the former case, a BlockVector of two components would be selected with a vector selecting the blocks {0, 1} in MatrixFree, whereas in the latter, a non-block vector selecting the block {2} would be used.
Definition at line 164 of file operators.h.
typedef VectorType::value_type MatrixFreeOperators::Base< dim, VectorType >::value_type |
Number typedef.
Definition at line 170 of file operators.h.
typedef VectorType::size_type MatrixFreeOperators::Base< dim, VectorType >::size_type |
size_type needed for preconditioner classes.
Definition at line 175 of file operators.h.
MatrixFreeOperators::Base< dim, VectorType >::Base | ( | ) |
Default constructor.
Definition at line 881 of file operators.h.
|
virtual |
Virtual destructor.
Definition at line 874 of file operators.h.
|
virtual |
Release all memory and return to a state just like after having called the default constructor.
Reimplemented in MatrixFreeOperators::LaplaceOperator< dim, fe_degree, n_q_points_1d, n_components, VectorType >.
Definition at line 923 of file operators.h.
void MatrixFreeOperators::Base< dim, VectorType >::initialize | ( | std_cxx11::shared_ptr< const MatrixFree< dim, value_type > > | data, |
const std::vector< unsigned int > & | selected_row_blocks = std::vector< unsigned int >() , |
||
const std::vector< unsigned int > & | selected_column_blocks = std::vector< unsigned int >() |
||
) |
Initialize operator on fine scale.
The optional selection vector allows to choose only some components from the underlying MatrixFree object, e.g. just a single one. The entry selected_row_blocks
[i] in the vector chooses the DoFHandler and ConstraintMatrix object that was given as the selected_row_blocks
[i]-th argument to the MatrixFree::reinit() call. Different arguments for rows and columns also make it possible to select non-diagonal blocks or rectangular blocks. If the row vector is empty, all components are selected, otherwise its size must be smaller or equal to MatrixFree::n_components() and all indices need to be unique and within the range of 0 and MatrixFree::n_components(). If the column selection vector is empty, it is taken the same as the row selection, defining a diagonal block.
void MatrixFreeOperators::Base< dim, VectorType >::initialize | ( | std_cxx11::shared_ptr< const MatrixFree< dim, value_type > > | data, |
const MGConstrainedDoFs & | mg_constrained_dofs, | ||
const unsigned int | level, | ||
const std::vector< unsigned int > & | selected_row_blocks = std::vector< unsigned int >() |
||
) |
Initialize operator on a level level
for a single FiniteElement.
The optional selection vector allows to choose only some components from the underlying MatrixFree object, e.g. just a single one. The entry selected_row_blocks
[i] in the vector chooses the DoFHandler and ConstraintMatrix object that was given as the selected_row_blocks
[i]-th argument to the MatrixFree::reinit() call. Since a multigrid operator is always associated to inverting a matrix and thus represents a diagonal block, the same vector for rows and columns is used as opposed to the non-level initialization function. If empty, all components are selected.
void MatrixFreeOperators::Base< dim, VectorType >::initialize | ( | std_cxx11::shared_ptr< const MatrixFree< dim, value_type > > | data_, |
const std::vector< MGConstrainedDoFs > & | mg_constrained_dofs, | ||
const unsigned int | level, | ||
const std::vector< unsigned int > & | selected_row_blocks = std::vector<unsigned int>() |
||
) |
Initialize operator on a level level
for multiple FiniteElement objects.
The optional selection vector allows to choose only some components from the underlying MatrixFree object, e.g. just a single one. The entry selected_row_blocks
[i] in the vector chooses the DoFHandler and ConstraintMatrix object that was given as the selected_row_blocks
[i]-th argument to the MatrixFree::reinit() call. Since a multigrid operator is always associated to inverting a matrix and thus represents a diagonal block, the same vector for rows and columns is used as opposed to the non-level initialization function. If empty, all components are selected.
Definition at line 1036 of file operators.h.
Base< dim, VectorType >::size_type MatrixFreeOperators::Base< dim, VectorType >::m | ( | ) | const |
Return the dimension of the codomain (or range) space.
Definition at line 895 of file operators.h.
Base< dim, VectorType >::size_type MatrixFreeOperators::Base< dim, VectorType >::n | ( | ) | const |
Return the dimension of the domain space.
Definition at line 909 of file operators.h.
void MatrixFreeOperators::Base< dim, VectorType >::vmult_interface_down | ( | VectorType & | dst, |
const VectorType & | src | ||
) | const |
vmult operator for interface.
Definition at line 1247 of file operators.h.
void MatrixFreeOperators::Base< dim, VectorType >::vmult_interface_up | ( | VectorType & | dst, |
const VectorType & | src | ||
) | const |
vmult operator for interface.
Definition at line 1299 of file operators.h.
void MatrixFreeOperators::Base< dim, VectorType >::vmult | ( | VectorType & | dst, |
const VectorType & | src | ||
) | const |
Matrix-vector multiplication.
Definition at line 1119 of file operators.h.
void MatrixFreeOperators::Base< dim, VectorType >::Tvmult | ( | VectorType & | dst, |
const VectorType & | src | ||
) | const |
Transpose matrix-vector multiplication.
Definition at line 1337 of file operators.h.
void MatrixFreeOperators::Base< dim, VectorType >::vmult_add | ( | VectorType & | dst, |
const VectorType & | src | ||
) | const |
Adding Matrix-vector multiplication.
Definition at line 1131 of file operators.h.
void MatrixFreeOperators::Base< dim, VectorType >::Tvmult_add | ( | VectorType & | dst, |
const VectorType & | src | ||
) | const |
Adding transpose matrix-vector multiplication.
Definition at line 1141 of file operators.h.
Base< dim, VectorType >::value_type MatrixFreeOperators::Base< dim, VectorType >::el | ( | const unsigned int | row, |
const unsigned int | col | ||
) | const |
Returns the value of the matrix entry (row,col). In matrix-free context this function is valid only for row==col when diagonal is initialized.
Definition at line 933 of file operators.h.
|
virtual |
Determine an estimate for the memory consumption (in bytes) of this object.
Definition at line 1349 of file operators.h.
void MatrixFreeOperators::Base< dim, VectorType >::initialize_dof_vector | ( | VectorType & | vec | ) | const |
A wrapper for initialize_dof_vector() of MatrixFree object.
Definition at line 947 of file operators.h.
|
pure virtual |
Compute diagonal of this operator.
A derived class needs to implement this function and resize and fill the protected member inverse_diagonal_entries accordingly.
Implemented in MatrixFreeOperators::LaplaceOperator< dim, fe_degree, n_q_points_1d, n_components, VectorType >, and MatrixFreeOperators::MassOperator< dim, fe_degree, n_q_points_1d, n_components, VectorType >.
std_cxx11::shared_ptr< const MatrixFree< dim, typename Base< dim, VectorType >::value_type > > MatrixFreeOperators::Base< dim, VectorType >::get_matrix_free | ( | ) | const |
Get read access to the MatrixFree object stored with this operator.
Definition at line 1358 of file operators.h.
const std_cxx11::shared_ptr< DiagonalMatrix< VectorType > > & MatrixFreeOperators::Base< dim, VectorType >::get_matrix_diagonal_inverse | ( | ) | const |
Get read access to the inverse diagonal of this operator.
Definition at line 1367 of file operators.h.
void MatrixFreeOperators::Base< dim, VectorType >::precondition_Jacobi | ( | VectorType & | dst, |
const VectorType & | src, | ||
const value_type | omega | ||
) | const |
Apply the Jacobi preconditioner, which multiplies every element of the src
vector by the inverse of the respective diagonal element and multiplies the result with the relaxation factor omega
.
Definition at line 1388 of file operators.h.
|
protected |
Set constrained entries (both from hanging nodes and edge constraints) of dst
to one.
Definition at line 1102 of file operators.h.
|
protectedpure virtual |
Apply operator to src
and add result in dst
.
Implemented in MatrixFreeOperators::LaplaceOperator< dim, fe_degree, n_q_points_1d, n_components, VectorType >, and MatrixFreeOperators::MassOperator< dim, fe_degree, n_q_points_1d, n_components, VectorType >.
|
protectedvirtual |
Apply transpose operator to src
and add result in dst
.
Default implementation is to call apply_add().
Definition at line 1378 of file operators.h.
|
private |
Function which implements vmult_add (transpose
= false) and Tvmult_add (transpose
= true).
Definition at line 1187 of file operators.h.
|
private |
Adjust the ghost range of the vectors to the storage requirements of the underlying MatrixFree class. This is used inside the mult_add() as well as vmult_interface_up() and vmult_interface_down() methods in order to ensure that the cell loops will be able to access the ghost indices with the correct local indices.
Definition at line 1151 of file operators.h.
|
protected |
MatrixFree object to be used with this operator.
Definition at line 368 of file operators.h.
|
protected |
A shared pointer to a diagonal matrix that stores the inverse of diagonal elements as a vector.
Definition at line 374 of file operators.h.
|
protected |
A vector which defines the selection of sub-components of MatrixFree for the rows of the matrix representation.
Definition at line 380 of file operators.h.
|
protected |
A vector which defines the selection of sub-components of MatrixFree for the columns of the matrix representation.
Definition at line 386 of file operators.h.
|
private |
Indices of DoFs on edge in case the operator is used in GMG context.
Definition at line 393 of file operators.h.
|
mutableprivate |
Auxiliary vector.
Definition at line 399 of file operators.h.
|
private |
A flag which determines whether or not this operator has interface matrices in GMG context.
Definition at line 405 of file operators.h.