# How to display lagrangian particles on a slice?

 Register Blogs Members List Search Today's Posts Mark Forums Read

 August 21, 2022, 16:52 How to display lagrangian particles on a slice? #1 Member   Huan Zhang Join Date: Nov 2020 Posts: 48 Rep Power: 4 Dear all, I have particles in a 3d column, but I want to display the particles at a slice (e.g., center-plane), how can I do it in ParaView? Any suggestions? Thanks! Jasper

 August 21, 2022, 22:52 #2 Member   Huan Zhang Join Date: Nov 2020 Posts: 48 Rep Power: 4 Is there any suggestions? Very appreciate!

 September 7, 2022, 06:53 #3 Member   Join Date: Jun 2020 Posts: 83 Rep Power: 4 Hello I am also looking for solutions to get 2-D packing at severals planes in 3D packing. here is my post: Plotting small particle fraction profiles along depth in 3D packing as you see i tried with clip filter but it doesnt produce 2-d planes cutting packing across specified plane. May be in your case it is useful. Let me know if you find another solution to visualize it. Best Regards Atul Jaiswal

 September 8, 2022, 03:54 #4 Member   Josh Williams Join Date: Feb 2021 Location: Scotland Posts: 88 Rep Power: 3 Hi, To do this in paraview, you would need to create a small box maybe around 1-2% of the axis length (using `clip' tool), because if you take a slice, very few particles will be exactly on the slice. Then you can use `glyph' to visualise them. Alternatively, I have used Python for this Code: ```from glob import glob import vedo as v import matplotlib.pyplot as plt import numpy as np def get_slices(pos, axis_to_slice=2, z_coord=3.0, thickness_pct=1): """ pos (np.ndarray) : particle positions axis_to_slice (int, 0,1 or 2) : which axis to be normal to cross section z_coord (float) : z-location to take slice at thickness_pct (float) : thickness of slice to take cross section at """ cut_larger_than_slice = pos[:, 2]>z_coord*(1+thickness_pct/100) cut_less_than_slice = pos[:, 2]=1, "no vtk files found" particles = v.load(fname[0]) marker_size = 2 z_coord = 1 # location that you want to take cross section at pos = particles.points() pos = get_slices(pos, z_coord=z_coord) del particles print("particles in slice", pos.shape[0]) xsize = 8.0 / 2.54 fig, ax = plt.subplots(1,1, figsize=(xsize, xsize)) ax.scatter(pos[:, 0], pos[:, 1], s=marker_size, c="black", marker='o', facecolors='black',) ax.axis('off') ax.autoscale_view('tight') # fig.tight_layout() plt.show() # plt.savefig('image.png', bbox_inches='tight',pad_inches = 0, dpi=400)```

 September 8, 2022, 06:40 #5 Member   Join Date: Jun 2020 Posts: 83 Rep Power: 4 Hi Josh It would be great if you cpuld share your .VTK file on which I can test the python code. I am not familiar with python and it difficlut to follow without example. I have sent you my private email address via private message here. Best Regards Atul

 September 8, 2022, 06:56 #6 Member   Josh Williams Join Date: Feb 2021 Location: Scotland Posts: 88 Rep Power: 3 Hi Atul, You can generate data for this by running the MPPICFoam tutorial "injectionChannel" (available in OpenFOAM 6). To generate VTK file for LIGGGHTS, you can use LPP (link). If you are not familiar with python, maybe easier to go with the "box" clipping approach I mentioned in Paraview.