CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

How to display lagrangian particles on a slice?

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 21, 2022, 16:52
Default How to display lagrangian particles on a slice?
  #1
Member
 
Huan Zhang
Join Date: Nov 2020
Posts: 48
Rep Power: 4
Jasper Z is on a distinguished road
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
Jasper Z is offline   Reply With Quote

Old   August 21, 2022, 22:52
Default
  #2
Member
 
Huan Zhang
Join Date: Nov 2020
Posts: 48
Rep Power: 4
Jasper Z is on a distinguished road
Is there any suggestions? Very appreciate!
Jasper Z is offline   Reply With Quote

Old   September 7, 2022, 06:53
Default
  #3
Member
 
Join Date: Jun 2020
Posts: 83
Rep Power: 4
atul1018 is on a distinguished road
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
atul1018 is offline   Reply With Quote

Old   September 8, 2022, 03:54
Default
  #4
Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 88
Rep Power: 3
joshwilliams is on a distinguished road
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]<z_coord*(1-thickness_pct/100)
  del_inds = np.where(cut_less_than_slice | cut_larger_than_slice)
  pos = np.delete(pos, del_inds, axis=0)
  return pos

# find and read VTK object
fname = glob("VTK/lagrangian/kinematicCloud/kinematicCloud_*.vtk")
assert len(fname) >=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)
joshwilliams is offline   Reply With Quote

Old   September 8, 2022, 06:40
Default
  #5
Member
 
Join Date: Jun 2020
Posts: 83
Rep Power: 4
atul1018 is on a distinguished road
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
atul1018 is offline   Reply With Quote

Old   September 8, 2022, 06:56
Default
  #6
Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 88
Rep Power: 3
joshwilliams is on a distinguished road
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.
joshwilliams is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF in case with DPM modle POSTHU Fluent UDF and Scheme Programming 0 March 3, 2021 08:21
Radiation heating of lagrangian particles in reactingParcelFoam CHUIKOV OpenFOAM Running, Solving & CFD 0 February 28, 2021 15:53
Corellation dimension of lagrangian particles oswald OpenFOAM Post-Processing 0 January 27, 2016 08:30
Add lagrangian particles to OpenFoam solver luchen2408 OpenFOAM 0 June 2, 2015 04:10
errors when installing openfoam2.1 on ubuntu12.o4 hewei OpenFOAM Installation 5 May 29, 2012 08:43


All times are GMT -4. The time now is 12:14.