meshpro / dmsh

:spider_web: Simple mesh generator inspired by distmesh.
GNU General Public License v3.0
210 stars 25 forks source link

Compute_tri_areas fails with new meshplex commit #43

Closed Eslsamu closed 3 years ago

Eslsamu commented 4 years ago

Let's take this geo (but it happens for every other shape I tried as well): 0

These are the boundary coords: boundary_e=[[124.0, 18.0], [75.0, 33.0], [51.0, 54.0], [31.0, 86.0], [19.0, 124.0], [14.0, 183.0], [18.0, 221.0], [33.0, 269.0], [64.0, 310.0], [93.0, 326.0], [122.0, 332.0], [185.0, 327.0], [220.0, 311.0], [254.0, 285.0], [254.0, 156.0], [145.0, 156.0], [145.0, 215.0], [193.0, 215.0], [194.0, 248.0], [155.0, 269.0], [130.0, 269.0], [111.0, 260.0], [92.0, 234.0], [84.0, 190.0], [84.0, 159.0], [94.0, 112.0], [110.0, 91.0], [131.0, 81.0], [159.0, 84.0], [184.0, 116.0], [250.0, 101.0], [242.0, 72.0], [216.0, 36.0], [197.0, 25.0], [162.0, 18.0], [125.0, 19.0]] dmsh.Polygon(boundary_e) Then "dmsh.generate(geo, edge_size=20, verbose = False)" leads to:

.../python3.6/site-packages/meshplex/base.py", line 17, in compute_tri_areas assert numpy.all(vol2 > -1.0e-14) AssertionError Fatal Python error: Aborted

This didn't happen when I had a previos version of meshplex. Maybe the last update caused it.

nschloe commented 4 years ago

Interesting. Could you provide a full MWE that I can just copy/paste please? This makes it easier for me. (You can also make use of GitHub code fences for clarity.)

nschloe commented 4 years ago

Can you also try to produce the easiest shape possible that produces the error? This helps with testing then.

Eslsamu commented 4 years ago

For my usecase I am using segments I take from images. So they are on a larger scale. Haven't tried to downscale them.

Very simple cases like geo = dmsh.Polygon([[0,0],[0,1],[2,1],[1,0.5],[2,0]]) with edge size of 0.1 work.

This one causes the same error (first iteration btw) 0

points: [[43.0, 7.0], [43.0, 191.0], [154.0, 192.0], [156.0, 190.0], [155.0, 7.0]]

nschloe commented 4 years ago

I tried to guess what you did. This

import dmsh

geo = dmsh.Polygon([[0, 0], [0, 1], [2, 1], [1, 0.5], [2, 0]])

dmsh.generate(geo, edge_size=20, verbose=False)

works without error. This was a waste of my time.

Lesson: Always provide a full MWE!

Eslsamu commented 4 years ago

As I said, the example you mention works. The other example I provided does not. Sorry If I was not clear.

nschloe commented 4 years ago

Always provide a full MWE!

Eslsamu commented 4 years ago

Ouch, well I mean this is the MWNE I could get:

[[43.0, 7.0], [43.0, 191.0], [154.0, 192.0], [156.0, 190.0], [155.0, 7.0]]

nschloe commented 4 years ago

The complete code. I just want to copy-and-paste the whole thing to make sure I'm running the same as you are.

Eslsamu commented 4 years ago

def main(): X, cells = dmsh.generate(dmsh.Polygon([[43.0, 7.0], [43.0, 191.0], [154.0, 192.0], [156.0, 190.0], [155.0, 7.0]]), edge_size=20, verbose=False)

if name == 'main': main()

output:

Traceback (most recent call last): File "meshing.py", line 100, in main() File "meshing.py", line 97, in main [156.0, 190.0], [155.0, 7.0]]), edge_size=20, verbose=False) File "/home/samuel/MEGAsync/Thesis_Celtic/FreeformCelticKnotwork/distmesh.py", line 143, in generate f_scale=1.2, File "/home/samuel/MEGAsync/Thesis_Celtic/FreeformCelticKnotwork/distmesh.py", line 182, in distmesh_smoothing mesh = meshplex.MeshTri(mesh.node_coords, cells) File "/home/samuel/MEGAsync/Thesis_Celtic/FreeformCelticKnotwork/venv/lib/python3.6/site-packages/meshplex/mesh_tri.py", line 114, in init self.cell_volumes = compute_tri_areas(self.ei_dot_ej) File "/home/samuel/MEGAsync/Thesis_Celtic/FreeformCelticKnotwork/venv/lib/python3.6/site-packages/meshplex/base.py", line 17, in compute_tri_areas assert numpy.all(vol2 > -1.0e-14) AssertionError

nschloe commented 4 years ago
  File "/tmp/j.py", line 2
    X, cells = dmsh.generate(dmsh.Polygon([[43.0, 7.0],
    ^
IndentationError: expected an indented block

Always use code fences.

Eslsamu commented 4 years ago
  File "/tmp/j.py", line 2
    X, cells = dmsh.generate(dmsh.Polygon([[43.0, 7.0],
    ^
IndentationError: expected an indented block

Always use code fences.

Okay, sorry I didn't know how to do this on a comment here

nschloe commented 3 years ago

Should be fixed now. If the issue persists for you, feel free to reopen with an MWE.