Reference documentation for deal.II version 8.4.2
sparse_decomposition.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2002 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__sparse_decomposition_h
17 #define dealii__sparse_decomposition_h
18 
19 #include <deal.II/base/config.h>
20 #include <deal.II/lac/sparse_matrix.h>
21 
22 #include <cmath>
23 
24 DEAL_II_NAMESPACE_OPEN
25 
108 template <typename number>
109 class SparseLUDecomposition : protected SparseMatrix<number>,
110  public virtual Subscriptor
111 {
112 protected:
120 
121 public:
126 
131  virtual ~SparseLUDecomposition () = 0;
132 
137  virtual void clear();
138 
143  {
144  public:
148  AdditionalData (const double strengthen_diagonal=0,
149  const unsigned int extra_off_diagonals=0,
150  const bool use_previous_sparsity=false,
152 
160 
171  unsigned int extra_off_diagonals;
172 
182 
194  };
195 
211  template <typename somenumber>
212  void initialize (const SparseMatrix<somenumber> &matrix,
213  const AdditionalData parameters);
214 
219  bool empty () const;
220 
226  size_type m () const;
227 
233  size_type n () const;
234 
242  template <class OutVector, class InVector>
243  void vmult_add (OutVector &dst,
244  const InVector &src) const;
245 
253  template <class OutVector, class InVector>
254  void Tvmult_add (OutVector &dst,
255  const InVector &src) const;
256 
261  virtual std::size_t memory_consumption () const;
262 
271  DeclException1 (ExcInvalidStrengthening,
272  double,
273  << "The strengthening parameter " << arg1
274  << " is not greater or equal than zero!");
276 protected:
281  template<typename somenumber>
282  void copy_from (const SparseMatrix<somenumber> &matrix);
283 
290  virtual void strengthen_diagonal_impl ();
291 
300  virtual number get_strengthen_diagonal(const number rowsum, const size_type row) const;
301 
306 
312  std::vector<const size_type *> prebuilt_lower_bound;
313 
317  void prebuild_lower_bound ();
318 
319 private:
320 
331 };
332 
334 //---------------------------------------------------------------------------
335 
336 #ifndef DOXYGEN
337 
338 template <typename number>
339 inline number
341 get_strengthen_diagonal(const number /*rowsum*/,
342  const size_type /*row*/) const
343 {
344  return strengthen_diagonal;
345 }
346 
347 
348 
349 template <typename number>
350 inline bool
352 {
354 }
355 
356 
357 template <typename number>
360 {
361  return SparseMatrix<number>::m();
362 }
363 
364 
365 template <typename number>
368 {
369  return SparseMatrix<number>::n();
370 }
371 
372 // Note: This function is required for full compatibility with
373 // the LinearOperator class. ::MatrixInterfaceWithVmultAdd
374 // picks up the vmult_add function in the protected SparseMatrix
375 // base class.
376 template <typename number>
377 template <class OutVector, class InVector>
378 inline void
380  const InVector &src) const
381 {
382  OutVector tmp;
383  tmp.reinit(dst);
384  this->vmult(tmp, src);
385  dst += tmp;
386 }
387 
388 // Note: This function is required for full compatibility with
389 // the LinearOperator class. ::MatrixInterfaceWithVmultAdd
390 // picks up the vmult_add function in the protected SparseMatrix
391 // base class.
392 template <typename number>
393 template <class OutVector, class InVector>
394 inline void
396  const InVector &src) const
397 {
398  OutVector tmp;
399  tmp.reinit(dst);
400  this->Tvmult(tmp, src);
401  dst += tmp;
402 }
403 
404 //---------------------------------------------------------------------------
405 
406 
407 template <typename number>
409  const double strengthen_diag,
410  const unsigned int extra_off_diag,
411  const bool use_prev_sparsity,
412  const SparsityPattern *use_this_spars):
413  strengthen_diagonal(strengthen_diag),
414  extra_off_diagonals(extra_off_diag),
415  use_previous_sparsity(use_prev_sparsity),
416  use_this_sparsity(use_this_spars)
417 {}
418 
419 
420 #endif // DOXYGEN
421 
422 DEAL_II_NAMESPACE_CLOSE
423 
424 #endif // dealii__sparse_decomposition_h
SparseMatrix< number >::size_type size_type
void vmult_add(OutVector &dst, const InVector &src) const
bool empty() const
void copy_from(const SparseMatrix< somenumber > &matrix)
SparsityPattern * own_sparsity
size_type n() const
size_type n() const
virtual ~SparseLUDecomposition()=0
void vmult(OutVector &dst, const InVector &src) const
std::vector< const size_type * > prebuilt_lower_bound
DeclException1(ExcInvalidStrengthening, double,<< "The strengthening parameter "<< arg1<< " is not greater or equal than zero!")
virtual void clear()
void Tvmult_add(OutVector &dst, const InVector &src) const
size_type m() const
AdditionalData(const double strengthen_diagonal=0, const unsigned int extra_off_diagonals=0, const bool use_previous_sparsity=false, const SparsityPattern *use_this_sparsity=0)
types::global_dof_index size_type
virtual std::size_t memory_consumption() const
virtual void strengthen_diagonal_impl()
virtual number get_strengthen_diagonal(const number rowsum, const size_type row) const
void initialize(const SparseMatrix< somenumber > &matrix, const AdditionalData parameters)
size_type m() const
void Tvmult(OutVector &dst, const InVector &src) const