[petsc-users] interpolate HDF5 mesh

Matthew Knepley knepley at gmail.com
Thu Dec 20 16:01:24 CST 2018


On Thu, Dec 20, 2018 at 4:55 PM Yann Jobic <yann.jobic at univ-amu.fr> wrote:

>
> On 20/12/2018 21:33, Matthew Knepley wrote:
>
> On Thu, Dec 20, 2018 at 2:35 PM Yann JOBIC <yann.jobic at univ-amu.fr> wrote:
>
>> Le 20/12/2018 à 19:05, Matthew Knepley a écrit :
>>
>> On Thu, Dec 20, 2018 at 12:56 PM Yann JOBIC <yann.jobic at univ-amu.fr>
>> wrote:
>>
>>> Le 20/12/2018 à 16:40, Matthew Knepley a écrit :
>>>
>>> On Thu, Dec 20, 2018 at 9:33 AM Yann JOBIC via petsc-users <
>>> petsc-users at mcs.anl.gov> wrote:
>>>
>>>> Dear Petsc Users,
>>>>
>>>> When i'm using DMPlexCreateBoxMesh, my code works fine. However, when i
>>>> load the "exact" same mesh from an HDF5 file, it's not working anymore
>>>> (Nonlinear solve did not converge due to DIVERGED_FNORM_NAN iterations
>>>> 0).
>>>>
>>>> The mesh view when i use DMPlexCreateBoxMesh looks like (i labeled my
>>>> boudary nodes):
>>>>
>>>> /* generated with DMPlexCreateBoxMesh */
>>>> DM Object: Mesh 1 MPI processes
>>>>    type: plex
>>>> Mesh in 3 dimensions:
>>>>    0-cells: 216
>>>>    1-cells: 540
>>>>    2-cells: 450
>>>>    3-cells: 125
>>>> Labels:
>>>>    Faces: 6 strata with value/size (2 (121), 4 (121), 3 (121), 6 (121),
>>>> 5 (121), 7 (121))
>>>>    boundary: 1 strata with value/size (1 (602))
>>>>    depth: 4 strata with value/size (0 (216), 1 (540), 2 (450), 3 (125))
>>>>    Face Sets: 6 strata with value/size (6 (25), 5 (25), 3 (25), 4 (25),
>>>> 1 (25), 2 (25))
>>>>    marker: 1 strata with value/size (1 (450))
>>>>
>>>> And when i use DMPlexCreateFromFile, or DMLoad, i have :
>>>>
>>>> /* generated with H5 file */
>>>> fin label DM
>>>> DM Object: Mesh 1 MPI processes
>>>>    type: plex
>>>> Mesh in 3 dimensions:
>>>>    0-cells: 216
>>>>    1-cells: 540
>>>>    2-cells: 450
>>>>    3-cells: 125
>>>> Labels:
>>>>    Faces: 6 strata with value/size (2 (121), 4 (121), 6 (121), 7 (121),
>>>> 5 (121), 3 (121))
>>>>    boundary: 1 strata with value/size (1 (602))
>>>>    depth: 4 strata with value/size (0 (216), 1 (540), 2 (450), 3 (125))
>>>>
>>>> It looks like my DM is not interpolated. Am i wrong ?
>>>>
>>>
>>> Its interpolated (you have 4 kinds of k-cells, instead of 2). However,
>>> you are missing your
>>> Face Sets marker, which probably means boundary conditions are not
>>> getting applied.
>>>
>>> My Face marker is label to 1, with the label  "boundary" (i used
>>> DMPlexMarkBoundaryFaces)
>>> After that, i create a new label, "Faces", with the number associated to
>>> the boundary condition.
>>> Faces = 0 -> ouest
>>> Faces = 1 -> est
>>> ...
>>>
>>> But you're right, I'm missing "Face Sets".
>>>
>>
>> You are also missing "marker". Both of these are added by the mesh
>> creation function. Do you know
>> which one you are using (setting in a boundary condition)?
>>
>> I'm using DMPlexLoad_HDF5_Internal, which doesn't add those markers.
>> I'm using the label "Faces", that i create, with has a different value
>> defining the physical location of the boundary.
>> Next, my using this label in order to define my boundary condition, as :
>>   ierr = PetscDSAddBoundary(prob, DM_BC_ESSENTIAL, "wall", "Faces", 0,
>> Ncomp, components, (void (*)(void)) zero, NInd, nord, NULL);CHKERRQ(ierr);
>>   ierr = PetscDSAddBoundary(prob, DM_BC_ESSENTIAL, "wall", "Faces", 0,
>> Ncomp, components, (void (*)(void)) zero, NInd, sud, NULL);CHKERRQ(ierr);
>>   ierr = PetscDSAddBoundary(prob, DM_BC_ESSENTIAL, "wall", "Faces", 0,
>> Ncomp, components, (void (*)(void)) zero, NInd, Back, NULL);CHKERRQ(ierr);
>>   ierr = PetscDSAddBoundary(prob, DM_BC_ESSENTIAL, "wall", "Faces", 0,
>> Ncomp, components, (void (*)(void)) zero, NInd, Top, NULL);CHKERRQ(ierr);
>>   ierr = PetscDSAddBoundary(prob, DM_BC_ESSENTIAL, "in", "Faces", 0,
>> Ncomp, components, (void (*)(void)) uIn, NInd, west, NULL);CHKERRQ(ierr);
>> With:
>>   const PetscInt Ncomp = 3; /*  dim = 3 */
>>   const PetscInt components[] = {0,1,2};
>>   const PetscInt NInd = 1;
>>   const PetscInt west[] = {2}; /* (x=0) */
>>   const PetscInt est[] = {3}; /* (x=L_x) */
>>   const PetscInt sud[] = {4}; /* (y=0) */
>>   const PetscInt nord[] = {5}; /* (y=L_y) */
>>   const PetscInt Back[] = {6}; /* (z=0) */
>>   const PetscInt Top[] = {7}; /* (z=L_z) */
>>
>> Is it the right way to do it ?
>>
>
> It looks right.
>
>
>> Should i have a different label for each boundary condition ? I thought
>> that the value was enough.
>>
>
> The next thing to do is compare residuals.
>
> I found the bugs. I had one code which has a hard coded domain length....
> (which was incorrect for the hdf5 file)
>
> The other one was more tricky. In the function where i put boundary
> values, i had to specify the exact same value at the corners (imposed more
> than once).
>
> I first thought that the last one to change it will be imposed, but no,
> otherwise it crashed.
>
> Everything is working now.
>
> Thanks a lot !!
>
> Great!

   Matt

> Yann
>
>
>    Matt
>
>
>> Thanks,
>>
>> Yann
>>
>>
>>   Thanks,
>>
>>     Matt
>>
>>
>>> I couldn't find the function which adds this label.
>>> Is there one ? or do i have to do as in  DMPlexCreateCubeMesh_Internal?
>>>
>>> Thanks,
>>>
>>> Yann
>>>
>>>   Thanks,
>>>
>>>     Matt
>>>
>>>
>>>> It's strange, because when i use DMPlexCreateFromFile, i put PETSC_TRUE
>>>> for interpolation.
>>>>
>>>> Even after loading the mesh, i used DMPlexInterpolate, which return a
>>>> new DM (not null).
>>>>
>>>> Do you know what's happening here ?
>>>> Maybe my DIVERGED_FNORM_NAN comes from another part of the code ?
>>>> (however only the mesh is changing)
>>>>
>>>> Thanks,
>>>>
>>>> Yann
>>>>
>>>
>>
>
> --
> 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/20181220/62adeb17/attachment.html>


More information about the petsc-users mailing list