UXARRAY / uxarray

Xarray extension for unstructured climate and global weather data analysis and visualization.
https://uxarray.readthedocs.io/
Apache License 2.0
149 stars 31 forks source link

Function to Check For Meshes With Holes #898

Closed aaronzedwick closed 5 days ago

aaronzedwick commented 3 weeks ago

Proposed new feature or change:

Function that returns whether or not a mesh has holes in it. Something like this:

Grid.contains_holes()

Returns True if any holes exists and False if not.

rajeeja commented 3 weeks ago

Why can one function not work for both of them?

On Thu, Aug 22, 2024, 9:42 AM Aaron Zedwick @.***> wrote:

Proposed new feature or change:

Function that returns whether or not a mesh has holes in it. Something like this:

Grid.validate.holes_in_mesh()

Returns True if any holes exists and False if not.

— Reply to this email directly, view it on GitHub https://github.com/UXARRAY/uxarray/issues/898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALF6AR4XZLIY5REUY2JHE3ZSX2GVAVCNFSM6AAAAABM6J4QE6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ4DAOJXGI2DMNY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

aaronzedwick commented 3 weeks ago

Why can one function not work for both of them? On Thu, Aug 22, 2024, 9:42 AM Aaron Zedwick @.> wrote: Proposed new feature or change: Function that returns whether or not a mesh has holes in it. Something like this: Grid.validate.holes_in_mesh() Returns True if any holes exists and False if not. — Reply to this email directly, view it on GitHub <#898>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALF6AR4XZLIY5REUY2JHE3ZSX2GVAVCNFSM6AAAAABM6J4QE6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ4DAOJXGI2DMNY . You are receiving this because you are subscribed to this thread.Message ID: @.>

A grid with holes in it is a valid grid, so putting under the normal validation function doesn't make sense. I just need a function to return whether a grid has holes or not for the dual mesh, because if a grid has holes in it, it should be approached differently especially when it comes to DataArrays.

rajeeja commented 3 weeks ago

A grid with holes in it is a valid grid, so putting under the normal validation function doesn't make sense. I just need a function to return whether a grid has holes or not for the dual mesh, because if a grid has holes in it, it should be approached differently especially when it comes to DataArrays.

validation if you see the file grid/validation.py there are functions such as _check_connectivity _check_duplicates etc., you can add something to detect holes _detect_holes a new function is not required.

The problem is the dual mesh must be constructed in a way that respects the topology of the original mesh, which can be non-trivial. What you really need is the idea of "geometry" and "mesh", it might be doable without the computational geometry here as we limit ourselves to spherical and earth type topology/meshes.

aaronzedwick commented 3 weeks ago

A grid with holes in it is a valid grid, so putting under the normal validation function doesn't make sense. I just need a function to return whether a grid has holes or not for the dual mesh, because if a grid has holes in it, it should be approached differently especially when it comes to DataArrays.

validation if you see the file grid/validation.py there are functions such as _check_connectivity _check_duplicates etc., you can add something to detect holes _detect_holes a new function is not required.

The problem is the dual mesh must be constructed in a way that respects the topology of the original mesh, which can be non-trivial. What you really need is the idea of "geometry" and "mesh", it might be doable without the computational geometry here as we limit ourselves to spherical and earth type topology/meshes.

I opened a PR earlier with my implementation idea, could you give it a review so I can better understand how you want it to be organized? I added a similar thing as what you said above, but I don’t know that it’s exactly what you are saying.

aaronzedwick commented 3 weeks ago

899 is the PR number, I changed the name of the issue as I think it might have been poorly worded and possibly confusing. I don't want to add a new validation function, I simply just want to add a check for holes function inside of validation.py

philipc2 commented 3 weeks ago

This is a much needed check that we should include.

Looping @hongyuchen1030 in for any inputs on this. We can chat about the algorithm in next weeks UXarray meeting.

hongyuchen1030 commented 3 weeks ago

This is a much needed check that we should include.

Looping @hongyuchen1030 in for any inputs on this. We can chat about the algorithm in next weeks UXarray meeting.

All face in the Uxarray grid should be convex. And this mean there will not be any "hole" inside And before answering the "is Hole inside" algorithm, please think about the following question first:

  1. How to detect if a point is inside a face on the spherical surface. (I know the immediate answer is ray-casting, but we are on the spherical surface, so the ray will go back!)
  2. How to know an interval is "inside" a face。
  3. Why we need this "is Hole inside" function?
hongyuchen1030 commented 3 weeks ago

@aaronzedwick And I also add a comment for the current implementation in the PR https://github.com/UXARRAY/uxarray/pull/899#issuecomment-2307786474

Such implementation idea is not checking the hole, but to see if a face has FEWER nodes than other faces.

rajeeja commented 3 weeks ago

@aaronzedwick And I also add a comment for the current implementation in the PR #899 (comment)

Such implementation idea is not checking the hole, but to see if a face has FEWER nodes than other faces.

Oh, in that case it'd come out as True for a mesh with faces with different numbers of edges (mixed mesh, eg. tri/quad/hex etc.)

hongyuchen1030 commented 3 weeks ago

@aaronzedwick And I also add a comment for the current implementation in the PR #899 (comment)

Such implementation idea is not checking the hole, but to see if a face has FEWER nodes than other faces.

Sorry for the misunderstanding about the purpose of such a function. The updated comment listed here. https://github.com/UXARRAY/uxarray/pull/899#issuecomment-2307975194

Basically my question is why this function and what's the following steps for such function.