Reference documentation for deal.II version 9.0.0
sparse_decomposition.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2002 - 2017 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,
151  const SparsityPattern *use_this_sparsity=nullptr);
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 
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 
301  virtual number get_strengthen_diagonal(const number rowsum, const size_type row) const;
302 
307 
313  std::vector<const size_type *> prebuilt_lower_bound;
314 
318  void prebuild_lower_bound ();
319 
320 private:
321 
332 };
333 
335 //---------------------------------------------------------------------------
336 
337 #ifndef DOXYGEN
338 
339 template <typename number>
340 inline number
342 get_strengthen_diagonal(const number /*rowsum*/,
343  const size_type /*row*/) const
344 {
345  return strengthen_diagonal;
346 }
347 
348 
349 
350 template <typename number>
351 inline bool
353 {
355 }
356 
357 
358 template <typename number>
361 {
362  return SparseMatrix<number>::m();
363 }
364 
365 
366 template <typename number>
369 {
370  return SparseMatrix<number>::n();
371 }
372 
373 // Note: This function is required for full compatibility with
374 // the LinearOperator class. ::MatrixInterfaceWithVmultAdd
375 // picks up the vmult_add function in the protected SparseMatrix
376 // base class.
377 template <typename number>
378 template <class OutVector, class InVector>
379 inline void
381  const InVector &src) const
382 {
383  OutVector tmp;
384  tmp.reinit(dst);
385  this->vmult(tmp, src);
386  dst += tmp;
387 }
388 
389 // Note: This function is required for full compatibility with
390 // the LinearOperator class. ::MatrixInterfaceWithVmultAdd
391 // picks up the vmult_add function in the protected SparseMatrix
392 // base class.
393 template <typename number>
394 template <class OutVector, class InVector>
395 inline void
397  const InVector &src) const
398 {
399  OutVector tmp;
400  tmp.reinit(dst);
401  this->Tvmult(tmp, src);
402  dst += tmp;
403 }
404 
405 //---------------------------------------------------------------------------
406 
407 
408 template <typename number>
410 AdditionalData::AdditionalData (const double strengthen_diag,
411  const unsigned int extra_off_diag,
412  const bool use_prev_sparsity,
413  const SparsityPattern *use_this_spars)
414  :
415  strengthen_diagonal(strengthen_diag),
416  extra_off_diagonals(extra_off_diag),
417  use_previous_sparsity(use_prev_sparsity),
418  use_this_sparsity(use_this_spars)
419 {}
420 
421 
422 #endif // DOXYGEN
423 
424 DEAL_II_NAMESPACE_CLOSE
425 
426 #endif // dealii_sparse_decomposition_h
SparseMatrix< number >::size_type size_type
AdditionalData(const double strengthen_diagonal=0, const unsigned int extra_off_diagonals=0, const bool use_previous_sparsity=false, const SparsityPattern *use_this_sparsity=nullptr)
void vmult_add(OutVector &dst, const InVector &src) const
static ::ExceptionBase & ExcInvalidStrengthening(double arg1)
bool empty() const
void copy_from(const SparseMatrix< somenumber > &matrix)
SparsityPattern * own_sparsity
size_type n() const
size_type n() const
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:346
virtual ~SparseLUDecomposition()=0
std::vector< const size_type * > prebuilt_lower_bound
virtual void clear()
void Tvmult_add(OutVector &dst, const InVector &src) const
size_type m() const
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