MethodOfLines.jl icon indicating copy to clipboard operation
MethodOfLines.jl copied to clipboard

Using MethodOfLines to solve a system over a Gmsh mesh

Open 00krishna opened this issue 3 years ago • 3 comments

In seismology there seems to be some debate between finite element methods and finite difference methods for the propagation of elastic waves--the kind that come out of an earthquake. I was wondering whether there is any plan to allowing MOL to solve PDE systems over an arbitrary quadrilateral mesh. Like I would define the mesh in Gmsh, and then import the mesh into MOL as the domain.

Certainly this might not be possible yet. But I was just wondering if this is a feature that you have considered?

00krishna avatar Oct 06 '22 06:10 00krishna

I haven't considered Gmsh specifically, but had considered making this simpler by including automatic changes of variables for arbitrary curvilinear grids. Arbitrary rectilinear is supported with nonuniform grids, and quadrilateral and curvilinear by a manual change of variables, the trouble of course being finding what to substitute in.

If a suitable nonuniform axis and change of variables could be inferred from a quadrilateral gmsh file, I could support this in a few weeks. If not, this will require an entirely new backend for stencil generation which is much more difficult, but could be done with access to sufficient resources on the above.

Could you send over a few example gmsh files so I can try my hand at finding the needed information, and generalising this in code?

xtalax avatar Oct 06 '22 12:10 xtalax

@xtalax yeah that makes sense. So if I understand correctly, you just need the mesh file to provide data in a format compatible with the MOL backend. That is, the points and lines need to be easy to parse into the MOL format. Yeah, I can pull together some Gmsh examples. Also note that Gmsh can export files to a bunch of different formats--so perhaps one of those alternative formats would work if the original Gmsh *.msh format does not work.

I will see if I can generate quadrilateral or rectilinear meshes on some simple objects. I suppose I can also try to mesh using triangles and perhaps hexagons--just so you can see those file formats and how difficult it is to define the change of variables. I will get started on it today, so hopefully I will have some files for you by tomorrow.

00krishna avatar Oct 06 '22 16:10 00krishna

Hey @xtalax Alex, so I am following up. There are a few different practice meshes I can send to you. But I thought I might start with this one. So this is from a Gridap.jl tutorial, and I am including it because it will allow us to easily compare results between Gridap.jl and MOL.jl. The other nice thing about this mesh is that it comes in 2 format. So Gridap actually takes the original Gmsh *.msh file, and preprocesses it into a JSON file using a package called GridapGmsh.jl. Since you were interested in the specifics of the file format, I through that if the original *.msh file presented problems, that perhaps the equivalent JSON file might be easier to use for coordinate transformation.

This mesh is probably a bit larger than I would have liked, it is 3d and such. But hopefully it gives you a flavor of the file formats and all. If you think it is useful, I can also export this mesh to some other file formats, to help you see whether an alternative file format conforms better for parsing into MOL. Just let me know, and I can do that pretty quickly.

Keep in mind that both of these files in the attached ZIP are eqivalent meshes.

I am also working on getting a curved mesh for you. My approach is to try and find mesh examples that we can use to compare against other software. That way we can benchmark performance and diagnose issues. I might just setup a simple curved mesh in Gridap and then simulate the heat equation there. And then we can use that to compare for MOL. So let me look into that.

demo_mesh.zip

UPDATED 10/08/2022

Oh yes, I forgot that there is also a Gmsh.jl package, that handles some of this mesh parsing for you. So you might find that handy instead of writing your mesh parsing functions, etc.

00krishna avatar Oct 07 '22 17:10 00krishna