]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add more functions to paralution_vector, paralution_solver, and paralution_solver...
authorturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 19 Dec 2013 22:54:11 +0000 (22:54 +0000)
committerturcksin <turcksin@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 19 Dec 2013 22:54:11 +0000 (22:54 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_paralution@32066 0785d39b-7218-0410-832d-ea1e28bc413d

18 files changed:
deal.II/include/deal.II/lac/paralution_solver.h
deal.II/include/deal.II/lac/paralution_sparse_matrix.h
deal.II/include/deal.II/lac/paralution_vector.h
deal.II/include/deal.II/lac/vector.h
deal.II/include/deal.II/numerics/vector_tools.templates.h
deal.II/source/fe/fe_tools_interpolate.cc
deal.II/source/fe/fe_values.cc
deal.II/source/lac/paralution_solver.cc
deal.II/source/lac/solver.cc
deal.II/source/lac/vector_memory.cc
deal.II/source/multigrid/multigrid.cc
deal.II/source/numerics/derivative_approximation.cc
deal.II/source/numerics/dof_output_operator.cc
deal.II/source/numerics/error_estimator.cc
deal.II/source/numerics/error_estimator_1d.cc
deal.II/source/numerics/fe_field_function.cc
deal.II/source/numerics/point_value_history.cc
deal.II/source/numerics/solution_transfer.cc

index ff52c026ac92dea7ab0483c4a7cbbef71593536b..1e559b2b6b787363eb6458894769834e76a863ee 100644 (file)
@@ -78,13 +78,15 @@ namespace ParalutionWrappers
     SolverCG (SolverControl &cn);
 
     /**
-     * Solve the linear system <tt>Ax=b</tt> using the CG solver of Paralution.
+     * Solve the linear system <tt>Ax=b</tt> using the CG solver of
+     * Paralution. If the flag @p move_to_accelerator is set to true, the
+     * solver is built on the accelerator.
      */
-    //TODO: add a flag to move to the accelerator
     template <typename Number>
     void solve (const SparseMatrix<Number> &A,
                 Vector<Number>             &x,
-                const Vector<Number>       &b);
+                const Vector<Number>       &b,
+                bool                        move_to_accelerator=false);
   };
 
 
@@ -103,12 +105,14 @@ namespace ParalutionWrappers
 
     /**
      * Solve the linear system <tt>Ax=b</tt> using the BiCGStab solver of
-     * Paralution.
+     * Paralution. If the flag @p move_to_accelerator is set to true, the
+     * solver is built on the accelerator.
      */
     template <typename Number>
     void solve (const SparseMatrix<Number> &A,
                 Vector<Number>             &x,
-                const Vector<Number>       &b);
+                const Vector<Number>       &b,
+                bool                        move_to_accelerator=false);
   };
 
 
@@ -146,12 +150,14 @@ namespace ParalutionWrappers
 
     /**
      * Solve the linear system <tt>Ax=b</tt> using the GMRES solver of
-     * Paralution.
+     * Paralution. If the flag @p move_to_accelerator is set to true, the
+     * solver is built on the accelerator.
      */
     template <typename Number>
     void solve (const SparseMatrix<Number> &A,
                 Vector<Number>             &x,
-                const Vector<Number>       &b);
+                const Vector<Number>       &b,
+                bool                        move_to_accelerator=false);
 
   private:
     /**
index 217d0a90a5b40a683115dcbdc402450814905619..ebc1e123084ba2eeb399234b681f649c5babc8d0 100644 (file)
@@ -54,9 +54,10 @@ namespace ParalutionWrappers
   {
   public :
     /**
-     * Declare type for container size.
+     * Declare some of the standard types used.
      */
-    typedef types::global_dof_index size_type;
+    typedef dealii::types::global_dof_index size_type;
+    typedef Number                          value_type;
 
     /**
      * @name 1: Constructors and initialization
@@ -304,8 +305,21 @@ namespace ParalutionWrappers
 
     //@}
     /**
-     * @name 4: Access to underlying Paralution data
+     * @name 4: Access to underlying Paralution data and move data to
+     * accelerator/host
      */
+    /**
+     * Move the SparseMatrix to the accelerator. This function should only be
+     * called after convert_to_paralution_csr.
+     */
+    void move_to_accelerator();
+
+    /**
+     * Move the SparseMatrix to the host. This function should only be called
+     * after convert_to_paralution_csr.
+     */
+    void move_to_host();
+
     /**
      * Return a constant reference to the underlying Paralution LocalMatrix
      * data.
@@ -319,6 +333,12 @@ namespace ParalutionWrappers
     //@}
 
   private :
+    /**
+     * This flag is true if local_matrix is used. It becomes true after
+     * convert_to_paralution_csr has been called.
+     */
+    bool is_local_matrix;
+
     /**
      * Underlying Paralution LocalMatrix<Number>.
      */
@@ -335,7 +355,10 @@ namespace ParalutionWrappers
 // ------------------- inline functions --------------
 
   template <typename Number>
-  inline SparseMatrix<Number>::SparseMatrix() {}
+  inline SparseMatrix<Number>::SparseMatrix()
+    :
+    is_local_matrix(false)
+  {}
 
 
 
@@ -360,6 +383,7 @@ namespace ParalutionWrappers
   {
     local_matrix.Clear();
     sparse_matrix.reinit(sparsity_pattern);
+    is_local_matrix = false;
   }
 
 
@@ -368,6 +392,7 @@ namespace ParalutionWrappers
   {
     local_matrix.clear();
     sparse_matrix.clear();
+    is_local_matrix = false;
   }
 
 
@@ -375,7 +400,7 @@ namespace ParalutionWrappers
   template <typename Number>
   inline typename SparseMatrix<Number>::size_type SparseMatrix<Number>::m() const
   {
-    return local_matrix.get_nrows();
+    return (is_local_matrix ? local_matrix.get_nrow() : sparse_matrix.m());
   }
 
 
@@ -383,7 +408,7 @@ namespace ParalutionWrappers
   template <typename Number>
   inline typename SparseMatrix<Number>::size_type SparseMatrix<Number>::n() const
   {
-    return local_matrix.get_ncols();
+    return (is_local_matrix ? local_matrix.get_ncol() : sparse_matrix.n());
   }
 
 
@@ -479,6 +504,22 @@ namespace ParalutionWrappers
 
 
 
+  template <typename Number>
+  inline void SparseMatrix<Number>::move_to_accelerator()
+  {
+    local_matrix.MoveToAccelerator();
+  }
+
+
+
+  template <typename Number>
+  inline void SparseMatrix<Number>::move_to_host()
+  {
+    local_matrix.MoveToHost();
+  }
+
+
+
   template <typename Number>
   inline paralution::LocalMatrix<Number> const &SparseMatrix<Number>::paralution_matrix() const
   {
index e743d8929cbd41dfbeb8cc65038ec694a3d0bf85..366c1ee724f9020100103ce5c56f7f2e10f0dbc7 100644 (file)
 #ifdef DEAL_II_WITH_PARALUTION
 
 #include <deal.II/base/exceptions.h>
+#include <deal.II/base/index_set.h>
 #include <deal.II/base/subscriptor.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/base/memory_consumption.h>
 
 #include "paralution.hpp"
 
@@ -57,19 +60,30 @@ namespace ParalutionWrappers
   {
   public :
     /**
-     * Declare some the standard types used in all containers. These types
+     * Declare some of the standard types used in all containers. These types
      * parallel those in the <tt>C</tt> standard libraries
      * <tt>vector<...></tt> class.
      */
     typedef dealii::types::global_dof_index size_type;
+    typedef Number                          value_type;
     typedef Number                         *iterator;
     typedef const Number                   *const_iterator;
 
+    /**
+     * A variable that indicates whether this vector supports distributed data
+     * storage. If true, then this vector also needs an appropriate compress()
+     * function that allows communicating recent set or add operations to
+     * individual elements to be communicated to other processors.
+     *
+     * For the current class, the variable equals false, since it does not
+     * support parallel data storage.
+     */
+    static const bool supports_distributed_data = false;
+
     /**
      * @name 1: Basic Object-handling
      */
     //@{
-
     /**
      * Default constructor that generates and empy (zero size) vector. The
      * function <tt>reinit()</tt> will have to give the vector the correct
@@ -114,6 +128,23 @@ namespace ParalutionWrappers
      */
     ~Vector();
 
+    /**
+     * This function does nothing but is there for compatibility with the
+     * @p PETScWrappers::Vector class.
+     *
+     * For the PETSC vector wrapper class, this function compresses the
+     * underlying representation of the PETSc object, i.e. flusehes the
+     * buffers of the vector obkect if it has any. This function is necessary
+     * after writing into a vector element-by-element and before anything else
+     * can be done on it.
+     *
+     * However, for the implementation of this class, it is immaterial and
+     * thus an empty function.
+     */
+    void compress (::dealii::VectorOperation::values operation
+                   =::dealii::VectorOperation::unknown) const;
+
+
     /**
      * Change the dimension of the vector to @p N. The vector is filled with
      * zeros.
@@ -160,11 +191,68 @@ namespace ParalutionWrappers
      */
     const_iterator end() const;
 
+    /**
+     * Set all components of the vector to the given number s.
+     */
+    Vector<Number>& operator= (const Number s);
+
+    /**
+     * Copy the given vector in the present one. Resize if necessary.
+     */
+    Vector<Number>& operator= (const Vector<Number> &v);
+
+    /**
+     * Mean value of the elements of this vector.
+     */
+    Number mean_value() const;
+
     /**
      * $l_2$-norm of the vector. The ssquare root of the sum of the squares of
      * the elements.
      */
     Number l2_norm() const;
+
+    /**
+     * Return true if the vector contains ghost elements. Since this not a
+     * distributed vector the method always returns false.
+     */
+    bool has_ghost_elements() const;
+
+    /**
+     * Returns true if the given global index is in the local range of this
+     * processor. Since this is not a distributed vector the method always
+     * returns true.
+     */
+    bool in_local_range (const size_type global_index) const;
+
+    /**
+     * Return an index set that describes wich elements of this vector are
+     * owned by the current processor. Note that this index set does not
+     * include elements this vector may store locally as ghost elements but
+     * that are in fact owned by another processor. As a consequence, the
+     * index sets returned returned on different processors if this is a
+     * distributed vector will form disjoint sets that add up to the the
+     * complete index set. Obviously, if a vector is created on only one
+     * processor, then the result would satisfy
+     * @code
+     *   vec.locally_owned_elements() == complete_index_set(vec.size())
+     * @endcode
+     *
+     * Since the current data type does not support parallel data storage
+     * across different processors, the returned index set is the complete
+     * index set.
+     */
+    IndexSet locally_owned_elements() const;
+
+    /**
+     * Move the Vector to the accelerator.
+     */
+    void move_to_accelerator();
+
+    /**
+     * Move the Vector to the host.
+     */
+    void move_to_host();
     //@}
 
     /**
@@ -196,6 +284,24 @@ namespace ParalutionWrappers
      */
     Number &operator[] (const size_type i);
 
+    /**
+     * A collective get operation: instead of getting individual elements of a
+     * vector, this function allows to get a whole set of elements at once.
+     * The indices of the elements to be read are stated in the first
+     * argument, the corresponding values are returned in the second.
+     */
+    void extract_subvector_to (const std::vector<size_type> &indices,
+                               std::vector<Number>          &values) const;
+
+    /**
+     * Just as the above, but with pointers. Useful in minimizing copying of
+     * the data around.
+     */
+    template <typename ForwardIterator, typename OutputIterator>
+    void extract_subvector_to (ForwardIterator       indices_begin,
+                               const ForwardIterator indices_end,
+                               OutputIterator        values_begin) const;
+
     /**
      * Return a constant reference to the underlying Paralution LocalVector
      * class.
@@ -223,17 +329,78 @@ namespace ParalutionWrappers
      */
     Vector<Number>& operator-= (const Vector<Number> &v);
 
+    /**
+     * A collective add operation: This function adds a whole set of values
+     * stored in @p values to the vector components specified by @p indices.
+     */
+    template <typename Number2>
+    void add (const std::vector<size_type> &indices,
+              const std::vector<Number2>   &values);
+
+    /**
+     * This is a second collective add operation. As a difference, this
+     * function takes a deal.II vector of values.
+     */
+    template <typename Number2>
+    void add (const std::vector<size_type>    &indices,
+              const ::dealii::Vector<Number2> &values);
+
+    /**
+     * Take an address where <tt>n_eleements</tt> are stored contiguously and
+     * add them into the vector. Handles all case which are not covered by the
+     * other two <tt>add()</tt> functions above.
+     */
+    template <typename Number2>
+    void add (const size_type n_elements,
+              const size_type *indices,
+              const Number2 *values);
+
     /**
      * Addition of @p s to all components. Note that @p s is a scalar and
      * not a vector.
      */
-    void add(const Number s);
+    void add (const Number s);
+
+    /**
+     * Simple vector addition, equal to the <tt>operator +=</tt>.
+     */
+    void add (const Vector<Number> &v);
 
     /**
      * Simple addition of a multiple of a vector, i.e. <tt>*this += a*V</tt>.
      */
-    void add(const Number          a,
-             const Vector<Number> &v);
+    void add (const Number a, const Vector<Number> &V);
+
+    /**
+     * Scaling and simple vector addition, i.e. <tt>*this += a*V + v*W</tt>.
+     */
+    void add (const Number a, const Vector<Number> &V,
+              const Number b, const Vector<Number> &W);
+
+    /**
+     * Scaling and simple vector addition, i.e. <tt>*this = s*(*this)+V</tt>.
+     */
+    void sadd (const Number s, const Vector<Number> &V);
+
+    /**
+     * Scaling and simple addition, i.e. <tt>*this = s*(*this)+a*V</tt>.
+     */
+    void sadd (const Number s, const Number a, const Vector<Number> &V);
+
+    /**
+     * Scaling and multiple addition.
+     * <tt>*this = s*(*this) + a*v + b*W</tt>.
+     */
+    void sadd (const Number s, const Number a, const Vector<Number> &V,
+               const Number b, const Vector<Number> &W);
+
+    /**
+     * Scaling and multiple addition.
+     * <tt>*this = s*(*this) + a*v + b*W + c*X</tt>.
+     */
+    void sadd (const Number s, const Number a, const Vector<Number> &V,
+               const Number v, const Vector<Number> &W, const Number c,
+               const Vector<Number> &X);
 
     /**
      * Scale each element of the vector by a constant value.
@@ -244,6 +411,35 @@ namespace ParalutionWrappers
      * Scale each element of the vector by the inverse of the given value.
      */
     Vector<Number>& operator/= (const Number factor);
+
+    /**
+     * Assignement <tt>*this = a*u</tt>.
+     */
+    void equ (const Number a, const Vector<Number> &u);
+
+    /**
+     * Assignement <tt>*this = a*u + b*v</tt>.
+     */
+    void equ (const Number a, const Vector<Number> &u,
+              const Number b, const Vector<Number> &v);
+
+    /**
+     * Assignement <tt>*this = a*u + b*v + c*w</tt>.
+     */
+    void equ (const Number a, const Vector<Number> &u,
+              const Number b, const Vector<Number> &v,
+              const Number c, const Vector<Number> &w);
+    //@}
+
+    /**
+     * @name 4: Mixed stuff
+     */
+    //@{
+    /**
+     * Determine an estimate for the memory consumption (in bytes) of this
+     * object.
+     */
+    std::size_t memory_consumption () const;
     //@}
 
   private :
@@ -285,7 +481,9 @@ namespace ParalutionWrappers
     local_vector.Clear();
   }
 
-
+  template <typename Number>
+  inline void Vector<Number>:: compress(::dealii::VectorOperation::values operation) const
+  {}
 
   template <typename Number>
   void Vector<Number>::reinit(const size_type n)
@@ -345,6 +543,42 @@ namespace ParalutionWrappers
 
 
 
+  template <typename Number>
+  inline Vector<Number>& Vector<Number>::operator= (const Number s)
+  {
+    Assert(numbers::is_finite(s),ExcNumberNotFinite());
+
+    local_vector.SetValues(s);
+
+    return *this;
+  }
+
+
+
+  template <typename Number>
+  inline Vector<Number>& Vector<Number>::operator= (const Vector<Number> &v)
+  {
+    local_vector.CopyFrom(v.paralution_vector());
+
+    return *this;
+  }
+
+
+
+  template <typename Number>
+  inline Number Vector<Number>::mean_value() const
+  {
+    Number mean(0.);
+    unsigned int i_max(size());
+    for (unsigned int i=0; i<i_max; ++i)
+      mean += local_vector[i];
+    mean /= i_max;
+
+    return mean;
+  }
+
+
+
   template <typename Number>
   inline Number Vector<Number>::l2_norm() const
   {
@@ -353,6 +587,44 @@ namespace ParalutionWrappers
 
 
 
+  template <typename Number>
+  inline bool Vector<Number>::has_ghost_elements() const
+  {
+    return false;
+  }
+
+  template <typename Number>
+  inline bool Vector<Number>::in_local_range(const size_type global_index) const
+  {
+    return true;
+  }
+
+
+
+  template <typename Number>
+  inline IndexSet Vector<Number>::locally_owned_elements() const
+  {
+    return complete_index_set(size());
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::move_to_accelerator()
+  {
+    local_vector.MoveToAccelerator();
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::move_to_host()
+  {
+    local_vector.MoveToHost();
+  }
+
+
+
   template <typename Number>
   inline Number Vector<Number>::operator() (const size_type i) const
   {
@@ -393,6 +665,32 @@ namespace ParalutionWrappers
 
 
 
+  template <typename Number>
+  inline void Vector<Number>::extract_subvector_to (const std::vector<size_type> &indices,
+                                                    std::vector<Number>          &values) const
+  {
+    for (size_type i=0; i<indices.size(); ++i)
+      values[i] = operator()(indices[i]);
+  }
+
+
+
+  template <typename Number>
+  template <typename ForwardIterator, typename OutputIterator>
+  inline void Vector<Number>::extract_subvector_to (ForwardIterator       indices_begin,
+                                                    const ForwardIterator indices_end,
+                                                    OutputIterator        values_begin) const
+  {
+    while (indices_begin != indices_end)
+      {
+        *values_begin = operator()(*indices_begin);
+        ++indices_begin;
+        ++values_begin;
+      }
+  }
+
+
+
   template <typename Number>
   inline paralution::LocalVector<Number> const &Vector<Number>::paralution_vector() const
   {
@@ -414,7 +712,7 @@ namespace ParalutionWrappers
   {
     Assert(size()==v.size(),ExcDimensionMismatch(size(),v.size()));
 
-    local_vector.ScaleAdd(1.,v.paralution_vector());
+    local_vector.AddScale(v.paralution_vector(),1.);
 
     return *this;
   }
@@ -426,13 +724,53 @@ namespace ParalutionWrappers
   {
     Assert(size()==v.size(),ExcDimensionMismatch(size(),v.size()));
 
-    local_vector.ScaleAddScale(1.,v.paralution_vector(),-1.);
+    local_vector.AddScale(v.paralution_vector(),-1.);
 
     return *this;
   }
 
 
 
+  template <typename Number>
+  template <typename Number2>
+  inline void Vector<Number>::add (const std::vector<size_type> &indices,
+                                   const std::vector<Number2>   &values)
+  {
+    Assert(indices.size()==values.size(),
+           ExcDimensionMismatch(indices.size(),values.size()));
+    add(indices.size(),&indices[0],&values[0]);
+  }
+
+
+
+  template <typename Number>
+  template <typename Number2>
+  inline void Vector<Number>::add (const std::vector<size_type>    &indices,
+                                   const ::dealii::Vector<Number2> &values)
+  {
+    Assert(indices.size()==values.size(),
+           ExcDimensionMismatch(indices.size(),values.size()));
+    add(indices.size(),&indices[0],values.begin());
+  }
+
+
+
+  template <typename Number>
+  template <typename Number2>
+  inline void Vector<Number>::add (const size_type n_indices,const size_type *indices,
+                                   const Number2 *values)
+  {
+    for (size_type i=0; i<n_indices; ++i)
+      {
+        Assert(indices[i]<size(),ExcIndexRange(indices[i],0,size()));
+        Assert(numbers::is_finite(values[i]),ExcNumberNotFinite());
+
+        local_vector[indices[i]] += values[i];
+      }
+  }
+
+
+
   template <typename Number>
   inline void Vector<Number>::add(const Number s)
   {
@@ -445,12 +783,92 @@ namespace ParalutionWrappers
 
 
   template <typename Number>
-  inline void Vector<Number>::add(const Number a,const Vector<Number> &v)
+  inline void Vector<Number>::add(const Vector<Number> &V)
+  {
+    Assert(size()==V.size(),ExcDimensionMismatch(size(),V.size()));
+    local_vector.AddScale(V.paralution_vector(),1.);
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::add(const Number a,const Vector<Number> &V)
   {
     Assert(numbers::is_finite(a),ExcNumberNotFinite());
-    Assert(size()==v.size(),ExcDimensionMismatch(size(),v.size()));
+    Assert(size()==V.size(),ExcDimensionMismatch(size(),V.size()));
 
-    local_vector.ScaleAddScale(1.,v.paralution_vector(),a);
+    local_vector.ScaleAddScale(1.,V.paralution_vector(),a);
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::add(const Number a,const Vector<Number> &V,
+                                  const Number b,const Vector<Number> &W)
+  {
+    Assert(numbers::is_finite(a),ExcNumberNotFinite());
+    Assert(numbers::is_finite(b),ExcNumberNotFinite());
+    Assert(size()==V.size(),ExcDimensionMismatch(size(),V.size()));
+    Assert(size()==W.size(),ExcDimensionMismatch(size(),W.size()));
+
+    local_vector.ScaleAdd2(1.,V.paralution_vector(),a,W.paralution_vector(),b);
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::sadd(const Number s, const Vector<Number> &V)
+  {
+    Assert(numbers::is_finite(s),ExcNumberNotFinite());
+    Assert(size()==V.size(),ExcDimensionMismatch(size(),V.size()));
+
+    local_vector.ScaleAdd(s,V.paralution_vector());
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::sadd(const Number s, const Number a, const Vector<Number> &V)
+  {
+    Assert(numbers::is_finite(s),ExcNumberNotFinite());
+    Assert(numbers::is_finite(a),ExcNumberNotFinite());
+    Assert(size()==V.size(),ExcDimensionMismatch(size(),V.size()));
+
+    local_vector.ScaleAddScale(s,V.paralution_vector(),a);
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::sadd(const Number s, const Number a, const Vector<Number> &V,
+                                   const Number b, const Vector<Number> &W)
+  {
+    Assert(numbers::is_finite(s),ExcNumberNotFinite());
+    Assert(numbers::is_finite(a),ExcNumberNotFinite());
+    Assert(numbers::is_finite(b),ExcNumberNotFinite());
+    Assert(size()==V.size(),ExcDimensionMismatch(size(),V.size()));
+    Assert(size()==W.size(),ExcDimensionMismatch(size(),W.size()));
+
+    local_vector.ScaleAdd2(s,V.paralution_vector(),a,W.paralution_vector(),b);
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::sadd(const Number s, const Number a, const Vector<Number> &V,
+                                   const Number b, const Vector<Number> &W, const Number c,
+                                   const Vector<Number> &X)
+  {
+    Assert(numbers::is_finite(s),ExcNumberNotFinite());
+    Assert(numbers::is_finite(a),ExcNumberNotFinite());
+    Assert(numbers::is_finite(b),ExcNumberNotFinite());
+    Assert(numbers::is_finite(c),ExcNumberNotFinite());
+    Assert(size()==V.size(),ExcDimensionMismatch(size(),V.size()));
+    Assert(size()==W.size(),ExcDimensionMismatch(size(),W.size()));
+    Assert(size()==X.size(),ExcDimensionMismatch(size(),X.size()));
+
+    local_vector.ScaleAdd2(s,V.paralution_vector(),a,W.paralution_vector(),b);
+    local_vector.AddScale(X.paralution_vector(),c);
   }
 
 
@@ -480,6 +898,58 @@ namespace ParalutionWrappers
 
     return *this;
   }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::equ (const Number a, const Vector<Number> &u)
+  {
+    Assert(numbers::is_finite(a), ExcNumberNotFinite());
+    Assert(size()==u.size(),ExcDimensionMismatch(size(),u.size()));
+
+    local_vector.ScaleAddScale(0.,u.paralution_vector(),a);
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::equ (const Number a, const Vector<Number> &u,
+                                   const Number b, const Vector<Number> &v)
+  {
+    Assert(numbers::is_finite(a), ExcNumberNotFinite());
+    Assert(numbers::is_finite(b), ExcNumberNotFinite());
+    Assert(size()==u.size(),ExcDimensionMismatch(size(),u.size()));
+    Assert(size()==v.size(),ExcDimensionMismatch(size(),v.size()));
+
+    local_vector.ScaleAdd2(0.,u.paralution_vector(),a,v.paralution_vector(),b);
+  }
+
+
+
+  template <typename Number>
+  inline void Vector<Number>::equ (const Number a, const Vector<Number> &u,
+                                   const Number b, const Vector<Number> &v,
+                                   const Number c, const Vector<Number> &w)
+  {
+    Assert(numbers::is_finite(a), ExcNumberNotFinite());
+    Assert(numbers::is_finite(b), ExcNumberNotFinite());
+    Assert(numbers::is_finite(c), ExcNumberNotFinite());
+    Assert(size()==u.size(),ExcDimensionMismatch(size(),u.size()));
+    Assert(size()==v.size(),ExcDimensionMismatch(size(),v.size()));
+    Assert(size()==w.size(),ExcDimensionMismatch(size(),w.size()));
+
+    local_vector.ScaleAdd2(0.,u.paralution_vector(),a,v.paralution_vector(),b);
+    local_vector.AddScale(w.paralution_vector(),c);
+  }
+
+
+
+  template <typename Number>
+  std::size_t Vector<Number>::memory_consumption () const
+  {
+    //TODO: This is a very poor approzimation.
+    return sizeof(*this) + (size() * sizeof(Number));
+  }
 }
 
 /*@}*/
index 8dae825247d238d7c97a6408a8d82ba305bfad88..d6271d461559cee1fbf08f5938572a3cf43d5915 100644 (file)
@@ -762,7 +762,7 @@ public:
 
   /**
    * A collective add operation:
-   * This funnction adds a whole
+   * This function adds a whole
    * set of values stored in @p
    * values to the vector
    * components specified by @p
index 757c2a35fe1eabd90bcba54736478d836ae13b95..a6c7aa08d6090c085235d8d28072f708bee9de0a 100644 (file)
@@ -29,6 +29,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 #include <deal.II/lac/sparse_matrix.h>
 #include <deal.II/lac/compressed_sparsity_pattern.h>
 #include <deal.II/lac/compressed_simple_sparsity_pattern.h>
index 13a0dace97e286d2e3cf3c2adc2d706a7f19d6b0..3eb327118002b8464ac0847f9d32038c828a3c62 100644 (file)
@@ -28,6 +28,7 @@
 #include <deal.II/lac/petsc_parallel_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 #include <deal.II/lac/constraint_matrix.h>
 #include <deal.II/grid/tria.h>
 #include <deal.II/grid/tria_iterator.h>
index 639d937fd924a9f7e8522b7266b5e3cabe606321..d650f823e1e842d5d3f7bff19119a14629bdad49 100644 (file)
@@ -25,6 +25,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 #include <deal.II/grid/tria_iterator.h>
 #include <deal.II/grid/tria_accessor.h>
 #include <deal.II/grid/tria_boundary.h>
index 0a7e6564e87515d0b01716bc614f4d044eac85b5..3bf9e3668bdd679ee4aafdfc58494e8ee9c527cb 100644 (file)
@@ -50,15 +50,18 @@ namespace ParalutionWrappers
   template <typename Number>
   void SolverCG::solve(const SparseMatrix<Number> &A,
                        Vector<Number>             &x,
-                       const Vector<Number>       &b)
+                       const Vector<Number>       &b,
+                       bool                        move_to_accelerator)
   {
     paralution::CG<paralution::LocalMatrix<Number>,
                paralution::LocalVector<Number>,Number> solver;
     solver.SetOperator(A.paralution_matrix());
     // Set absolute tolerance, relative tolerance, divergence tolerance,
     // maximum number of iterations.
-    solver.Init(solver_control.tolerance(),1e10,1e10,
+    solver.Init(solver_control.tolerance(),0.,1.e100,
                 solver_control.max_steps());
+    if (move_to_accelerator==true)
+      solver.MoveToAccelerator();
     solver.Build();
     solver.Solve(b.paralution_vector(),&(x.paralution_vector()));
   }
@@ -77,14 +80,17 @@ namespace ParalutionWrappers
   template <typename Number>
   void SolverBicgstab::solve(const SparseMatrix<Number> &A,
                              Vector<Number>             &x,
-                             const Vector<Number>       &b)
+                             const Vector<Number>       &b,
+                             bool                        move_to_accelerator)
   {
     paralution::BiCGStab<paralution::LocalMatrix<Number>,
                paralution::LocalVector<Number>,Number> solver;
     // Set absolute tolerance, relative tolerance, divergence tolerance,
     // maximum number of iterations.
-    solver.Init(solver_control.tolerance(),1e10,1e10,
+    solver.Init(solver_control.tolerance(),0.,1.e100,
                 solver_control.max_steps());
+    if (move_to_accelerator==true)
+      solver.MoveToAccelerator();
     solver.Build();
     solver.Solve(b.paralution_vector(),&(x.paralution_vector()));
   }
@@ -105,15 +111,18 @@ namespace ParalutionWrappers
   template <typename Number>
   void SolverGMRES::solve(const SparseMatrix<Number> &A,
                           Vector<Number>             &x,
-                          const Vector<Number>       &b)
+                          const Vector<Number>       &b,
+                          bool                        move_to_accelerator)
   {
     paralution::GMRES<paralution::LocalMatrix<Number>,
                paralution::LocalVector<Number>,Number> solver;
     // Set absolute tolerance, relative tolerance, divergence tolerance,
     // maximum number of iterations.
-    solver.Init(solver_control.tolerance(),1e10,1e10,
+    solver.Init(solver_control.tolerance(),0.,1.e100,
                 solver_control.max_steps());
     solver.SetBasisSize(additional_data.restart_parameter);
+    if (move_to_accelerator==true)
+      solver.MoveToAccelerator();
     solver.Build();
     solver.Solve(b.paralution_vector(),&(x.paralution_vector()));
   }
@@ -128,27 +137,33 @@ namespace ParalutionWrappers
 {
   template void SolverCG::solve<float>(const SparseMatrix<float> &A,
                                        Vector<float>             &x,
-                                       const Vector<float>       &b);
+                                       const Vector<float>       &b,
+                                       bool                       move_to_accelerator);
 
   template void SolverCG::solve<double>(const SparseMatrix<double> &A,
                                         Vector<double>             &x,
-                                        const Vector<double>       &b);
+                                        const Vector<double>       &b,
+                                        bool                       move_to_accelerator);
 
   template void SolverBicgstab::solve<float>(const SparseMatrix<float> &A,
                                              Vector<float>             &x,
-                                             const Vector<float>       &b);
+                                             const Vector<float>       &b,
+                                             bool                       move_to_accelerator);
 
   template void SolverBicgstab::solve<double>(const SparseMatrix<double> &A,
                                               Vector<double>             &x,
-                                              const Vector<double>       &b);
+                                              const Vector<double>       &b,
+                                              bool                       move_to_accelerator);
 
   template void SolverGMRES::solve<float>(const SparseMatrix<float> &A,
                                           Vector<float>             &x,
-                                          const Vector<float>       &b);
+                                          const Vector<float>       &b,
+                                          bool                       move_to_accelerator);
 
   template void SolverGMRES::solve<double>(const SparseMatrix<double> &A,
                                            Vector<double>             &x,
-                                           const Vector<double>       &b);
+                                           const Vector<double>       &b,
+                                           bool                       move_to_accelerator);
 }
 
 DEAL_II_NAMESPACE_CLOSE
index 145347c6cf879ecc36dade3311525bec98398bd9..1630185b902fdcb0c389bece11fc745da9be355e 100644 (file)
@@ -23,7 +23,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
-
+#include <deal.II/lac/paralution_vector.h>
 #include <deal.II/lac/parallel_vector.h>
 #include <deal.II/lac/parallel_block_vector.h>
 
index 9ed021a9972c7da4eac524b4e4b25d939d0d3611..711dc53feeb7238874289dd38f02c71ff2017d8d 100644 (file)
@@ -25,6 +25,7 @@
 #include <deal.II/lac/petsc_parallel_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 
 DEAL_II_NAMESPACE_OPEN
 
index 20012529005269493873eeeed601358d1673d9ec..e151cce1aa5ed0b2b3c8b85591629a55ea217203 100644 (file)
@@ -22,6 +22,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 #include <deal.II/lac/sparse_matrix.h>
 #include <deal.II/lac/block_sparse_matrix.h>
 #include <deal.II/multigrid/mg_transfer.h>
index dd2a9ca41df429cad3da6ca08bae470a973913d5..ece310a4f7b5814f071846d20ca874b96f0d57dc 100644 (file)
@@ -25,6 +25,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 #include <deal.II/grid/tria_iterator.h>
 #include <deal.II/grid/grid_tools.h>
 #include <deal.II/grid/filtered_iterator.h>
index 740c8e89e7111fbf14d773e11590365821a20981..22829fcfa45255aacdda8a29041c721031ae0be2 100644 (file)
@@ -29,6 +29,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 
 
 DEAL_II_NAMESPACE_OPEN
index 83e89a9afae087c7ef56f21b782b4d2bd9a7ef81..12a2861a4a9e5912055019601b102fe2cb4e77f0 100644 (file)
@@ -26,6 +26,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 #include <deal.II/grid/tria_iterator.h>
 #include <deal.II/base/geometry_info.h>
 #include <deal.II/dofs/dof_handler.h>
index 15b65d0bc892544f769760c68e83099470746843..d54175d12b64eb68dd9bed2e4d6e4825e938d8ab 100644 (file)
@@ -26,6 +26,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 #include <deal.II/grid/tria_iterator.h>
 #include <deal.II/base/geometry_info.h>
 #include <deal.II/dofs/dof_handler.h>
index d6f176aac07df2a16e7634bf6cd5af344c0af73b..08df1b38bff38a3e5891150ad3f8e26fd1a8a685 100644 (file)
@@ -29,6 +29,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 
 DEAL_II_NAMESPACE_OPEN
 
index c7b849693b6cc991ed42f415b1a79e7fe0ed93d7..60841e6915c2c35885b4a2d2dcf5447854e55afd 100644 (file)
@@ -23,6 +23,7 @@
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 
 #include <deal.II/numerics/vector_tools.h>
 
index 5e0ac217ed4ce4d1823d103733c4bd8b453214e4..fb7ef2a30e7137cc0d6e5295ba70359f5ba2ff8f 100644 (file)
@@ -29,6 +29,7 @@
 #include <deal.II/lac/parallel_block_vector.h>
 #include <deal.II/lac/petsc_block_vector.h>
 #include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/paralution_vector.h>
 #include <deal.II/numerics/solution_transfer.h>
 
 DEAL_II_NAMESPACE_OPEN

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.