From: kronbichler Date: Fri, 12 Sep 2008 14:30:24 +0000 (+0000) Subject: Now the transfer from distributed to localized vector seems to work properly. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63acfeea42660bc2a1f67f03385c53b56836b42a;p=dealii-svn.git Now the transfer from distributed to localized vector seems to work properly. git-svn-id: https://svn.dealii.org/trunk@16818 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/trilinos_sparse_matrix.h b/deal.II/lac/include/lac/trilinos_sparse_matrix.h index 18359e99c0..da91f09ee9 100755 --- a/deal.II/lac/include/lac/trilinos_sparse_matrix.h +++ b/deal.II/lac/include/lac/trilinos_sparse_matrix.h @@ -453,7 +453,7 @@ namespace TrilinosWrappers * reference to *this. */ SparseMatrix & - copy_from (const SparseMatrix &source); + copy_from (const SparseMatrix &source); /** * This function initializes @@ -657,7 +657,7 @@ namespace TrilinosWrappers * pattern previously used. */ SparseMatrix & - operator = (const double d); + operator = (const double d); /** * Set the element (i,j) @@ -876,13 +876,14 @@ namespace TrilinosWrappers * Return the * l1-norm of * the matrix, that is - * $|M|_1=\max_{\mathrm{all - * columns} j}\sum_{\mathrm{all - * rows} i} |M_{ij}|$, (max. sum + * $|M|_1= + * \max_{\mathrm{all columns } j} + * \sum_{\mathrm{all rows } i} + * |M_{ij}|$, (max. sum * of columns). This is the * natural matrix norm that is * compatible to the l1-norm for - * vectors, i.e. $|Mv|_1\leq + * vectors, i.e. $|Mv|_1 \leq * |M|_1 |v|_1$. * (cf. Haemmerlin-Hoffmann: * Numerische Mathematik) diff --git a/deal.II/lac/include/lac/trilinos_vector.h b/deal.II/lac/include/lac/trilinos_vector.h index a3f9c2c1de..0dc2a13555 100755 --- a/deal.II/lac/include/lac/trilinos_vector.h +++ b/deal.II/lac/include/lac/trilinos_vector.h @@ -454,7 +454,23 @@ namespace TrilinosWrappers * necessary. */ Vector & - operator = (const Vector &v); + operator = (const Vector &V); + + /** + * Copy operator from a given + * localized vector (present on + * all processes) in + * TrilinosWrappers format to the + * current distributed + * vector. This function assumes + * that the calling vector (left + * hand object) already is of the + * same size as the right hand + * side vector. Otherwise, an + * exception will be thrown. + */ + Vector & + operator = (const LocalizedVector &V); /** * Another copy function. This @@ -991,6 +1007,7 @@ namespace TrilinosWrappers * friend. */ friend class internal::VectorReference; + friend class LocalizedVector; }; @@ -1005,7 +1022,7 @@ namespace TrilinosWrappers * @see @ref SoftwareTrilinos * @author Martin Kronbichler, 2008 */ - class LocalizedVector : Vector + class LocalizedVector : public Vector { public: /** @@ -1089,6 +1106,8 @@ namespace TrilinosWrappers public: std::auto_ptr vector; + + friend class Vector; }; diff --git a/deal.II/lac/source/trilinos_vector.cc b/deal.II/lac/source/trilinos_vector.cc index d59d0235c3..cfc62b919f 100755 --- a/deal.II/lac/source/trilinos_vector.cc +++ b/deal.II/lac/source/trilinos_vector.cc @@ -18,6 +18,9 @@ #ifdef DEAL_II_USE_TRILINOS +#include + + DEAL_II_NAMESPACE_OPEN namespace TrilinosWrappers @@ -161,6 +164,22 @@ namespace TrilinosWrappers } + + Vector & + Vector::operator = (const LocalizedVector &v) + { + Assert (size() == v.size(), ExcDimensionMismatch(size(), v.size())); + + Epetra_Import import_information (map, v.map); + const int ierr = vector->Import(*v.vector, import_information, Insert); + + Assert (ierr == 0, ExcTrilinosError(ierr)); + + return *this; + } + + + Vector & Vector::operator = (const ::dealii::Vector &v) { @@ -954,9 +973,14 @@ namespace TrilinosWrappers LocalizedVector::reinit (const Vector &v) { map = Epetra_LocalMap (v.size(),0,v.vector->Comm()); + + Epetra_Import import_information (map, v.map); + vector = std::auto_ptr (new Epetra_MultiVector (map,1,false)); - *vector = *v.vector; + + int ierr = vector->Import(*v.vector, import_information, Insert); + Assert (ierr == 0, ExcTrilinosError(ierr)); }