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 Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 21, 2022, 15:52
Default How to display lagrangian particles on a slice?
  #1
Member
 
Huan Zhang
Join Date: Nov 2020
Posts: 55
Rep Power: 5
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, 21:52
Default
  #2
Member
 
Huan Zhang
Join Date: Nov 2020
Posts: 55
Rep Power: 5
Jasper Z is on a distinguished road
Is there any suggestions? Very appreciate!
Jasper Z is offline   Reply With Quote

Old   September 7, 2022, 05:53
Default
  #3
Senior Member
 
Join Date: Jun 2020
Posts: 100
Rep Power: 5
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, 02:54
Default
  #4
Senior Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 112
Rep Power: 5
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, 05:40
Default
  #5
Senior Member
 
Join Date: Jun 2020
Posts: 100
Rep Power: 5
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, 05:56
Default
  #6
Senior Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 112
Rep Power: 5
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


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 07:21
Radiation heating of lagrangian particles in reactingParcelFoam CHUIKOV OpenFOAM Running, Solving & CFD 0 February 28, 2021 14:53
Corellation dimension of lagrangian particles oswald OpenFOAM Post-Processing 0 January 27, 2016 07:30
Add lagrangian particles to OpenFoam solver luchen2408 OpenFOAM 0 June 2, 2015 03:10
errors when installing openfoam2.1 on ubuntu12.o4 hewei OpenFOAM Installation 5 May 29, 2012 07:43


All times are GMT -4. The time now is 00:44.