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

feat: Distance to Wall for 2D meshes #29

Open
jrwrigh opened this issue Sep 15, 2020 · 5 comments
Open

feat: Distance to Wall for 2D meshes #29

jrwrigh opened this issue Sep 15, 2020 · 5 comments

Comments

@jrwrigh
Copy link
Member

jrwrigh commented Sep 15, 2020

Add function to compute distance from "wall" to every point in the "grid". vtkDistancePolyDataFilter

See C++ tutorial on vtkExamples website

@jrwrigh
Copy link
Member Author

jrwrigh commented Nov 28, 2020

Possibly also see this ParaView forum post for a Programmable Filter that may do the same thing.

See some little progress in /users/jrwrigh/papers/.../Plotting/addWallDist.py

@jrwrigh
Copy link
Member Author

jrwrigh commented Aug 2, 2022

pyvista has compute_implicit_distance, which may work similarly to the above PV forum post. Though that assumes that it's more flexible than the pyvista documentation specifies (which currently says the PolyData input is a surface).

Confirmed that compute_implicit_distance uses vtkImplicitPolyDataDistance.

@jrwrigh
Copy link
Member Author

jrwrigh commented Aug 2, 2022

Detailed description on vtkImplicitPolyDataDistance says it works with the explicit points on the PolyData object, so it should be agnostic to the underlying PolyData structure.
https://vtk.org/doc/nightly/html/classvtkImplicitPolyDataDistance.html#details

@jrwrigh
Copy link
Member Author

jrwrigh commented Aug 2, 2022

Note that vtkDistancePolyDataFilter calls vtkImplicitPolyDataDistance in a for loop at the end of the day. https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/General/vtkDistancePolyDataFilter.cxx#L75

@jrwrigh
Copy link
Member Author

jrwrigh commented Aug 15, 2022

When @prestonTee tried to use the compute_implicit_distance, but ran into the following error:

ERROR:root:No polygons to evaluate function!

This points back to this line. In order for it to calculate the signed distance, it needs to know cell normals. But to get cell normals, it needs an actual 3D cell (since VTK is implicitly always 3D). In fact, it actually filters out the vertices and edges of the input mesh (see here). Thus it can't be used with what we're trying to do. Instead, something like:

d2wall = np.zeros(grid.npoints)
d2wallpnt = np.zeros(grid.npoints)

for i in range(wall.npoints):
    d2wallpnt = np.linalg.norm(grid.points - wall.points[i,:], axis=1)
    d2wall = np.min(d2wall, d2wallpnt, axis=1)

should work fine, if being a bit more memory intensive.

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

No branches or pull requests

1 participant