VecDuplicate()

Barry Smith bsmith at mcs.anl.gov
Wed Apr 15 18:16:01 CDT 2009


    There is something else wrong here. It is rejecting the y argument  
as not being a vector. Perhaps you are not passing
it down correctly into the call? Perhaps passing a pointer to it  
instead?

   Don't think this has anything do with with periodic.

    Barry

On Apr 15, 2009, at 5:50 PM, (Rebecca) Xuefei YUAN wrote:

> Hi,
>
> I use VecDuplicate() to duplicate four vectors from x, whose da has  
> DA_XPERIODIC, however, those four new vectors lost the properties of  
> DA_XPERIODIC. How could I keep this XPERIODIC property?
> ----------------------------------------------------------------------------
> ierr = DACreate2d(comm,DA_XPERIODIC,DA_STENCIL_STAR, -5, -5,  
> PETSC_DECIDE, PETSC_DECIDE, 4, 2, 0, 0, &da);CHKERRQ(ierr);
> ierr = DMMGSetDM(dmmg, (DM)da);CHKERRQ(ierr);
>
>
> for (i = 0; i < parameters.numberOfLevels; i++){
> 	ierr = VecDuplicate(dmmg[i]->x,  
> &appCtx[i].uOld1Vector);CHKERRQ(ierr);
> 	ierr = VecDuplicate(dmmg[i]->x,  
> &appCtx[i].uOld2Vector);CHKERRQ(ierr);
> 	ierr = VecDuplicate(dmmg[i]->x,  
> &appCtx[i].uOld3Vector);CHKERRQ(ierr);
> 	ierr = VecDuplicate(dmmg[i]->x,  
> &appCtx[i].uOld4Vector);CHKERRQ(ierr);
> }
> -------------------------------------------------------------------
>
> I tried to use VecCopy(), but it is wrong at line 1678:vector.c.
>
> ------------------------------------------------------------------
> Breakpoint 4, VecCopy (x=0x8861070, y=0x886407c) at vector.c:1672
> 1672	  PetscReal      norms[4] = {0.0,0.0,0.0,0.0};
> (gdb) n
> 1676	  PetscFunctionBegin;
> (gdb) n
> 1677	  PetscValidHeaderSpecific(x,VEC_COOKIE,1);
> (gdb)
> 1678	  PetscValidHeaderSpecific(y,VEC_COOKIE,2);
> (gdb)
> [0]PETSC ERROR: --------------------- Error Message  
> ------------------------------------
> [0]PETSC ERROR: Invalid argument!
> [0]PETSC ERROR: Wrong type of object: Parameter # 2!
> ------------------------------------------------------------------
>
> Is there any better way to "duplicate" or "copy" the vector and make  
> it preserve the da properties?
>
> Thanks very much!
>
> Cheers,
>
> Rebecca
>
>
>
>



More information about the petsc-users mailing list