Gradient at ghost cells only?

Barry Smith bsmith at mcs.anl.gov
Sat Mar 4 19:25:43 CST 2006



On Sun, 5 Mar 2006, billy at dem.uminho.pt wrote:

>
> Firstly, I would like to congratulate the PETSc team for such a great code!
>
> I send you an image of my case (all indices are global). Ghost cells are in
> yellow and white cells are the interior cells. To calculate the gradient at a
> cell, I use the gauss theorem so I need all neighbor cells for that. The
> interior points are easy I can calculate them each time in each processor since
> I have a ghost cell layer. My problem is the gradient in ghost cells because I
> need the values at pink cells but they belong to another process. I guess I
> could include these pink cells also as ghost cells and then I would have access
> to their values.
    This is the way we handle things in PETSc-Fun3d; If you need to calculate 
new gradients each time then just use double wide ghost points for all your 
vectors. If you only need to calculate them less often you can create a seperate
VecScatter to get the double-wide ghosts just when you need to.

If the gradient is linear in the cell values you can compute "your part of it",
store in a regular ghosted vector move to the other side and then add "its" part
of the gradient. Tricker but avoids the two levels of communication.

    Barry



> Or I could calculate the gradient and exchange it through
> processes using VecCreateGhost().
>
> For now I have the code working because I only use these cell-centered gradients
> for non-orthogonal corrections. So, if the grid orthogonal this term is zero.
>
>
>
>
>
>
> Quoting Barry Smith <bsmith at mcs.anl.gov>:
>
>>
>>
>> On Sat, 4 Mar 2006, billy at dem.uminho.pt wrote:
>>
>>>
>>> Hi,
>>>
>>> I need the gradient of 5 scalars at ghost cells and I was thinking of
>> creating
>>> 5x3 vectors with VecCreateGhost(). Right now, I calculate the gradient
>> during
>>> each iteration and I don't store it's value.
>>> I would like to calculate, store and exchange the gradient at the ghost
>> cells
>>> only, to minimize memory requirements. How is the best way to do that?
>> ^^^^^^^
>>     Do you not need the gradient values for the interior points? Or are you
>>
>> willing to recompute the gradients for the interior points? Why different?
>>
>>     If the gradient is the same each time why not just calculate it the
>> first
>> time and store it for later? Don't make live complicated by using
>> VecCreateGhost(), just compute them and store them in some array.
>>
>>     Barry
>>
>>
>>>
>>> Billy.
>>>
>>>
>>
>>
>
>
>




More information about the petsc-users mailing list