From: guido Date: Tue, 3 May 2005 05:59:19 +0000 (+0000) Subject: new preconditioner PreconditionUMFPACK X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9abf413bbb524f54e72f3bfd40cd3a0bdfe0b257;p=dealii-svn.git new preconditioner PreconditionUMFPACK git-svn-id: https://svn.dealii.org/trunk@10611 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/sparse_direct.h b/deal.II/lac/include/lac/sparse_direct.h index 1489fe698a..80a2a44e6d 100644 --- a/deal.II/lac/include/lac/sparse_direct.h +++ b/deal.II/lac/include/lac/sparse_direct.h @@ -1020,10 +1020,8 @@ class SparseDirectMA47 : public Subscriptor * * @author Wolfgang Bangerth, 2004 */ -class SparseDirectUMFPACK : public Subscriptor +class SparseDirectUMFPACK : public virtual Subscriptor { -#ifdef HAVE_UMFPACK - public: /** * Constructor. See the @@ -1152,11 +1150,66 @@ class SparseDirectUMFPACK : public Subscriptor * routines. */ std::vector control; +}; -#endif + +/** + * Wrapper for SparseDirectUMFPACK, implementing the usual + * preconditioner interface with functions initialize() and vmult(). + */ +class PreconditionUMFPACK : public virtual Subscriptor, + private SparseDirectUMFPACK +{ + public: + /** + * Dummy class needed for the + * usual initalization interface + * of preconditioners. + */ + class AdditionalData + {}; + + + /** + * Initialize memory and call + * SparseDirectUMFPACK::factorize. + */ + void initialize(const SparseMatrix &matrix, + const AdditionalData = AdditionalData()); + + /** + * Preconditioner interface + * function. Given the source + * vector, returns the + * approximated solution of Ax + * = b. + */ + void vmult (Vector&, const Vector&) const; + + /** + * Not implemented but necessary + * for compiling. + */ + void Tvmult (Vector&, const Vector&) const; + + /** + * Same as vmult(), but adding to + * the previous solution. Not + * implemented yet. + */ + void vmult_add (Vector&, const Vector&) const; + + /** + * Not implemented but necessary + * for compiling. + */ + void Tvmult_add (Vector&, const Vector&) const; }; + + /*@}*/ + #endif diff --git a/deal.II/lac/source/sparse_direct.cc b/deal.II/lac/source/sparse_direct.cc index cc6ddc22bf..70304c1300 100644 --- a/deal.II/lac/source/sparse_direct.cc +++ b/deal.II/lac/source/sparse_direct.cc @@ -1617,6 +1617,18 @@ call_ma47cd (const unsigned int *n_rows, //scalar +SparseDirectUMFPACK::~SparseDirectUMFPACK () +{ + clear (); +} + + +void +SparseDirectUMFPACK:: +initialize (const SparsityPattern &) +{} + + #ifdef HAVE_UMFPACK SparseDirectUMFPACK::SparseDirectUMFPACK () @@ -1630,12 +1642,6 @@ SparseDirectUMFPACK::SparseDirectUMFPACK () -SparseDirectUMFPACK::~SparseDirectUMFPACK () -{ - clear (); -} - - void SparseDirectUMFPACK::clear () { @@ -1673,13 +1679,6 @@ SparseDirectUMFPACK::clear () -void -SparseDirectUMFPACK:: -initialize (const SparsityPattern &) -{} - - - void SparseDirectUMFPACK:: factorize (const SparseMatrix &matrix) @@ -1844,9 +1843,93 @@ SparseDirectUMFPACK::solve (const SparseMatrix &matrix, solve (rhs_and_solution); } + +#else + + +SparseDirectUMFPACK::SparseDirectUMFPACK () + : + symbolic_decomposition (0), + numeric_decomposition (0), + control (UMFPACK_CONTROL) +{ + Assert(false, ExcNeedsUMFPack()); +} + + +void +SparseDirectUMFPACK::clear () +{ + Assert(false, ExcNeedsUMFPack()); +} + +void SparseDirectUMFPACK::factorize (const SparseMatrix &) +{ + Assert(false, ExcNeedsUMFPack()); +} + +void +SparseDirectUMFPACK::solve (Vector &) const +{ + Assert(false, ExcNeedsUMFPack()); +} + +void +SparseDirectUMFPACK::solve (const SparseMatrix &, + Vector &) +{ + Assert(false, ExcNeedsUMFPack()); +} + + #endif +void +PreconditionUMFPACK::initialize (const SparseMatrix& M, + const AdditionalData) +{ + this->factorize(M); +} + + +void +PreconditionUMFPACK::vmult ( + Vector& dst, + const Vector& src) const +{ + dst = src; + this->solve(dst); +} + + +void +PreconditionUMFPACK::Tvmult ( + Vector&, + const Vector&) const +{ + Assert(false, ExcNotImplemented()); +} + + +void +PreconditionUMFPACK::vmult_add ( + Vector&, + const Vector&) const +{ + Assert(false, ExcNotImplemented()); +} + + +void +PreconditionUMFPACK::Tvmult_add ( + Vector&, + const Vector&) const +{ + Assert(false, ExcNotImplemented()); +} + + // explicit instantiations template void