]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement an improved = operator for distributed vectors that can handle different...
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 5 Nov 2009 20:57:45 +0000 (20:57 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 5 Nov 2009 20:57:45 +0000 (20:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@20043 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/trilinos_vector.cc

index 923cccdf6485564a4201be0ed3730123e8b93e84..f984ce003f2ae2569b8d6e13297fa04f63133ffb 100644 (file)
@@ -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();

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.