]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Allow the assignment onto vectors with one-to-one map. 17357/head
authorSebastian Kinnewig <sebastian@kinnewig.org>
Tue, 23 Jul 2024 08:19:05 +0000 (10:19 +0200)
committerSebastian Kinnewig <sebastian@kinnewig.org>
Tue, 23 Jul 2024 08:23:16 +0000 (10:23 +0200)
include/deal.II/lac/trilinos_tpetra_vector.templates.h

index 0a3cd3ffed80fe4b4db92776c7151336e2b84b9d..4650e8e28a6bc55ebc0008c1ae7953abf7f9791a 100644 (file)
@@ -383,26 +383,40 @@ namespace LinearAlgebra
         }
       else if (size() == V.size())
         {
-          // We expect the origin vector to have a one-to-one map, otherwise
-          // we can not call Import
-          Assert(V.vector->getMap()->isOneToOne(),
-                 ExcMessage(
-                   "You are trying to map one vector distributed "
-                   "between processors, where some elements belong "
-                   "to multiple processors, onto another distribution "
-                   "pattern, where some elements belong to multiple "
-                   "processors. It is unclear how to deal with elements "
-                   "in the vector belonging to multiple processors. "
-                   "Therefore, compress() must be called on this "
-                   "vector first."));
-
-          Teuchos::RCP<const TpetraTypes::ImportType<MemorySpace>> importer =
-            Tpetra::createImport(V.vector->getMap(), vector->getMap());
-
-          // Since we are distributing the vector from a one-to-one map
-          // we can always use the VectorOperation::insert / Tpetra::INSERT
-          // here.
-          vector->doImport(*V.vector, *importer, Tpetra::INSERT);
+          // We expect that at least one vector has a one-to-one map, otherwise
+          // we can neither call Import nor Export.
+          if (V.vector->getMap()->isOneToOne())
+            {
+              Teuchos::RCP<const TpetraTypes::ImportType<MemorySpace>>
+                importer =
+                  Tpetra::createImport(V.vector->getMap(), vector->getMap());
+
+              // Since we are distributing the vector from a one-to-one map
+              // we can always use the VectorOperation::insert / Tpetra::INSERT
+              // here.
+              vector->doImport(*V.vector, *importer, Tpetra::INSERT);
+            }
+          else if (vector->getMap()->isOneToOne())
+            {
+              Teuchos::RCP<const TpetraTypes::ExportType<MemorySpace>>
+                exporter =
+                  Tpetra::createExport(V.vector->getMap(), vector->getMap());
+
+              vector->doExport(*V.vector, *exporter, Tpetra::INSERT);
+            }
+          else
+            {
+              Assert(false,
+                     ExcMessage(
+                       "You are trying to map one vector distributed "
+                       "between processors, where some elements belong "
+                       "to multiple processors, onto another distribution "
+                       "pattern, where some elements belong to multiple "
+                       "processors. It is unclear how to deal with elements "
+                       "in the vector belonging to multiple processors. "
+                       "Therefore, compress() must be called on this "
+                       "vector first."));
+            }
         }
       else
         {

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.