<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word; line-break: after-white-space;" class=""></div></blockquote><blockquote type="cite" class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word; line-break: after-white-space;" class=""></div></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word; line-break: after-white-space;" class="">Ahh, thanks. I was missing the option " -dm_plex_gmsh_periodic “. But using this option I now generate a segmentation fault error when calling VecView() on the solution vector with vtk and hdf5 viewers. Any suggestions?</div></blockquote></blockquote><blockquote type="cite" class=""><div class=""> </div></blockquote></blockquote><blockquote type="cite" class=""></blockquote><br class=""><blockquote type="cite" class=""><div class="">Small example? VTK is deprecated. HDF5 should work, although it will require you to have proper coordinates I think. We have to</div><div class="">think about what you mean. If its for a checkpoint, there is no problem, but for viz, those programs do not understand periodicity. Thus I embed it in a higher dimensional space.</div><div class=""><br class=""></div><div class=""> Matt</div></blockquote><div class=""><br class=""></div>Building the small example I realised that hdf5 wasn’t working altogether. I’m trying to fix this and see if I can run VecView with the periodic DMPlex then.<div class="">I planned using this for visualisation. <br class=""><div class=""><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On 25. Oct 2018, at 15:36, Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" class="">stefano.zampini@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class="">Maybe this is a fix<div class=""><br class=""></div><div class=""><div class="">diff --git a/src/dm/impls/plex/plexvtu.c b/src/dm/impls/plex/plexvtu.c</div><div class="">index acdea12c2f..1a8bbada6a 100644</div><div class="">--- a/src/dm/impls/plex/plexvtu.c</div><div class="">+++ b/src/dm/impls/plex/plexvtu.c</div><div class="">@@ -465,10 +465,11 @@ PetscErrorCode DMPlexVTKWriteAll_VTU(DM dm,PetscViewer viewer)</div><div class=""> if ((closure[v] >= vStart) && (closure[v] < vEnd)) {</div><div class=""> PetscScalar *xpoint;</div><div class=""> </div><div class="">- ierr = DMPlexPointLocalRead(dm,v,x,&xpoint);CHKERRQ(ierr);</div><div class="">+ ierr = DMPlexPointLocalRead(dm,closure[v],x,&xpoint);CHKERRQ(ierr);</div><div class=""> y[cnt + off++] = xpoint[i];</div><div class=""> }</div><div class=""> }</div><div class="">+ cnt += off;</div><div class=""> ierr = DMPlexRestoreTransitiveClosure(dm, c, PETSC_TRUE, &closureSize, &closure);CHKERRQ(ierr);</div><div class=""> }</div><div class=""> }</div></div><div class=""><br class=""></div><div class="">Max, does this fix your problem? If you confirm, I'll fix this in the maint branch</div></div></div></div></div></blockquote><div><br class=""></div>It did indeed fix the issue! Thank you. I’ve had problems with hdf5 before and switched to vtk. It’s good news I can continue to use it.<br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">If I run the below command line with the patch and with snes tutorials ex12 I get the nice picture attached</div><div class="">$ ./ex12 -quiet -run_type test -interpolate 1 -bc_type dirichlet -petscspace_degree 1 -vec_view vtk:test.vtu:vtk_vtu -f ${PETSC_DIR}/share/petsc/datafiles/meshes/square_periodic.msh -dm_plex_gmsh_periodic -x_periodicity periodic -y_periodicity periodic -dm_refine 4<br class=""></div></div></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">Il giorno gio 25 ott 2018 alle ore 15:11 Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" class="">stefano.zampini@gmail.com</a>> ha scritto:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class="">Matt,</div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">you can reproduce it via<div class=""><br class=""></div><div class="">$ valgrind ./ex12 -quiet -run_type test -interpolate 1 -bc_type dirichlet -petscspace_degree 1 -vec_view vtk:test.vtu:vtk_vtu -f ${PETSC_DIR}/share/petsc/datafiles/meshes/square_periodic.msh -dm_plex_gmsh_periodic<br class=""></div><div class=""><br class=""></div><div class="">Long time ago I added support for viewing meshes with periodic vertices in the VTK_VTU viewer, but I did not fix the part that writes fields</div><div class=""><br class=""></div></div></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">Il giorno mer 24 ott 2018 alle ore 21:04 Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" class="">knepley@gmail.com</a>> ha scritto:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Oct 24, 2018 at 11:36 AM Maximilian Hartig <<a href="mailto:imilian.hartig@gmail.com" target="_blank" class="">imilian.hartig@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 24. Oct 2018, at 12:49, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" class="">knepley@gmail.com</a>> wrote:</div><br class="m_3925837018042710958m_-5388742668316797550m_1819301664155549261Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Oct 24, 2018 at 6:29 AM Lawrence Mitchell <<a href="mailto:wence@gmx.li" target="_blank" class="">wence@gmx.li</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hi Max,<br class=""><br class="">(I'm cc'ing in the petsc-users mailing list which may have more advice, if you are using PETSc you should definitely subscribe!<br class=""><br class="">> On 24 Oct 2018, at 09:27, Maximilian Hartig <<a href="mailto:imilian.hartig@gmail.com" target="_blank" class="">imilian.hartig@gmail.com</a>> wrote:<br class="">><span class="m_3925837018042710958m_-5388742668316797550m_1819301664155549261Apple-converted-space"> </span><br class="">> Hello Lawrence,<br class="">><span class="m_3925837018042710958m_-5388742668316797550m_1819301664155549261Apple-converted-space"> </span><br class="">> sorry to message you out of the blue. My name is Max and I found your post on GitHub (<a href="https://github.com/firedrakeproject/firedrake/issues/1246" rel="noreferrer" target="_blank" class="">https://github.com/firedrakeproject/firedrake/issues/1246</a><span class="m_3925837018042710958m_-5388742668316797550m_1819301664155549261Apple-converted-space"> </span>) on DMPlex being able to read periodic gmsh files. I am currently trying to do just that (creating a periodic DMPlex mesh with gmsh) in the context of my PhD work. So far I haven’ t found any documentation on the periodic BC’s with DMPlex and gmsh in the official petsc documentation.<span class="m_3925837018042710958m_-5388742668316797550m_1819301664155549261Apple-converted-space"> </span><br class="">> I was wondering whether you’d be so kind as to point me in a general direction concerning how to achieve this. You seem experienced in using petsc and I would greatly appreciate your help.<span class="m_3925837018042710958m_-5388742668316797550m_1819301664155549261Apple-converted-space"> </span><br class=""><br class=""><br class="">I think the answer is "it depends". If you're just using DMPlex directly and all the of the functionality with PetscDS, then I /think/ that reading periodic meshes via gmsh (assuming you're using the appropriate gmsh mesh format [v2]) "just works".<br class=""></blockquote><div class=""><br class=""></div><div class="">There are two phases here: topological and geometric. DMPlex represents the periodic topological entity directly. For example, a circle is just a segment with one end hooked to the other. Vertices are not duplicated, or mapped to each other. This makes topology simple and easy to implement. However, then geometry is more complicated. What Plex does is allow coordinates to be represented by a discontinuous field taking values on cells, in addition to vertices. In our circle example, each cells near the cut will have 2 coordinates, one for each vertex, but they will not agree across the cut. If you define a periodic domain, then Plex can construct this coordinate field automatically using DMPlexLocalize(). These DG coordinates are then used by the integration routines.</div></div></div></div></blockquote><div class=""><br class=""></div>Ok, I think I understand the concept. DMPlex reads information about both topology and coordinates from the .msh file. Creating a periodic mesh in gmsh then should allow DMPlex to identify the periodic boundaries as the “cut” and build the mesh topology accordingly. Coordinate information is handled separately.</div><div class="">That means, as Lawrence suggested, building periodic meshes in gmsh and reading them in to petsc’s DMPlex should indeed “just work”. (From the user perspective). The only extra step is to call DMLocalizeCoordinates() after DMPlexReadFromFile(). Sorry to reiterate, I am just trying to make sense of this. <br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class=""><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">From my side, the issue is to do with mapping that coordinate field into one that I understand (within Firedrake). You may not have this problem.<br class=""></blockquote><div class=""><br class=""></div><div class="">Firedrake uses its own coordinate mapping and integration routines, so they must manage the second part independently. I hope to get change this slightly soon by making the Firedrake representation a DMField, so that it looks the same to Plex.</div><div class=""><br class=""></div><div class=""> <span class="m_3925837018042710958m_-5388742668316797550m_1819301664155549261Apple-converted-space"> </span>Thanks,</div><div class=""><br class=""></div><div class=""> Matt</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Thanks,<br class=""><br class="">Lawrence</blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="m_3925837018042710958m_-5388742668316797550m_1819301664155549261Apple-converted-space"> </span><br class=""><div dir="ltr" class="m_3925837018042710958m_-5388742668316797550m_1819301664155549261gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="https://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a></div></div></div></div></div></div></div></div></div></blockquote><br class=""></div><div class=""><div dir="ltr" class=""></div><blockquote type="cite" class=""><div dir="ltr" class="">To read periodic meshes from GMSH, you need to use the option -dm_plex_gmsh_periodic and DMPlexCreateFromFile</div></blockquote><div class=""><br class=""></div>Ahh, thanks. I was missing the option " -dm_plex_gmsh_periodic “. But using this option I now generate a segmentation fault error when calling VecView() on the solution vector with vtk and hdf5 viewers. Any suggestions?</div></div></blockquote><div class=""><br class=""></div><div class=""> Small example? VTK is deprecated. HDF5 should work, although it will require you to have proper coordinates I think. We have to</div><div class="">think about what you mean. If its for a checkpoint, there is no problem, but for viz, those programs do not understand periodicity. Thus I embed it in a higher dimensional space.</div><div class=""><br class=""></div><div class=""> Matt</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><blockquote type="cite" class=""><div class="">See src/dm/impls/plex/examples/tests/ex1.c. An example runs</div><div class=""><br class=""></div><div class="">$ ./ex1 -filename ${PETSC_DIR}/share/petsc/datafiles/meshes/cube_periodic_bin.msh -dm_plex_gmsh_periodic -dm_view ::ascii_info_detail -interpolate -test_shape</div><div class=""><br class=""></div><div class="">generating periodic meshes in gmsh may be tricky, Lisandro for sure may advice.</div></blockquote><br class=""></div><div class="">Thanks,</div><div class="">Max</div><br class=""></div></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="m_3925837018042710958m_-5388742668316797550gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a><br class=""></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="m_3925837018042710958gmail_signature" data-smartmail="gmail_signature">Stefano</div>
</blockquote></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Stefano</div>
<span id="cid:f_jnomrujb0"><periodic.png></span></div></blockquote></div><br class=""></div></body></html>