From: David Wells Date: Sat, 28 Oct 2017 21:35:33 +0000 (-0400) Subject: Add another BlockLinearOperator example. X-Git-Tag: v9.0.0-rc1~849^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=874a2afea283e9c756676c5891a1290db79404d5;p=dealii.git Add another BlockLinearOperator example. --- diff --git a/include/deal.II/lac/block_linear_operator.h b/include/deal.II/lac/block_linear_operator.h index ccb43b12a2..3afeb24ca3 100644 --- a/include/deal.II/lac/block_linear_operator.h +++ b/include/deal.II/lac/block_linear_operator.h @@ -122,6 +122,39 @@ block_back_substitution(const BlockLinearOperator & * const auto block_op_a = block_operator(A); * @endcode * + * Alternatively, there are several helper functions available for creating + * instances from multiple independent matrices of possibly different types. + * Here is an example of a block diagonal matrix created from a FullMatrix and + * a SparseMatrixEZ: + * + * @code + * FullMatrix top_left(2, 2); + * top_left(0, 0) = 2.0; + * top_left(0, 1) = -1.0; + * top_left(1, 0) = -1.0; + * top_left(1, 1) = 2.0; + * + * SparseMatrixEZ bottom_right(4, 4, 4); + * for (std::size_t row_n = 0; row_n < 4; ++row_n) + * { + * bottom_right.add(row_n, row_n, 1.0); + * if (row_n < 3) + * bottom_right.add(row_n, row_n + 1, -1.0); + * } + * + * auto top_left_op = linear_operator(top_left); + * auto bottom_right_op = linear_operator(bottom_right); + * std::array operators {{top_left_op, bottom_right_op}}; + * auto block_op = block_diagonal_operator (operators); + * + * std::vector::size_type> block_sizes {2, 4}; + * BlockVector src(block_sizes); + * src = 2.0; + * BlockVector dst(block_sizes); + * block_op.vmult(dst, src); // now equal to 2, 2, 0, 0, 0, 2 + * @endcode + * + * * A BlockLinearOperator can be sliced to a LinearOperator at any time. This * removes all information about the underlying block structure (because above * std::function objects are no longer available) - the linear