16#ifndef dealii_precondition_block_base_h
17#define dealii_precondition_block_base_h
36template <
typename number>
38template <
typename number>
57template <
typename number>
148 template <
typename number2>
157 template <
typename number2>
302template <
typename number>
306 , n_diagonal_blocks(0)
307 , var_store_diagonals(store)
308 , var_same_diagonal(false)
309 , var_inverses_ready(false)
313template <
typename number>
317 if (var_inverse_full.size() != 0)
318 var_inverse_full.erase(var_inverse_full.begin(), var_inverse_full.end());
319 if (var_inverse_householder.size() != 0)
320 var_inverse_householder.erase(var_inverse_householder.begin(),
321 var_inverse_householder.end());
322 if (var_inverse_svd.size() != 0)
323 var_inverse_svd.erase(var_inverse_svd.begin(), var_inverse_svd.end());
324 if (var_diagonal.size() != 0)
325 var_diagonal.erase(var_diagonal.begin(), var_diagonal.end());
326 var_same_diagonal =
false;
327 var_inverses_ready =
false;
328 n_diagonal_blocks = 0;
331template <
typename number>
339 var_same_diagonal = compress;
340 var_inverses_ready =
false;
341 n_diagonal_blocks = n;
348 var_inverse_full.resize(1);
349 var_inverse_full[0].reinit(b, b);
352 var_inverse_householder.resize(1);
355 var_inverse_svd.resize(1);
356 var_inverse_svd[0].reinit(b, b);
362 if (store_diagonals())
364 var_diagonal.resize(1);
365 var_diagonal[0].reinit(b, b);
378 if (store_diagonals())
381 var_diagonal.swap(tmp);
389 var_inverse_full.swap(tmp);
393 var_inverse_householder.resize(n);
397 std::vector<LAPACKFullMatrix<number>> tmp(
399 var_inverse_svd.swap(tmp);
409template <
typename number>
413 return n_diagonal_blocks;
416template <
typename number>
417template <
typename number2>
423 const size_type ii = same_diagonal() ? 0U : i;
429 var_inverse_full[ii].vmult(dst, src);
433 var_inverse_householder[ii].vmult(dst, src);
437 var_inverse_svd[ii].vmult(dst, src);
445template <
typename number>
446template <
typename number2>
452 const size_type ii = same_diagonal() ? 0U : i;
458 var_inverse_full[ii].Tvmult(dst, src);
462 var_inverse_householder[ii].Tvmult(dst, src);
466 var_inverse_svd[ii].Tvmult(dst, src);
474template <
typename number>
479 return var_inverse_full[0];
482 return var_inverse_full[i];
486template <
typename number>
491 return var_inverse_householder[0];
494 return var_inverse_householder[i];
498template <
typename number>
503 return var_inverse_svd[0];
506 return var_inverse_svd[i];
510template <
typename number>
514 Assert(store_diagonals(), ExcDiagonalsNotStored());
517 return var_diagonal[0];
520 return var_diagonal[i];
524template <
typename number>
528 Assert(var_inverse_full.size() != 0, ExcInverseNotAvailable());
531 return var_inverse_full[0];
534 return var_inverse_full[i];
538template <
typename number>
542 Assert(var_inverse_householder.size() != 0, ExcInverseNotAvailable());
545 return var_inverse_householder[0];
548 return var_inverse_householder[i];
552template <
typename number>
556 Assert(var_inverse_svd.size() != 0, ExcInverseNotAvailable());
559 return var_inverse_svd[0];
562 return var_inverse_svd[i];
566template <
typename number>
570 Assert(store_diagonals(), ExcDiagonalsNotStored());
573 return var_diagonal[0];
576 return var_diagonal[i];
580template <
typename number>
584 return var_same_diagonal;
588template <
typename number>
592 return var_store_diagonals;
596template <
typename number>
600 var_inverses_ready = x;
604template <
typename number>
608 return var_inverses_ready;
612template <
typename number>
616 deallog <<
"PreconditionBlockBase: " << size() <<
" blocks; ";
618 if (inversion == svd)
620 unsigned int kermin = 100000000, kermax = 0;
621 double sigmin = 1.e300, sigmax = -1.e300;
622 double kappamin = 1.e300, kappamax = -1.e300;
628 while (k <= matrix.n_cols() &&
629 matrix.singular_value(matrix.n_cols() - k) == 0)
631 const double s0 = matrix.singular_value(0);
632 const double sm = matrix.singular_value(matrix.n_cols() - k);
633 const double co = sm / s0;
648 deallog <<
"dim ker [" << kermin <<
':' << kermax <<
"] sigma [" << sigmin
649 <<
':' << sigmax <<
"] kappa [" << kappamin <<
':' << kappamax
652 else if (inversion == householder)
654 else if (inversion == gauss_jordan)
663template <
typename number>
667 std::size_t mem =
sizeof(*this);
668 for (
size_type i = 0; i < var_inverse_full.size(); ++i)
670 for (
size_type i = 0; i < var_diagonal.size(); ++i)
bool same_diagonal() const
std::vector< FullMatrix< number > > var_diagonal
unsigned int n_diagonal_blocks
std::size_t memory_consumption() const
std::vector< LAPACKFullMatrix< number > > var_inverse_svd
void inverses_computed(bool are_they)
void reinit(unsigned int nblocks, size_type blocksize, bool compress, Inversion method=gauss_jordan)
void inverse_vmult(size_type i, Vector< number2 > &dst, const Vector< number2 > &src) const
void log_statistics() const
PreconditionBlockBase(bool store_diagonals=false, Inversion method=gauss_jordan)
Householder< number > & inverse_householder(size_type i)
std::vector< FullMatrix< number > > var_inverse_full
bool inverses_ready() const
unsigned int size() const
const FullMatrix< number > & diagonal(size_type i) const
std::vector< Householder< number > > var_inverse_householder
FullMatrix< number > & inverse(size_type i)
FullMatrix< number > & diagonal(size_type i)
bool store_diagonals() const
const Householder< number > & inverse_householder(size_type i) const
const FullMatrix< number > & inverse(size_type i) const
void inverse_Tvmult(size_type i, Vector< number2 > &dst, const Vector< number2 > &src) const
LAPACKFullMatrix< number > & inverse_svd(size_type i)
const LAPACKFullMatrix< number > & inverse_svd(size_type i) const
~PreconditionBlockBase()=default
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException0(Exception0)
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcDiagonalsNotStored()
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInverseNotAvailable()
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
unsigned int global_dof_index