17 #include <deal.II/lac/block_matrix_array.h> 18 #include <deal.II/lac/vector.h> 19 #include <deal.II/lac/block_vector.h> 20 #include <deal.II/lac/trilinos_block_vector.h> 21 #include <deal.II/lac/trilinos_parallel_block_vector.h> 23 #include <deal.II/lac/petsc_block_vector.h> 24 #include <deal.II/lac/petsc_parallel_block_vector.h> 26 DEAL_II_NAMESPACE_OPEN
29 template <
typename number,
typename BlockVectorType>
44 template <
typename number,
typename BlockVectorType>
52 template <
typename number,
typename BlockVectorType>
60 template <
typename number,
typename BlockVectorType>
62 (
const unsigned int n_block_rows,
63 const unsigned int n_block_cols)
64 : block_rows (n_block_rows),
65 block_cols (n_block_cols)
69 template <
typename number,
typename BlockVectorType>
72 (
const unsigned int n_block_rows,
73 const unsigned int n_block_cols)
75 block_rows = n_block_rows;
76 block_cols = n_block_cols;
81 template <
typename number,
typename BlockVectorType>
84 (
const unsigned int n_block_rows,
85 const unsigned int n_block_cols)
88 block_rows = n_block_rows;
89 block_cols = n_block_cols;
94 template <
typename number,
typename BlockVectorType>
102 template <
typename number,
typename BlockVectorType>
105 const BlockVectorType &src)
const 108 Assert (dst.n_blocks() == block_rows,
110 Assert (src.n_blocks() == block_cols,
114 typename BlockVectorType::BlockType &aux = *p_aux;
116 typename std::vector<Entry>::const_iterator m = entries.begin();
117 typename std::vector<Entry>::const_iterator end = entries.end();
119 for (; m != end ; ++m)
121 aux.reinit(dst.block(m->row));
123 m->matrix->Tvmult(aux, src.block(m->col));
125 m->matrix->vmult(aux, src.block(m->col));
126 dst.block(m->row).add (m->prefix, aux);
133 template <
typename number,
typename BlockVectorType>
136 const BlockVectorType &src)
const 139 vmult_add (dst, src);
145 template <
typename number,
typename BlockVectorType>
148 const BlockVectorType &src)
const 151 Assert (dst.n_blocks() == block_cols,
153 Assert (src.n_blocks() == block_rows,
156 typename std::vector<Entry>::const_iterator m = entries.begin();
157 typename std::vector<Entry>::const_iterator end = entries.end();
160 typename BlockVectorType::BlockType &aux = *p_aux;
162 for (; m != end ; ++m)
164 aux.reinit(dst.block(m->col));
166 m->matrix->vmult(aux, src.block(m->row));
168 m->matrix->Tvmult(aux, src.block(m->row));
169 dst.block(m->col).add (m->prefix, aux);
175 template <
typename number,
typename BlockVectorType>
178 const BlockVectorType &src)
const 181 Tvmult_add (dst, src);
187 template <
typename number,
typename BlockVectorType>
190 (
const BlockVectorType &u,
191 const BlockVectorType &v)
const 194 Assert (u.n_blocks() == block_rows,
196 Assert (v.n_blocks() == block_cols,
200 typename BlockVectorType::BlockType &aux = *p_aux;
202 typename std::vector<Entry>::const_iterator m;
203 typename std::vector<Entry>::const_iterator end = entries.end();
207 for (
unsigned int i=0; i<block_rows; ++i)
209 aux.reinit(u.block(i));
210 for (m = entries.begin(); m != end ; ++m)
215 m->matrix->Tvmult_add(aux, v.block(m->col));
217 m->matrix->vmult(aux, v.block(m->col));
219 result += u.block(i)*aux;
227 template <
typename number,
typename BlockVectorType>
230 (
const BlockVectorType &u)
const 232 return matrix_scalar_product(u,u);
237 template <
typename number,
typename BlockVectorType>
246 template <
typename number,
typename BlockVectorType>
257 template <
typename number,
typename BlockVectorType>
264 template <
typename number,
typename BlockVectorType>
266 (
const unsigned int block_rows)
273 template <
typename number,
typename BlockVectorType>
276 (
const unsigned int n)
282 template <
typename number,
typename BlockVectorType>
285 (BlockVectorType &dst,
289 typename std::vector<typename BlockMatrixArray<number,BlockVectorType>::Entry>::const_iterator
290 m = this->entries.begin();
291 typename std::vector<typename BlockMatrixArray<number,BlockVectorType>::Entry>::const_iterator
292 end = this->entries.end();
293 std::vector<typename std::vector<typename BlockMatrixArray<number,BlockVectorType>::Entry>::const_iterator>
297 typename BlockVectorType::BlockType &aux = *p_aux;
299 aux.reinit(dst.block(row_num),
true);
303 for (; m != end ; ++m)
314 if (((j > i) && !backward) || ((j < i) && backward))
318 diagonals.push_back(m);
323 m->matrix->Tvmult(aux, dst.block(j));
325 m->matrix->vmult(aux, dst.block(j));
326 dst.block(i).add (-1.0 * m->prefix, aux);
329 Assert (diagonals.size() != 0, ExcNoDiagonal(row_num));
334 if (diagonals.size() == 1)
337 diagonals[0]->matrix->Tvmult(aux, dst.block(row_num));
339 diagonals[0]->matrix->vmult(aux, dst.block(row_num));
340 dst.block(row_num).equ (diagonals[0]->prefix, aux);
345 for (
size_type i=0; i<diagonals.size(); ++i)
353 m->matrix->Tvmult_add(aux, dst.block(row_num));
355 m->matrix->vmult_add(aux, dst.block(row_num));
358 dst.block(row_num) = aux;
364 template <
typename number,
typename BlockVectorType>
367 (BlockVectorType &dst,
368 const BlockVectorType &src)
const 370 Assert (dst.n_blocks() == n_block_rows(),
372 Assert (src.n_blocks() == n_block_cols(),
383 template <
typename number,
typename BlockVectorType>
386 (BlockVectorType &dst,
387 const BlockVectorType &src)
const 389 Assert (dst.n_blocks() == n_block_rows(),
391 Assert (src.n_blocks() == n_block_cols(),
398 for (
unsigned int i=n_block_rows(); i>0;)
403 for (
unsigned int i=0; i<n_block_rows(); ++i)
409 template <
typename number,
typename BlockVectorType>
413 const BlockVectorType &)
const 419 template <
typename number,
typename BlockVectorType>
423 const BlockVectorType &)
const 433 #ifdef DEAL_II_WITH_TRILINOS 440 #ifdef DEAL_II_WITH_PETSC 441 #ifdef PETSC_USE_COMPLEX 454 DEAL_II_NAMESPACE_CLOSE
number matrix_norm_square(const BlockVectorType &u) const
types::global_dof_index size_type
void Tvmult(BlockVectorType &dst, const BlockVectorType &src) const
void vmult(BlockVectorType &dst, const BlockVectorType &src) const
void vmult_add(BlockVectorType &dst, const BlockVectorType &src) const
unsigned int n_block_cols() const
void initialize(const unsigned int n_block_rows, const unsigned int n_block_cols)
#define Assert(cond, exc)
void vmult_add(BlockVectorType &dst, const BlockVectorType &src) const
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
unsigned int n_block_rows() const
void Tvmult(BlockVectorType &dst, const BlockVectorType &src) const
Entry(const MatrixType &matrix, size_type row, size_type col, number prefix, bool transpose)
void reinit(const unsigned int n_block_rows, const unsigned int n_block_cols)
BlockTrianglePrecondition()
void Tvmult_add(BlockVectorType &dst, const BlockVectorType &src) const
void Tvmult_add(BlockVectorType &dst, const BlockVectorType &src) const
PointerMatrixBase< typename BlockVectorType::BlockType > * matrix
static ::ExceptionBase & ExcNotImplemented()
void reinit(const unsigned int n_block_rows)
void vmult(BlockVectorType &dst, const BlockVectorType &src) const
void do_row(BlockVectorType &dst, size_type row_num) const
number matrix_scalar_product(const BlockVectorType &u, const BlockVectorType &v) const