DACreate2d() and DAGetMatrix()

Barry Smith bsmith at mcs.anl.gov
Fri Feb 13 15:49:05 CST 2009


On Feb 12, 2009, at 2:53 PM, (Rebecca) Xuefei YUAN wrote:

> I check the matrix.c and find that the x,y,z direction has been  
> reversed as in line 1249-1252 in MatSetStencil(), can I get to know  
> why we do this?

    This is to match the code in MatSetValuesStencil() where the code  
has

       else                                       tmp = tmp*dims[j] +  
*(dxm-1) - starts[j+1];
                                                                        ^ 
^^^^^^

    I am pretty sure the code is correct (if slightly cryptic).

    Barry

>
>
> Thanks.
>
>
> 1249:   for (i=0; i<dim; i++) {
> 1250:     mat->stencil.dims[i]   = dims[dim-i-1];      /* copy the  
> values in backwards */
> 1251:     mat->stencil.starts[i] = starts[dim-i-1];
> 1252:   }
>
> Quoting "(Rebecca) Xuefei YUAN" <xy2102 at columbia.edu>:
>
>> I think the dims should be {9,5,4,0} if it is Xperiodic, and should  
>> be
>> {5,9,4,0} if it is Yperiodic. Am I right?
>>
>> Thanks,
>>
>> Rebecca
>>
>>
>> Quoting "(Rebecca) Xuefei YUAN" <xy2102 at columbia.edu>:
>>
>>> If I have -da_grid_x 5 -da_grid_y 5 -dmmg_nlevels 1 and the DA and
>>> jacobian like:
>>>>> ierr = DMMGCreate(comm, 1, &appCtx, &dmmg);CHKERRQ(ierr);
>>>>> 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);
>>>>> ierr = DAGetMatrix(DMMGGetDA(dmmg), MATAIJ,  
>>>>> &jacobian);CHKERRQ(ierr);
>>>
>>> will that be right if I have jacobian->stencil.dims ={5, 9, 4, 0}?
>>>
>>> Thanks,
>>>
>>> Rebecca
>>>
>>>
>>>
>>> Quoting Barry Smith <bsmith at mcs.anl.gov>:
>>>
>>>>
>>>> The dof argument to DACreate2d() is greater than 1. Thus the
>>>> "dimension" that is associated with the matrix is 3 dimensions.  Is
>>>> this causing a problem?
>>>>
>>>>
>>>> Barry
>>>>
>>>> Note: the "dimension" of the matrix affects the  
>>>> MatSetValuesStencil()
>>>> but not much else I can think of;
>>>>
>>>>
>>>> On Feb 12, 2009, at 11:44 AM, (Rebecca) Xuefei YUAN wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I use the following set of codes to create the jacobian  
>>>>> matrix,    however, the dimensions of jacobian becomes 3 (dim=3)  
>>>>> although I    use DACreate2d to create this da. I wanna know  
>>>>> where is wrong?
>>>>>
>>>>> ierr = DMMGCreate(comm, 1, &appCtx, &dmmg);CHKERRQ(ierr);
>>>>> 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);
>>>>> ierr = DAGetMatrix(DMMGGetDA(dmmg), MATAIJ,  
>>>>> &jacobian);CHKERRQ(ierr);
>>>>>
>>>>> Thanks very much!
>>>>>
>>>>> Rebecca
>>>
>>>
>>>
>>> -- 
>>> (Rebecca) Xuefei YUAN
>>> Department of Applied Physics and Applied Mathematics
>>> Columbia University
>>> Tel:917-399-8032
>>> www.columbia.edu/~xy2102
>>
>>
>>
>> -- 
>> (Rebecca) Xuefei YUAN
>> Department of Applied Physics and Applied Mathematics
>> Columbia University
>> Tel:917-399-8032
>> www.columbia.edu/~xy2102
>
>
>
> -- 
> (Rebecca) Xuefei YUAN
> Department of Applied Physics and Applied Mathematics
> Columbia University
> Tel:917-399-8032
> www.columbia.edu/~xy2102
>



More information about the petsc-users mailing list