Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mesh line annotation for triangulations with a side in the plane #1437

Merged
merged 9 commits into from Jun 3, 2017

Conversation

lindsayad
Copy link
Member

PR Summary

Fixes issues #1273 where mesh line annotations are thrown off when a side of the triangulation lies in the slice plane. AFAICT the issue is fixed by making sure that copysign doesn't receive a 0 as the second argument for one node and a -0 as the second argument for another node.

PR Checklist

Need to add a fixed bug test

@lindsayad lindsayad requested a review from atmyers May 31, 2017 22:38
@ngoldbaum
Copy link
Member

You should be able to back out #1396 too :)

@lindsayad
Copy link
Member Author

@ngoldbaum Did you ever ID the cause of the seg faults? In studying this bug, I never got any seg faults...

@ngoldbaum
Copy link
Member

Ah, I was under the impression that #1273 was filed after andrew tried to track down the cause of he seg faults. Have you tried just running the test 100 times in a row? I can try reproducing the seg faults tomorrow. I know we ran into them on fido so we can try there if all else fails.

@lindsayad
Copy link
Member Author

lindsayad commented May 31, 2017

Yea, I don't know the history behind #1273...No, I haven't tried running it many times in a row, although I did probably end up running it 100 times in total :-) If you want to give it a shot tomorrow, please have at it!

@atmyers
Copy link
Member

atmyers commented Jun 1, 2017

Thanks for tracking this down! I think this is a separate issue from #1273.

@lindsayad
Copy link
Member Author

lindsayad commented Jun 1, 2017

So the #1273 script with master looks like this:

master

This PR fixes element boundaries in the plane issue but there's still some interesting mesh line annotations that I'm trying to wrap my head around as shown in this sweep of slices (probably have to open the picture outside the browser to really see it):

interesting_mesh_lines

@atmyers I'm trying to convince myself that this is just some interesting artifact of the fake hexahedral mesh. Have you ever gone backwards and visualized a mesh (say as a wireframe) given only coordinates and indices? E.g. my first thought would be to write out to exodus and open with paraview which has a nice wireframe visualization feature. I believe that it's possible looking at the Exodus API, but maybe a lot of work unless someone's already done it. Maybe there's a netCDF4 module method?

@ngoldbaum
Copy link
Member

That windows test failure is real. Let me know if you need a hand fixing it. I think just changing the function in the error to accept np.intp_t instead of np.float64_t should be sufficient.

@ngoldbaum
Copy link
Member

Might also make sense to use the cython.integral fused type if the last one you tried doesn't work:

http://cython.readthedocs.io/en/latest/src/userguide/fusedtypes.html#built-in-fused-types

I have a windows machine on my desk too if you want to be able to debug without waiting for appveyor. You can also remote desktop into appveyor nodes, I used that yesterday: https://www.appveyor.com/docs/how-to/rdp-to-build-worker/

@atmyers
Copy link
Member

atmyers commented Jun 1, 2017

Unfortunately, I'm having a hard time finding where exactly the fake hexahedral mesh came from. I thought I had exported it from a MOOSE sample dataset somehow, but I can't seem to find the one it came from anywhere.

It's possible that this dataset is ill-formed somehow (for example, if the node numberings don't use the normal ExodusII conventions). Is there any behaviour like this for any of the MOOSE datasets? If not, I'd be inclined to regenerate the fake dataset.

@matthewturk
Copy link
Member

If memory serves, it was indeed generated from scratch, and might be time to replace it with a new one.

@ngoldbaum
Copy link
Member

Alex mentioned to me at our group meeting that the new sample dataset doesn't have the issues he was seeing in his comment two days ago. Once the tests pass I think this is ready to go in.

if count == 2:
nlines += 1
elif count == 3:
nlines += 2
raise RuntimeError("I'm impressed you got a plane to intersect all three "
"legs of a triangle")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reword this? Imagine you're a random user who hits this error and doesn't understand the guts of what's going on here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha yes. I get snarky when a bug has foiled me for a few days...

if p3[0] * p3[1] < 0: count += 1
if p3[1] * p3[2] < 0: count += 1
if p3[2] * p3[0] < 0: count += 1
p2[j] = copysign(1.0, triangles[i, j, ax] - coord + 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment explaining why you're adding zero (if it's necessary).

https://github.com/yt-project/yt/pull/1437 this test falsely
yielded three annotation lines, whereas the correct result is four
corresponding to the four edges of the top hex face.
'''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you convert this docstring into a comment? Nose interprets the first line of a docstring on a test as the "name" of the test. That means that right now this test shows up in the test runner like this:

This test tests mesh line annotation where a z=0 slice ... ok (0.1249s)

Which I think is less useful (and greppable) than just printing the module and test function name.

@ngoldbaum ngoldbaum merged commit 9d9baed into yt-project:master Jun 3, 2017
@lindsayad lindsayad deleted the mesh_annotations_1273 branch June 3, 2017 19:56
@lindsayad lindsayad restored the mesh_annotations_1273 branch August 11, 2017 22:20
matthewturk pushed a commit to matthewturk/yt that referenced this pull request Apr 17, 2018
Fix mesh line annotation for triangulations with a side in the plane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants