]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix assignment operator of Trilinos vectors in distributed case which did not work...
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 18 Oct 2010 14:40:12 +0000 (14:40 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 18 Oct 2010 14:40:12 +0000 (14:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@22359 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/trilinos_vector.cc

index deb093ea0d6922105d5a11ccb219a62d96397d48..a2ecd7ec614418f69a84558e1d365e639ebcfdfb 100644 (file)
@@ -115,7 +115,7 @@ namespace TrilinosWrappers
     Vector::reinit (const Epetra_Map &input_map,
                    const bool        fast)
     {
-      if (!vector->Map().SameAs(input_map))
+      if (vector->Map().SameAs(input_map)==false)
        vector.reset (new Epetra_FEVector(input_map));
       else if (fast == false)
        {
@@ -279,49 +279,26 @@ namespace TrilinosWrappers
     {
                                // 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())
+                               // copy the local data, not reset the memory
+                               // and the underlying Epetra_Map). The third
+                               // case means that we have to rebuild the
+                               // calling vector.
+      if (vector->Map().SameAs(v.vector->Map()))
        {
-         Assert (vector->Map().SameAs(v.vector->Map()) == true,
-                 ExcMessage ("The Epetra maps in the assignment operator ="
-                             " do not match, even though the local_range"
-                             " seems to be the same. Check vector setup or"
-                             " use reinit()!"));
-
-         const int ierr = vector->Update(1.0, *v.vector, 0.0);
-         Assert (ierr == 0, ExcTrilinosError(ierr));
-
+         *vector = *v.vector;
          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())
+                               // Second case: vectors have the same global
+                               // size, but different parallel layouts (and
+                               // one of them a one-to-one mapping). Then we
+                               // can call the import/export functionality.
+      else if (size() == v.size() &&
+              (v.vector->Map().UniqueGIDs() || vector->Map().UniqueGIDs()))
        {
-         Epetra_Import data_exchange (vector->Map(), v.vector->Map());
-         const int ierr = vector->Import(*v.vector, data_exchange, Insert);
-         Assert (ierr == 0, ExcTrilinosError(ierr));
-       }
-      else if (size() == v.size() && local_range().first>=v.local_range().first &&
-              local_range().second<=v.local_range().second &&
-              vector->Map().UniqueGIDs())
-       {
-         for (unsigned int i=0; i<local_size(); ++i)
-           {
-             Assert (v.trilinos_vector().Map().MyGID(vector->Map().GID(i)),
-                     ExcMessage ("The right hand side vector does not contain "
-                                 "all local elements present in the left hand "
-                                 "side vector in the assignment operation =, "
-                                 "which is not allowed. Use reinit()."));
-             (*vector)[0][i] = v(vector->Map().GID(i));
-           }
+         reinit (v, false, true);
        }
+                               // Third case: Vectors do not have the same
+                               // size.
       else
        {
          vector.reset (new Epetra_FEVector(*v.vector));

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.