I am trying to understand and implement how the vtkLagrangianParticleTracker (LPT) works. I tried to modify the kitchen example. Basically, replaced the vtkStreamTracer arguments with the LPT arguments. My issue is how the particle data is inputted.
The reader comes from the kitchen example and I replaced the line with point. In the code, I am missing particle arguments. I need help with creating a particle with random specifications and inputting this data into the LPT.
Thanks! This really helped me in understanding of how to implement LPT. Could you also elaborate on where the particles are spawned? For example, in the test case you provided, the spawn locations for the particles are not specified. Are they being spawned at random?
To elaborate,
If I have a (x,y,z) location, how would I input it to spawn particles at this location?
OR
If I have a line object, how would I make particles spawn along the line?
I am trying to better understand the code. I was able to port your test code to python and modify the kitchen example. I will post the codes to both for reference shortly.
Sorry for the delayed reply. As I have mentioned, I have been trying to get the kitchen example to work. For some reason, creating a surface and setting it’s component to vtk.vtkLagrangianBasicIntegrationModel.SURFACE_TYPE_BOUNCE is not working as expected. Here’s a part of the code I have written, trying to replicate the test code you provided…
# Create a plane
surfaceBounce = vtk.vtkPlaneSource()
surfaceBounce.SetOrigin(4, 0, 0)
surfaceBounce.SetPoint1(4, 3, 0)
surfaceBounce.SetPoint2(4, 0, 1)
bouncePd = surfaceBounce.GetOutput()
# Plane actor
surfaceMapper = vtk.vtkPolyDataMapper()
surfaceMapper.SetInputConnection(surfaceBounce.GetOutputPort())
surfaceActor = vtk.vtkActor()
surfaceActor.SetMapper(surfaceMapper)
surfaceActor.GetProperty().SetColor(colors.GetColor3d('Blue'))
# Set the surface tpe to bounce
surfaceTypeBounce = vtk.vtkDoubleArray()
surfaceTypeBounce.SetNumberOfComponents(1)
surfaceTypeBounce.SetName('SurfaceType')
surfaceTypeBounce.SetNumberOfTuples(bouncePd.GetNumberOfCells())
surfaceTypeBounce.FillComponent(0, vtk.vtkLagrangianBasicIntegrationModel.SURFACE_TYPE_BOUNCE)
bouncePd.GetCellData().AddArray(surfaceTypeBounce)
# Group it to send it to tracker
groupSurface = vtk.vtkMultiBlockDataGroupFilter()
groupSurface.AddInputDataObject(bouncePd)
The rest of the code is same as yours! Below is the result I am getting, the blue surface is the one I created. Do you have any debugging steps/ideas I could use to figure out what’s happening? Thanks!
I think it’s an issue with using jupyter-notebook. When I ran the same code in PyCharm, it worked fine. I tried running the whole code from a single cell in jupyter-notebook, still did not work. Do you know of any reasons what might cause this issue?
I made a mistake in the code. Forgot to do surfaceBounce.Update(). The code works fine now. Nothing to do with the IDEs. I’ll post links to the code as soon as I am done cleaning it up.
@kal this would make a nice addition to the VTK Examples. You would need to convert it to a Python script, and create a MR. Please see ForDevelopers for instructions and Guidelines for guidelines. I would recommend calling it KitchenLPT and putting it in the Visualization folder where the original Kitchen example is.