[petsc-users] Non-uniform Cartisian Grid

Matthew Knepley knepley at gmail.com
Thu Feb 28 19:25:42 CST 2013


On Thu, Feb 28, 2013 at 8:05 PM, Zhenglun (Alan) Wei <zhenglun.wei at gmail.com
> wrote:

>  Dear Matt,
>     Thanks for your reply on the 1st question and I'm sorry for the
> confusion on the 2nd one.
>     In order to create a non-uniform Cartesian grid, I expected that the
> way I was programming can let me freely control the grid size. In the code
> attached in the previous E-mail, the 'DMDASetUniformCoordinate' generates a
> uniform coordinate with 100*48*48 grid number and 0.1*0.1*0.1 grid size. I
> was trying to manually double the grid size in the y-direction for the
> whole mesh with operations of DMDA in the 'SetNonUniformGrid()', which
> follows the method that /src/ksp/ksp/examples/tutorials/ex49.c used.
> However, as you can see in the figure attached in the previous E-mail, only
> the mesh on z = 0 plane and x = 0 plane has been changed to dy = 0.2; while
> I expected all mesh should have dy = 0.2 after I call
> 'SetNonUniformGrid()'.
>     Any idea about this?
>

Were you looking over all 3 directions?

  Matt


> thanks,
> Alan
>
> On 2/28/2013 6:31 PM, Matthew Knepley wrote:
>
> On Thu, Feb 28, 2013 at 7:19 PM, Zhenglun (Alan) Wei <
> zhenglun.wei at gmail.com> wrote:
>
>> Dear folks,
>>     Here are several questions following up my previous ones:
>> 1, I modified my code based on ex49.c. However, I found that if I don't
>> call 'DMDASetUniformCoordinates' before calling 'DMDAVecGetArray', then an
>> error comes up:
>> [0]PETSC ERROR: Null argument, when expecting valid pointer!
>> [0]PETSC ERROR: Null Object: Parameter # 2!
>>     The code do works if I add a call for 'DMDASetUniformCoordinates' in
>> it. However, I feel it is a waste of calling 'DMDASetUniformCoordinates'
>> since what follows this calling is to change the coordinate to a
>> non-uniform gird. Does it have any way to bypass this call or you think it
>> is fine to keep it here.
>>
>
>  If you do not call it, then you have to create the coordinate vector
> yourself. I would just call it.
>
>
>> 2, Also, if I do by this way, the outputted mesh looks weird, as shown in
>> the figure.
>>     I was trying to double the dy value manually in the
>> SetNonUniformGrid(). However, the only mesh changed is just on the z=0 and
>> x=0 plane. Here I attached my code. Do I need to do anything else except
>> DMDAVecRestoreArray() after I modified the coordinate information?
>>
>
>  I do not understand what you want here.
>
>    Matt
>
>
>> thanks,
>> Alan
>>
>>
>> On 2/26/2013 8:46 PM, Barry Smith wrote:
>>
>>> On Feb 26, 2013, at 4:49 PM, "Zhenglun (Alan) Wei"<
>>> zhenglun.wei at gmail.com>  wrote:
>>>
>>>  Dear folks,
>>>>       I have one question for the ex49.
>>>>       It do show a way to 'get' the 'coord' by the 'DMDAVecGetArray'.
>>>> Should I just modified the coordinate on the 'coord' in order to obtain a
>>>> non-uniform grid? and then, use DMDAVecRestoreArray to link the modified
>>>> 'coord' back to 'cda' so that the 'coord' will be updated to the mesh I
>>>> want?
>>>>
>>>     Yes, you can do this.
>>>
>>>
>>>  thanks,
>>>> Alan
>>>>
>>>> On 2/22/2013 3:20 PM, Matthew Knepley wrote:
>>>>
>>>>> On Fri, Feb 22, 2013 at 3:57 PM, Zhenglun (Alan) Wei<
>>>>> zhenglun.wei at gmail.com>  wrote:
>>>>> Dear all,
>>>>> I hope you're having a nice day.
>>>>> I wonder if anyone could point out a example for me about the
>>>>> DMDASetCoordinates(). I found this
>>>>> (
>>>>> http://www.mcs.anl.gov/petsc/petsc-current/src/dm/impls/da/dacorn.c.html#DMDASetCoordinates
>>>>> )
>>>>> online; however it does not really demonstrate how to create the
>>>>> 'coordinate vector - c'.
>>>>> Also, I found that in the petsc sub-folder:
>>>>> /petsc-dev/src/dm/impls/patch has a patch.c, which I suppose that it
>>>>> does a local refinement for mesh. Does this a mature model that we can
>>>>> use or just a testing code?
>>>>>
>>>>> Look at KSP ex49. In the routine DMDACoordViewGnuplot2d() it reads out
>>>>> the coordinates.
>>>>> You could just as easily set them in this fashion.
>>>>>
>>>>>     Matt
>>>>>   thanks,
>>>>> Alan
>>>>>
>>>>> On 11/7/2012 6:55 PM, Barry Smith wrote:
>>>>>
>>>>>> On Nov 7, 2012, at 6:50 PM, Alan<zhenglun.wei at gmail.com>  wrote:
>>>>>>
>>>>>>  Dear folks,
>>>>>>> I hope you're having a nice day.
>>>>>>> I'm testing the Poisson solver in
>>>>>>> /src/ksp/ksp/examples/tutorials/ex45.
>>>>>>> It uses the 'DMDACreate3d' to generate a Cartisian structured grid
>>>>>>> and
>>>>>>> solve it with uniform grid size. However, I attempt to modify it to
>>>>>>> obtain solution with a Cartsian structured grid and non-uniform grid
>>>>>>> (It
>>>>>>> is not unstructured local refined mesh). Should I still use the
>>>>>>> 'DMDACreate3d' and implement different grid size in 'ComputeMatrix'
>>>>>>> and
>>>>>>> 'ComputeRHS'? In other words, does 'DMDACreate3d' itself include any
>>>>>>> mesh size information?
>>>>>>>
>>>>>>     You can use DMDASetCoordinates() and DMDAGetCoordinates() (called
>>>>>> DMSetCoordinates() and DMGetCoordinates() in petsc-dev) to keep track of
>>>>>> the coordinates but you are responsible for generating the correctly scaled
>>>>>> entries in the matrix etc.
>>>>>>
>>>>>>     Barry
>>>>>>
>>>>>>  thanks,
>>>>>>> Alan
>>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> What most experimenters take for granted before they begin their
>>>>> experiments is infinitely more interesting than any results to which their
>>>>> experiments lead.
>>>>> -- Norbert Wiener
>>>>>
>>>>
>>
>
>
>  --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130228/7568cc01/attachment-0001.html>


More information about the petsc-users mailing list