]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
new preconditioner PreconditionUMFPACK
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 May 2005 05:59:19 +0000 (05:59 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 May 2005 05:59:19 +0000 (05:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@10611 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/sparse_direct.h
deal.II/lac/source/sparse_direct.cc

index 1489fe698a79b87f5b1e898cd0e14b5fbf3f8a20..80a2a44e6dd495585cd1156abc5ca7a059b27b30 100644 (file)
@@ -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<double> 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<double> &matrix,
+                   const AdditionalData = AdditionalData());
+    
+                                    /**
+                                     * Preconditioner interface
+                                     * function. Given the source
+                                     * vector, returns the
+                                     * approximated solution of <i>Ax
+                                     * = b</i>.
+                                     */
+    void vmult (Vector<double>&, const Vector<double>&) const;
+
+                                    /**
+                                     * Not implemented but necessary
+                                     * for compiling.
+                                     */
+    void Tvmult (Vector<double>&, const Vector<double>&) const;
+    
+                                    /**
+                                     * Same as vmult(), but adding to
+                                     * the previous solution. Not
+                                     * implemented yet.
+                                     */
+    void vmult_add (Vector<double>&, const Vector<double>&) const;
+
+                                    /**
+                                     * Not implemented but necessary
+                                     * for compiling.
+                                     */
+    void Tvmult_add (Vector<double>&, const Vector<double>&) const;
 };
 
+
+
 /*@}*/
 
 
+
 #endif
index cc6ddc22bf2c0ad2013df011db8a5403c9dc1151..70304c1300cc5d472567a97b7de85fa84b171694 100644 (file)
@@ -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<double> &matrix)
@@ -1844,9 +1843,93 @@ SparseDirectUMFPACK::solve (const SparseMatrix<double> &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<double> &)
+{
+  Assert(false, ExcNeedsUMFPack());
+}
+
+void
+SparseDirectUMFPACK::solve (Vector<double> &) const
+{
+  Assert(false, ExcNeedsUMFPack());
+}
+
+void
+SparseDirectUMFPACK::solve (const SparseMatrix<double> &,
+                            Vector<double>             &)
+{
+  Assert(false, ExcNeedsUMFPack());
+}
+
+
 #endif
 
 
+void
+PreconditionUMFPACK::initialize (const SparseMatrix<double>& M,
+                                const AdditionalData)
+{
+  this->factorize(M);
+}
+
+
+void
+PreconditionUMFPACK::vmult (
+  Vector<double>&       dst,
+  const Vector<double>& src) const
+{
+  dst = src;
+  this->solve(dst);
+}
+
+
+void
+PreconditionUMFPACK::Tvmult (
+  Vector<double>&,
+  const Vector<double>&) const
+{
+  Assert(false, ExcNotImplemented());
+}
+
+
+void
+PreconditionUMFPACK::vmult_add (
+  Vector<double>&,
+  const Vector<double>&) const
+{
+  Assert(false, ExcNotImplemented());
+}
+
+
+void
+PreconditionUMFPACK::Tvmult_add (
+  Vector<double>&,
+  const Vector<double>&) const
+{
+  Assert(false, ExcNotImplemented());
+}
+
+
 // explicit instantiations
 template
 void

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.