Reference documentation for deal.II version 9.1.0-pre
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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_sparse_decomposition_h
17 #define dealii_sparse_decomposition_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/lac/sparse_matrix.h>
22 
23 #include <cmath>
24 
25 DEAL_II_NAMESPACE_OPEN
26 
109 template <typename number>
110 class SparseLUDecomposition : protected SparseMatrix<number>,
111  public virtual Subscriptor
112 {
113 protected:
121 
122 public:
127 
132  virtual ~SparseLUDecomposition() override = 0;
133 
138  virtual void
139  clear() override;
140 
145  {
146  public:
150  AdditionalData(const double strengthen_diagonal = 0,
151  const unsigned int extra_off_diagonals = 0,
152  const bool use_previous_sparsity = false,
153  const SparsityPattern *use_this_sparsity = nullptr);
154 
162 
173  unsigned int extra_off_diagonals;
174 
184 
196  };
197 
213  template <typename somenumber>
214  void
215  initialize(const SparseMatrix<somenumber> &matrix,
216  const AdditionalData parameters);
217 
222  bool
223  empty() const;
224 
230  size_type
231  m() const;
232 
238  size_type
239  n() const;
240 
248  template <class OutVector, class InVector>
249  void
250  vmult_add(OutVector &dst, const InVector &src) const;
251 
259  template <class OutVector, class InVector>
260  void
261  Tvmult_add(OutVector &dst, const InVector &src) const;
262 
267  virtual std::size_t
268  memory_consumption() const;
269 
279  double,
280  << "The strengthening parameter " << arg1
281  << " is not greater or equal than zero!");
283 protected:
288  template <typename somenumber>
289  void
290  copy_from(const SparseMatrix<somenumber> &matrix);
291 
298  virtual void
300 
310  virtual number
311  get_strengthen_diagonal(const number rowsum, const size_type row) const;
312 
317 
323  std::vector<const size_type *> prebuilt_lower_bound;
324 
328  void
330 
331 private:
342 };
343 
345 //---------------------------------------------------------------------------
346 
347 #ifndef DOXYGEN
348 
349 template <typename number>
350 inline number
352  const number /*rowsum*/,
353  const size_type /*row*/) const
354 {
355  return strengthen_diagonal;
356 }
357 
358 
359 
360 template <typename number>
361 inline bool
363 {
365 }
366 
367 
368 template <typename number>
371 {
372  return SparseMatrix<number>::m();
373 }
374 
375 
376 template <typename number>
379 {
380  return SparseMatrix<number>::n();
381 }
382 
383 // Note: This function is required for full compatibility with
384 // the LinearOperator class. ::MatrixInterfaceWithVmultAdd
385 // picks up the vmult_add function in the protected SparseMatrix
386 // base class.
387 template <typename number>
388 template <class OutVector, class InVector>
389 inline void
391  const InVector &src) const
392 {
393  OutVector tmp;
394  tmp.reinit(dst);
395  this->vmult(tmp, src);
396  dst += tmp;
397 }
398 
399 // Note: This function is required for full compatibility with
400 // the LinearOperator class. ::MatrixInterfaceWithVmultAdd
401 // picks up the vmult_add function in the protected SparseMatrix
402 // base class.
403 template <typename number>
404 template <class OutVector, class InVector>
405 inline void
407  const InVector &src) const
408 {
409  OutVector tmp;
410  tmp.reinit(dst);
411  this->Tvmult(tmp, src);
412  dst += tmp;
413 }
414 
415 //---------------------------------------------------------------------------
416 
417 
418 template <typename number>
420  const double strengthen_diag,
421  const unsigned int extra_off_diag,
422  const bool use_prev_sparsity,
423  const SparsityPattern *use_this_spars)
424  : strengthen_diagonal(strengthen_diag)
425  , extra_off_diagonals(extra_off_diag)
426  , use_previous_sparsity(use_prev_sparsity)
427  , use_this_sparsity(use_this_spars)
428 {}
429 
430 
431 #endif // DOXYGEN
432 
433 DEAL_II_NAMESPACE_CLOSE
434 
435 #endif // dealii_sparse_decomposition_h
void Tvmult(OutVector &dst, const InVector &src) const
void vmult(OutVector &dst, const InVector &src) 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=nullptr)
size_type m() const
bool empty() const
size_type n() const
void Tvmult_add(OutVector &dst, const InVector &src) const
bool empty() const
static::ExceptionBase & ExcInvalidStrengthening(double arg1)
void copy_from(const SparseMatrix< somenumber > &matrix)
SparsityPattern * own_sparsity
size_type n() const
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:408
virtual std::size_t memory_consumption() const
virtual void clear() override
typename SparseMatrix< number >::size_type size_type
void vmult_add(OutVector &dst, const InVector &src) const
virtual ~SparseLUDecomposition() override=0
std::vector< const size_type * > prebuilt_lower_bound
size_type m() const
virtual number get_strengthen_diagonal(const number rowsum, const size_type row) const
types::global_dof_index size_type
virtual void strengthen_diagonal_impl()
void initialize(const SparseMatrix< somenumber > &matrix, const AdditionalData parameters)