From e892a4454d8d986afdb87ee62b0d6b2a78e9cb39 Mon Sep 17 00:00:00 2001 From: turcksin Date: Mon, 16 Dec 2013 17:04:36 +0000 Subject: [PATCH] Add ParalutionWrappers::Vector in the list of SERIAL_VECTOR and start the modifications to use the new Vector through the whole library. git-svn-id: https://svn.dealii.org/branches/branch_paralution@32027 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/config/template-arguments.in | 8 +++- .../configure/configure_2_paralution.cmake | 13 ++++-- .../include/deal.II/lac/paralution_vector.h | 45 +++++++++++++++++++ .../deal.II/lac/trilinos_vector_base.h | 4 +- deal.II/source/algorithms/operator.cc | 1 + deal.II/source/dofs/dof_accessor_get.cc | 1 + deal.II/source/dofs/dof_accessor_set.cc | 1 + deal.II/source/lac/constraint_matrix.cc | 1 + .../meshworker/mesh_worker_vector_selector.cc | 1 + deal.II/source/multigrid/mg_base.cc | 1 + deal.II/source/numerics/data_out_dof_data.cc | 1 + 11 files changed, 69 insertions(+), 8 deletions(-) diff --git a/deal.II/cmake/config/template-arguments.in b/deal.II/cmake/config/template-arguments.in index 7e97a5eea3..75194b4f07 100644 --- a/deal.II/cmake/config/template-arguments.in +++ b/deal.II/cmake/config/template-arguments.in @@ -30,6 +30,8 @@ SERIAL_VECTORS := { Vector; @DEAL_II_EXPAND_TRILINOS_MPI_VECTOR@; @DEAL_II_EXPAND_PETSC_VECTOR@; @DEAL_II_EXPAND_PETSC_MPI_VECTOR@; + @DEAL_II_EXPAND_PARALUTION_VECTOR_FLOAT@; + @DEAL_II_EXPAND_PARALUTION_VECTOR_DOUBLE@; @DEAL_II_EXPAND_TRILINOS_BLOCKVECTOR@; @DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR@; @@ -40,13 +42,15 @@ SERIAL_VECTORS := { Vector; EXTERNAL_SEQUENTIAL_VECTORS := { @DEAL_II_EXPAND_TRILINOS_VECTOR@; @DEAL_II_EXPAND_TRILINOS_BLOCKVECTOR@; @DEAL_II_EXPAND_PETSC_VECTOR@; - @DEAL_II_EXPAND_PETSC_BLOCKVECTOR@ + @DEAL_II_EXPAND_PETSC_BLOCKVECTOR@; + @DEAL_II_EXPAND_PARALUTION_VECTOR_FLOAT@; + @DEAL_II_EXPAND_PARALUTION_VECTOR_DOUBLE@; } EXTERNAL_PARALLEL_VECTORS := { @DEAL_II_EXPAND_TRILINOS_MPI_VECTOR@; @DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR@; @DEAL_II_EXPAND_PETSC_MPI_VECTOR@; - @DEAL_II_EXPAND_PETSC_MPI_BLOCKVECTOR@ + @DEAL_II_EXPAND_PETSC_MPI_BLOCKVECTOR@; } VECTORS_WITH_MATRIX := { Vector; diff --git a/deal.II/cmake/configure/configure_2_paralution.cmake b/deal.II/cmake/configure/configure_2_paralution.cmake index 7d5b7c7019..d495313635 100644 --- a/deal.II/cmake/configure/configure_2_paralution.cmake +++ b/deal.II/cmake/configure/configure_2_paralution.cmake @@ -18,10 +18,15 @@ # Configuration for the paralution library: # -# -# The user has to know the location of the PARALUTION headers as well: -# -SET(PARALUTION_ADD_TO_USER_INCLUDE_DIRS TRUE) +MACRO(FEATURE_PARALUTION_CONFIGURE_EXTERNAL) + + SET(PARALUTION_ADD_TO_USER_INCLUDE_DIRS TRUE) + REGISTER_FEATURE(PARALUTION) + + SET(DEAL_II_EXPAND_PARALUTION_VECTOR_FLOAT "ParalutionWrappers::Vector") + SET(DEAL_II_EXPAND_PARALUTION_VECTOR_DOUBLE "ParalutionWrappers::Vector") + +ENDMACRO() CONFIGURE_FEATURE(PARALUTION) diff --git a/deal.II/include/deal.II/lac/paralution_vector.h b/deal.II/include/deal.II/lac/paralution_vector.h index 00bee9a58e..e743d8929c 100644 --- a/deal.II/include/deal.II/lac/paralution_vector.h +++ b/deal.II/include/deal.II/lac/paralution_vector.h @@ -121,6 +121,12 @@ namespace ParalutionWrappers //TODO look to add fast void reinit(const size_type N); + /** + * Change the dimension of the vector to that of the vector v. The vector + * is filled with zeros. + */ + void reinit(const Vector &v); + /** * Return dimension of the vector. */ @@ -153,6 +159,12 @@ namespace ParalutionWrappers * cannot be moved. */ const_iterator end() const; + + /** + * $l_2$-norm of the vector. The ssquare root of the sum of the squares of + * the elements. + */ + Number l2_norm() const; //@} /** @@ -217,6 +229,12 @@ namespace ParalutionWrappers */ void add(const Number s); + /** + * Simple addition of a multiple of a vector, i.e. *this += a*V. + */ + void add(const Number a, + const Vector &v); + /** * Scale each element of the vector by a constant value. */ @@ -278,6 +296,15 @@ namespace ParalutionWrappers + template + void Vector::reinit(const Vector &v) + { + local_vector.Clear(); + local_vector.Allocate("deal_ii_vector",v.size()); + } + + + template inline std::size_t Vector::size() const { @@ -318,6 +345,14 @@ namespace ParalutionWrappers + template + inline Number Vector::l2_norm() const + { + return local_vector.Norm(); + } + + + template inline Number Vector::operator() (const size_type i) const { @@ -409,6 +444,16 @@ namespace ParalutionWrappers } + template + inline void Vector::add(const Number a,const Vector &v) + { + Assert(numbers::is_finite(a),ExcNumberNotFinite()); + Assert(size()==v.size(),ExcDimensionMismatch(size(),v.size())); + + local_vector.ScaleAddScale(1.,v.paralution_vector(),a); + } + + template inline Vector& Vector::operator*= (const Number factor) diff --git a/deal.II/include/deal.II/lac/trilinos_vector_base.h b/deal.II/include/deal.II/lac/trilinos_vector_base.h index b3035c0da1..cc7ad7569a 100644 --- a/deal.II/include/deal.II/lac/trilinos_vector_base.h +++ b/deal.II/include/deal.II/lac/trilinos_vector_base.h @@ -861,7 +861,7 @@ namespace TrilinosWrappers /** * Simple addition of a multiple - * of a vector, i.e. *this = + * of a vector, i.e. *this += * a*V. */ void add (const TrilinosScalar a, @@ -869,7 +869,7 @@ namespace TrilinosWrappers /** * Multiple addition of scaled - * vectors, i.e. *this = a*V + + * vectors, i.e. *this += a*V + * b*W. */ void add (const TrilinosScalar a, diff --git a/deal.II/source/algorithms/operator.cc b/deal.II/source/algorithms/operator.cc index 8f0bcc0516..a019d1a5c2 100644 --- a/deal.II/source/algorithms/operator.cc +++ b/deal.II/source/algorithms/operator.cc @@ -31,6 +31,7 @@ #include #include #include +#include DEAL_II_NAMESPACE_OPEN diff --git a/deal.II/source/dofs/dof_accessor_get.cc b/deal.II/source/dofs/dof_accessor_get.cc index 9b9ca8b7b8..0ae8220b47 100644 --- a/deal.II/source/dofs/dof_accessor_get.cc +++ b/deal.II/source/dofs/dof_accessor_get.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/deal.II/source/dofs/dof_accessor_set.cc b/deal.II/source/dofs/dof_accessor_set.cc index f11fc845a0..64572315fa 100644 --- a/deal.II/source/dofs/dof_accessor_set.cc +++ b/deal.II/source/dofs/dof_accessor_set.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/deal.II/source/lac/constraint_matrix.cc b/deal.II/source/lac/constraint_matrix.cc index 493b3f7c16..8b5d556634 100644 --- a/deal.II/source/lac/constraint_matrix.cc +++ b/deal.II/source/lac/constraint_matrix.cc @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/deal.II/source/meshworker/mesh_worker_vector_selector.cc b/deal.II/source/meshworker/mesh_worker_vector_selector.cc index 36d58a446a..77bdeaad1a 100644 --- a/deal.II/source/meshworker/mesh_worker_vector_selector.cc +++ b/deal.II/source/meshworker/mesh_worker_vector_selector.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include diff --git a/deal.II/source/multigrid/mg_base.cc b/deal.II/source/multigrid/mg_base.cc index 424e043082..db3884e59d 100644 --- a/deal.II/source/multigrid/mg_base.cc +++ b/deal.II/source/multigrid/mg_base.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include diff --git a/deal.II/source/numerics/data_out_dof_data.cc b/deal.II/source/numerics/data_out_dof_data.cc index db456bc6eb..52abb7de33 100644 --- a/deal.II/source/numerics/data_out_dof_data.cc +++ b/deal.II/source/numerics/data_out_dof_data.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include -- 2.39.5