From: kronbichler Date: Thu, 21 Aug 2008 21:23:36 +0000 (+0000) Subject: Introduced copy operator = for basic Trilinos vectors. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61de969b3f36092fbb451618224efbfd4a193591;p=dealii-svn.git Introduced copy operator = for basic Trilinos vectors. git-svn-id: https://svn.dealii.org/trunk@16645 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/trilinos_vector.h b/deal.II/lac/include/lac/trilinos_vector.h index 611e1a766d..a887ebc37d 100755 --- a/deal.II/lac/include/lac/trilinos_vector.h +++ b/deal.II/lac/include/lac/trilinos_vector.h @@ -377,6 +377,13 @@ namespace TrilinosWrappers */ void reinit (const Epetra_Map &input_map); + /** + * Reinit functionality. This function + * copies the vector v to the current + * one. + */ + void reinit (const Vector &v); + /** * Release all memory and return * to a state just like after @@ -417,6 +424,12 @@ namespace TrilinosWrappers */ Vector & operator = (const TrilinosScalar s); + /** + * Copy the given vector. Resize the + * present vector if necessary. + */ + Vector & operator = (const Vector &v); + /** * Test for equality. This function * assumes that the present vector and @@ -975,6 +988,19 @@ namespace TrilinosWrappers + inline + Vector & + Vector::operator = (const Vector &v) + { + // if the vectors have different sizes, + // then first resize the present one + reinit (v); + + return *this; + } + + + inline internal::VectorReference Vector::operator () (const unsigned int index) diff --git a/deal.II/lac/source/trilinos_vector.cc b/deal.II/lac/source/trilinos_vector.cc index d32be6fecd..4cabc899b8 100755 --- a/deal.II/lac/source/trilinos_vector.cc +++ b/deal.II/lac/source/trilinos_vector.cc @@ -100,6 +100,20 @@ namespace TrilinosWrappers + void + Vector::reinit (const Vector &v) + { + vector.reset(); + + if (!map.SameAs(v.map)) + map = v.map; + + vector = std::auto_ptr (new Epetra_FEVector(*v.vector)); + last_action = Insert; + } + + + void Vector::clear () {