[petsc-users] dmplex normal vector incorrect for periodic gmsh grids

Matthew Knepley knepley at gmail.com
Fri Dec 16 10:02:10 CST 2022


On Fri, Dec 16, 2022 at 12:22 AM Praveen C <praveen at gmx.net> wrote:

> Thank you very much. I do see correct normals now.
>
> Is there a way to set the option
>
> -dm_localize_height 1
>>
>
> within the code ?
>

The problem is that the localization happens within the Gmsh construction,
so it is difficult to insert an API.
We could use a callback, but that rapidly becomes unwieldy. If you want to
do it programmatically, I would use
PetscOptionsSetValue().

  Thanks,

      Matt


> best
> praveen
>
> On 15-Dec-2022, at 9:53 PM, Matthew Knepley <knepley at gmail.com> wrote:
>
> On Wed, Dec 14, 2022 at 9:20 AM Praveen C <praveen at gmx.net> wrote:
>
>> Hello
>>
>> I tried this with the attached code but I still get wrong normals.
>>
>> ./dmplex -dm_plex_filename ug_periodic.msh -dm_localize_height 1
>>
>> Code and grid file are attached
>>
>
> I have fixed the code. The above options should now work for you.
>
>   Thanks,
>
>       Matt
>
>
>> Thank you
>> praveen
>>
>>
>>
>> On 14-Dec-2022, at 6:40 PM, Matthew Knepley <knepley at gmail.com> wrote:
>>
>> On Wed, Dec 14, 2022 at 2:38 AM Praveen C <praveen at gmx.net> wrote:
>>
>>> Thank you, this MR works if I generate the mesh within the code.
>>>
>>> But using a mesh made in gmsh, I see the same issue.
>>>
>>
>> Because the operations happen in a different order. If you read in your
>> mesh with
>>
>>   -dm_plex_filename mymesh.gmsh -dm_localize_height 1
>>
>> then it should work.
>>
>>   Thanks,
>>
>>      Matt
>>
>>
>>> Thanks
>>> praveen
>>>
>>> On 14-Dec-2022, at 12:51 AM, Matthew Knepley <knepley at gmail.com> wrote:
>>>
>>> On Tue, Dec 13, 2022 at 10:57 AM Matthew Knepley <knepley at gmail.com>
>>> wrote:
>>>
>>>> On Tue, Dec 13, 2022 at 6:11 AM Praveen C <praveen at gmx.net> wrote:
>>>>
>>>>> Hello
>>>>>
>>>>> In the attached test, I read a small grid made in gmsh with periodic
>>>>> bc.
>>>>>
>>>>> This is a 2d mesh.
>>>>>
>>>>> The cell numbers are shown in the figure.
>>>>>
>>>>> All faces have length = 2.5
>>>>>
>>>>> But using PetscFVFaceGeom I am getting length of 7.5 for some faces.
>>>>> E.g.,
>>>>>
>>>>> face: 59, centroid = 3.750000, 2.500000, normal = 0.000000, -7.500000
>>>>> ===> Face length incorrect = 7.500000, should be 2.5
>>>>> support[0] = 11, cent = 8.750000, 3.750000, area = 6.250000
>>>>> support[1] = 15, cent = 8.750000, 1.250000, area = 6.250000
>>>>>
>>>>> There are also errors in the orientation of normal.
>>>>>
>>>>> If we disable periodicity in geo file, this error goes away.
>>>>>
>>>>
>>>> Yes, by default we only localize coordinates for cells. I can put in
>>>> code to localize faces.
>>>>
>>>
>>> Okay, I now have a MR for this:
>>> https://gitlab.com/petsc/petsc/-/merge_requests/5917
>>>
>>> I am attaching your code, slightly modified. You can run
>>>
>>>   ./dmplex -malloc_debug 0 -dm_plex_box_upper 10,10 -dm_plex_box_faces
>>> 4,4 -dm_plex_simplex 0 -dm_view ::ascii_info_detail -draw_pause 3
>>> -dm_plex_box_bd periodic,periodic -dm_localize_height 0
>>>
>>> which shows incorrect edges and
>>>
>>> ./dmplex -malloc_debug 0 -dm_plex_box_upper 10,10 -dm_plex_box_faces 4,4
>>> -dm_plex_simplex 0 -dm_view ::ascii_info_detail -draw_pause 3
>>> -dm_plex_box_bd periodic,periodic -dm_localize_height 1
>>>
>>> which is correct. If you want to control things yourself, instead of
>>> using the option you can call DMPlexSetMaxProjectionHeight() on the
>>> coordinate DM yourself.
>>>
>>>   Thanks,
>>>
>>>      Matt
>>>
>>>
>>>>   Thanks,
>>>>
>>>>     Matt
>>>>
>>>>
>>>>> Thanks
>>>>> praveen
>>>>>
>>>> --
>>>>
>>>>
>>>
>>
>> --
>> 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
>>
>> https://www.cse.buffalo.edu/~knepley/
>> <http://www.cse.buffalo.edu/~knepley/>
>>
>>
>>
>
> --
> 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
>
> https://www.cse.buffalo.edu/~knepley/
> <http://www.cse.buffalo.edu/~knepley/>
>
>
>

-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221216/1bc64f49/attachment.html>


More information about the petsc-users mailing list