-
Notifications
You must be signed in to change notification settings - Fork 460
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
StructuredGrid tutorials and add blank points/cells #318
Comments
Also, blank points are an interesting concept we might want to mention in this tutorial. We may need to add a wrapper to handle bank points more intuitively so that a user could pass an array of indices and have the render window automatically hide those points much like this VTK example. Perhaps we should mark any points with a NaN value as blank in StructuredGrids? And here's a snippet with PyVista: import numpy as np
import pyvista as pv
mesh = pv.StructuredGrid(*np.meshgrid(np.arange(8), np.arange(8), [1,]))
mesh.BlankPoint(27)
mesh.Modified()
mesh.plot(show_edges=True, cpos='xy', color='white', background='green') mesh.plot(show_edges=True, cpos='xy', scalars=np.arange(mesh.n_points),
background='green', cmap='Reds') And a 3D example: mesh = pv.StructuredGrid(*np.meshgrid(np.arange(8), np.arange(8), np.arange(8)))
mesh.BlankPoint(mesh.n_points-1)
mesh.BlankPoint(mesh.n_points-6)
mesh.Modified()
mesh.plot(show_edges=True, color='white', background='green') |
The issue with doing this for point arrays is that some arrays might have a NaN value where another array has a value. GoalIt may be simplest and most versatile if we simply add a property (setter/getter) for marking blank points on ...
>>> mesh.blank_points = [0, 3, 4, 27, 28]
>>> mesh.blank_points
[0, 3, 4, 27, 28] and same for bank cells: ...
>>> mesh.blank_cells = [1, 5, 18]
>>> mesh.blank_cells
[1, 5, 18] ImplementationTo implement this, we'd have to keep an internal reference array bound to the mesh sinceany user changes to the ...
>>> mesh.BlankPoint(27) # this adds a new `'vtkGhostType'` array
>>> np.argwhere(mesh['vtkGhostType'])
array([[27]])
>>> mesh['vtkGhostType'][3] = 1
>>> np.argwhere(mesh['vtkGhostType'])
array([[ 3],
[27]])
>>> mesh.UnBlankPoint(27)
>>> mesh.UpdatePointGhostArrayCache()
>>> np.argwhere(mesh['vtkGhostType'])
array([[3]])
>>> mesh.HasAnyBlankPoints()
False the last result is |
We need to create a tutorial for structured grids that walks users through how to create many different types/configurations of structured grids.
The main point of confusion I see is with what the
dimensions
mean - most users expect this to be the number of points in each axial direction, and this will work for most users. However, thedimensions
really only care about the structure of the points array and are indifferent about how many nodes are in each axial direction. I think one of the best examples to demo this point is a very curved structured grid-like (we should make a simpler example though - too much code in this):Maybe check out this example for something better
The text was updated successfully, but these errors were encountered: