From: Martin Kronbichler Date: Thu, 5 Nov 2009 20:57:45 +0000 (+0000) Subject: Implement an improved = operator for distributed vectors that can handle different... X-Git-Tag: v8.0.0~6849 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c36fe5b95c8c586a318ed0bd5b048c834b885f88;p=dealii.git Implement an improved = operator for distributed vectors that can handle different Epetra_Maps. git-svn-id: https://svn.dealii.org/trunk@20043 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/source/trilinos_vector.cc b/deal.II/lac/source/trilinos_vector.cc index 923cccdf64..f984ce003f 100644 --- a/deal.II/lac/source/trilinos_vector.cc +++ b/deal.II/lac/source/trilinos_vector.cc @@ -205,7 +205,17 @@ namespace TrilinosWrappers Vector & Vector::operator = (const Vector &v) { - if (local_range() == v.local_range()) + // distinguish three cases. First case: both + // vectors have the same layout (just need to + // copy the local data). Second case: vectors + // have the same size, but different + // layout. The calling vector has a wider + // local range than the input vector, and the + // input vector has a 1-to-1 map (need to + // import data). The third case means that we + // have to rebuild the calling vector. + if (size() == v.size() && + local_range() == v.local_range()) { Assert (vector->Map().SameAs(v.vector->Map()) == true, ExcMessage ("The Epetra maps in the assignment operator =" @@ -217,6 +227,14 @@ namespace TrilinosWrappers last_action = Zero; } + else if (size() == v.size() && local_range().first<=v.local_range().first && + local_range().second>=v.local_range().second && + v.vector->Map().UniqueGIDs()) + { + Epetra_Import data_exchange (vector->Map(), v.vector->Map()); + const int ierr = vector->Import(*v.vector, data_exchange, Insert); + AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + } else { vector.reset();