On Thu, 24 Jun 2010, Roy Stogner wrote:

I suspect there are only two reasons why we didn't support mismatched
types:

when that assertion was written we only had serial and parallel
vectors, a more extreme mismatch

we didn't know for sure that you could VecCopy between mismatched
types.

These reasons no longer apply.

I've meanwhile implemented "parallel=ghosted", see attached patch. It solves the problem for me. (BTW, it's amazing what mistakes one can do even in such a trivial change; I had to correct my patch two times before it did what I wanted...) I'll commit that within the next days if nobody objects.

I'd say that we should at least enable "parallelvec = ghostedvec", if everyone agrees. "parallelvec = serialvec" and "ghostedvec = serialvec" would also be natural to enable.

Conceptually yes, but as Jed pointed out, it's more difficult to implement. Hence I'd like to leave that to somebody else, as long as I don't need that for my application. (-:

I'd just as soon eventually support every operator= combo, but the "morelocaldatavec = lesslocaldatavec" type operations would require us to add some code in addition to the plain VecCopy before they'd have the semantics I'd want.

Well, aren't "ghosted=parallel" and "serial=parallel" just the same as NumericVector::localize()? If that is the case, only "parallel=serial" is missing, which should, altough it's not just VecCopy(), still be quite easy. Then, the remaining directions can easily be composed of existing ones.

Best Regards,

Tim

--
Dr. Tim Kroeger
tim.kroe...@mevis.fraunhofer.de            Phone +49-421-218-7710
tim.kroe...@cevis.uni-bremen.de            Fax   +49-421-218-4236
www.mevis.fraunhofer.de/~tim

Fraunhofer MEVIS, Institute for Medical Image Computing
Universitaetsallee 29, 28359 Bremen, Germany
Index: src/numerics/petsc_vector.C
===================================================================
--- src/numerics/petsc_vector.C (Revision 3838)
+++ src/numerics/petsc_vector.C (Arbeitskopie)
@@ -574,40 +574,55 @@
 {
   this->_restore_array();
   v._restore_array();
-  libmesh_assert (this->_type == v._type);
+
   libmesh_assert (this->size() == v.size());
   libmesh_assert (this->local_size() == v.local_size());
-  libmesh_assert (this->_global_to_local_map ==
-                  v._global_to_local_map);
-
   libmesh_assert (v.closed());
   this->_is_closed = true;
 
-  if (v.size() != 0)
+  int ierr = 0;
+
+  if((this->type()==PARALLEL) && (v.type()==GHOSTED))
     {
-      int ierr = 0;
-      if(this->type() != GHOSTED)
+      /* Allow assignment of a ghosted to a parallel vector since this
+        causes no difficulty.  See discussion in libmesh-devel of
+        June 24, 2010.  */
+      ierr = VecCopy (v._vec, this->_vec);
+      CHKERRABORT(libMesh::COMM_WORLD,ierr);
+    }
+  else
+    {
+      /* In all other cases, we assert that both vectors are of equal
+        type.  */
+      libmesh_assert (this->_type == v._type);
+      libmesh_assert (this->_global_to_local_map ==
+                     v._global_to_local_map);
+      
+      if (v.size() != 0)
        {
-         ierr = VecCopy (v._vec, this->_vec);
-         CHKERRABORT(libMesh::COMM_WORLD,ierr);
+         if(this->type() != GHOSTED)
+           {
+             ierr = VecCopy (v._vec, this->_vec);
+             CHKERRABORT(libMesh::COMM_WORLD,ierr);
+           }
+         else
+           {
+             Vec loc_vec;
+             Vec v_loc_vec;
+             ierr = VecGhostGetLocalForm (_vec,&loc_vec);
+             CHKERRABORT(libMesh::COMM_WORLD,ierr);
+             ierr = VecGhostGetLocalForm (v._vec,&v_loc_vec);
+             CHKERRABORT(libMesh::COMM_WORLD,ierr);
+             
+             ierr = VecCopy (v_loc_vec, loc_vec);
+             CHKERRABORT(libMesh::COMM_WORLD,ierr);
+             
+             ierr = VecGhostRestoreLocalForm (v._vec,&v_loc_vec);
+             CHKERRABORT(libMesh::COMM_WORLD,ierr);
+             ierr = VecGhostRestoreLocalForm (_vec,&loc_vec);
+             CHKERRABORT(libMesh::COMM_WORLD,ierr);
+           }
        }
-      else
-       {
-         Vec loc_vec;
-         Vec v_loc_vec;
-         ierr = VecGhostGetLocalForm (_vec,&loc_vec);
-         CHKERRABORT(libMesh::COMM_WORLD,ierr);
-         ierr = VecGhostGetLocalForm (v._vec,&v_loc_vec);
-         CHKERRABORT(libMesh::COMM_WORLD,ierr);
-
-         ierr = VecCopy (v_loc_vec, loc_vec);
-         CHKERRABORT(libMesh::COMM_WORLD,ierr);
-
-         ierr = VecGhostRestoreLocalForm (v._vec,&v_loc_vec);
-         CHKERRABORT(libMesh::COMM_WORLD,ierr);
-         ierr = VecGhostRestoreLocalForm (_vec,&loc_vec);
-         CHKERRABORT(libMesh::COMM_WORLD,ierr);
-       }
     }
   
   return *this;
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to