[petsc-users] Position based coupling matrix

Barry Smith bsmith at mcs.anl.gov
Thu Mar 19 12:00:41 CDT 2015


> On Mar 19, 2015, at 4:42 AM, Mohammad Imtiaz <M.Imtiaz at victorchang.edu.au> wrote:
> 
> Thank you, I am trying this now.
> 
> One more question:
> 
> I am my assigning my coupling matrix R as one of the state variable in the
> DMDA passed to RHS function even though R does not change once
> initialized.

   Not sure what you mean by this.
>  Is this the most efficient way to do this?

  So long as you are just passing around the Mat R then it is efficient, since R is just a pointer to the data structure. If you are calling MatDuplicate() on R or  creating a new R repeatedly then no it would not be efficient.

   Barry

> 
> Thanks
> Mohammad
> 
> 
> 
> 
> 
> 
> On 18/03/2015 2:10 am, "Barry Smith" <bsmith at mcs.anl.gov> wrote:
> 
>> 
>> You will need to associate the vector with a DMDA so you can use
>> DMDAVecGetArray() to index into it. Use DMCreateGlobalVector (with the
>> appropriate DMDA) to get the vector instead of VecCreate() before you do
>> the VecLoad().
>> 
>> Barry
>> 
>> 
>>> On Mar 17, 2015, at 6:15 AM, Mohammad Imtiaz
>>> <M.Imtiaz at victorchang.edu.au> wrote:
>>> 
>>> Hi,
>>> 
>>> I am trying to solve a 2 dimensional finite difference reaction
>>> diffusion problem where diffusional coupling is position based, i.e.
>>> fibres, discontinuities etc occur due to material properties (e.g. Heart
>>> tissue).
>>> 
>>> I have managed to import a matlab matrix representing coupling in four
>>> directions as below:
>>> 
>>>    PetscViewerBinaryOpen(PETSC_COMM_WORLD,²R",FILE_MODE_READ,&fd);
>>>    VecCreate(PETSC_COMM_WORLD,&R);
>>>    VecLoad(R,fd);
>>> 
>>> Š..Repeated to get L, U, D, coupling.
>>> 
>>> How can I now make R,L,U,D available to my finite difference part of
>>> the code? So that I can do
>>> 
>>> 
>>> v is field.
>>> 
>>> vxx = u[j][i].R*(u[j][i-1].v - u[j][i].v)  + u[j][i].L*(u[j][i+1].v ­
>>> u[j][i].v);
>>> 
>>> And similarly for up & down coupling.
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Thanks
>>> Mohammad Imtiaz
>> 
>> Scanned by Messagelabs ***



More information about the petsc-users mailing list