Mfem: Advices for handling periodic boundary conditions

Created on 2 Oct 2020  路  4Comments  路  Source: mfem/mfem

I wish to define several cases with periodic boundary conditions. What are the input mesh formats that allow for handling such boundary conditions ? While MFEM mesh format is read correctly to define periodic condition, GMSH mesh format periodic semantic is not understood from the tests I made. Does the GMSH reader in MFEM is able to understand the periodic tags of GMSH format ?

What would recommend to me as an input mesh format for defining periodic boundary conditions for not so simple geometries ?

Should I consider writing an extension of the MFEM GMSH reader ? Would it be better to try to convert GMSH to MFEM mesh format ?

Which mesh generator do you use usually to produce meshes encoded with MFEM mesh format ?

mesh usage

Most helpful comment

Thanks a lot for the information given. As I was working with MFEM release 4.1, I did not have access to the mesh reader that handles Periodic section. Switching to the master branch helped me much.

From my experience, Gmsh does not complain much if no match are found for vertices on periodic surfaces. Thanks to you advices, I figured out to get a tetrahedral mesh that works well. I mean, I finally obtain a Periodic section in output of Gmsh that includes a list of vertices.

I will postponed the quest for a periodic mesh with hexaedra for the moment.

Regards.
Guillaume.

All 4 comments

Hello, @latug0 ,

Either approach should be possible. If you work directly with MFEM meshes you could follow the advice given here. This involves copying a small amount of code from a specific branch of MFEM since this solution is not in master yet.

The Gmsh option should work without making any changes to MFEM and it will probably be more computationally efficient. Our Gmsh periodic mesh support has been tested with meshes using Gmsh's 2.2 and 4.1 formats. I believe the version 2.2 meshes may be more fully supported. There are two main things you need to check when generating Gmsh meshes. First, make sure all of your Physical Volumes and Physical Surfaces are given integer tags which are greater than zero (the Gmsh default is zero and MFEM will not accept this). Second, try to remove extraneous curves and surfaces from the output mesh file. For example, in a 3D mesh MFEM makes the assumption that any 2D elements are part of the boundary of the 3D mesh. If the Gmsh file contains 2D elements which don't lie on the surface of a 3D element MFEM will fail. A similar restriction applies in 2D meshes concerning extra 1D elements.

We'd like to make our Gmsh support as robust as possible so if you have trouble please let us know. If you can supply Gmsh scripts and meshes which MFEM cannot read we'd be happy to help you troubleshoot the problem.

Best wishes,
Mark

Thanks for your answer.
I think, I followed your recommandations to build my meshes, but I failed to get Periodic boundary conditions recognized within MFEM with GMSH input format.

I join you the "same" cube built with GMSH and with MFEM mesh format. There are two dimensions "Y" and "Z" with periodic BCs and a single dimension "X" without periodic BC. I gave these two versions to a single MFEM program. With the MFEM input mesh, I get the periodic conditions working well, while whith the GMSH file input, I can not recover the periodicity and I get results identical as if I had no periodic BCs at all.

cube_gmsh.msh.txt
cube_gmsh.mesh.txt
cube_gmsh.geo.txt

Would you please tell me where the "Periodic" keyword of GMSH mesh format are read within MFEM ? Hence, I can understand where I should find out where I missed something or where I should fix something ...

Hi, @latug0 ,

The Periodic section of a Gmsh file is read on line 2003 of mesh/mesh_readers.cpp. However, that's not going to help you much. Notice the lines after the Affine lines in the Periodic section of your cube_gmsh.msh.txt file. These are 0 which indicates that Gmsh found no vertices on the periodic surfaces. I suspect Gmsh issued an error such as:

No periodic vertices in surface 4 (maybe due to a structured mesh constraint on the target surface) 

As I understand it, this is a limitation in Gmsh. I've seen @bslazarov use a workaround involving building the mesh as an extruded volume but I'm not sure if that would work in this case. One alternative is to build a tetrahedral mesh which seems to work fine with periodic boundaries.

Another issue is that MFEM does not support the Gmsh 3 file format. We support 2.2 and to a limited extent 4.1. The version can be controlled from the .geo file by adding the following lines near the end of the file:

Mesh 3;
Mesh.MshFileVersion = 2.2;

The trouble with the newer formats is that they sometimes define node coordinates using parameterizations which MFEM does not recognize. Also, I haven't found the documentation for file format version 3 so I wouldn't know where to begin. We do have a pull request (PR #763) which adds support for version 4 and 4.1 but development on this has stalled and I'm not sure why.

Best wishes,
Mark

Thanks a lot for the information given. As I was working with MFEM release 4.1, I did not have access to the mesh reader that handles Periodic section. Switching to the master branch helped me much.

From my experience, Gmsh does not complain much if no match are found for vertices on periodic surfaces. Thanks to you advices, I figured out to get a tetrahedral mesh that works well. I mean, I finally obtain a Periodic section in output of Gmsh that includes a list of vertices.

I will postponed the quest for a periodic mesh with hexaedra for the moment.

Regards.
Guillaume.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tuckerbabcock picture tuckerbabcock  路  4Comments

kvoronin picture kvoronin  路  3Comments

jandrej picture jandrej  路  4Comments

tbarani picture tbarani  路  3Comments

thorvath12 picture thorvath12  路  3Comments