From 61de969b3f36092fbb451618224efbfd4a193591 Mon Sep 17 00:00:00 2001 From: kronbichler Date: Thu, 21 Aug 2008 21:23:36 +0000 Subject: [PATCH] Introduced copy operator = for basic Trilinos vectors. git-svn-id: https://svn.dealii.org/trunk@16645 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/trilinos_vector.h | 26 +++++++++++++++++++++++ deal.II/lac/source/trilinos_vector.cc | 14 ++++++++++++ 2 files changed, 40 insertions(+) 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 () { -- 2.39.5