krober10nd / SeismicMesh

2D/3D serial and parallel triangular mesh generation tool for finite element methods.
https://seismicmesh.readthedocs.io/
GNU General Public License v3.0
123 stars 32 forks source link

Improving 2d mesh accuracy #240

Open skypalat opened 1 year ago

skypalat commented 1 year ago

Hi! I've been using SeismicMesh recently to try to generate a 2D mesh from a distance function I have defined. The results so far have been quite good, but not exact to the distances specified by my function (i.e. some edges are shorter/longer than they should be by some small, but not insignificant amount).

My particular goal relies on generating a very accurate 2D mesh, so I was wondering if there was any cleanup functions that you think could help refine the mesh to the correct edge lengths, or at least remove some of the more incorrect edge lengths? I have tried setting "perform_checks" to True, but this didn't help too much.

Any guidance you can offer on this issue would be much appreciated. Thanks in advance for your help!

krober10nd commented 1 year ago

Hi @skypalat. What does the error look like in the mesh? Can you provide some images?

You can try manipulating this L0mult parameter. It multiplies the bar lengths by a constant factor to drive movement of the mesh nodes to a convergent state in which the majority of triangles are equilateral. Perhaps make the numerator 0.4 to 0.3 or 0.2 and measure the errors.

https://github.com/krober10nd/SeismicMesh/blob/982ab5b0f28a86e4c9a741cbf659424438914d32/SeismicMesh/generation/mesh_generator.py#L418

The images you attach will be helpful in better understanding the problem.

skypalat commented 12 months ago

Hi @krober10nd thanks so much for the reply! Here's a picture/map of my desired edge length distribution an image of the mesh with annotations where things are notably going wrong, and a zoom in on the center of the mesh so you can actually see the edges well

Screen Shot 2023-07-24 at 9 57 16 PM Screen Shot 2023-07-24 at 9 41 20 PM Screen Shot 2023-07-24 at 9 39 20 PM

I will try to manipulate the L0mult parameter and see if that helps. Thanks again!

krober10nd commented 12 months ago

Ah very interesting. It also seems there's some element cleaning occurring at the end as well. This could lead to some inaccuracies.

Could you share the example mesh generation script so I can also try some things locally?

skypalat commented 12 months ago

For sure. Here's the script as well as the example data (just change the path in the jupyter notebook and everything else should run as is, although I use a plotting mechanism from the pydistmesh package that you may want to replace) seismic_ex_data.txt Link to jupyter notebook: https://drive.google.com/file/d/1P-uEzZZ_KD3H5J1EFFbzGiaFWM6FNLfp/view?usp=sharing