CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [General] Depth-averaged quantities in ParaView (interFOAM simulation) (https://www.cfd-online.com/Forums/paraview/220945-depth-averaged-quantities-paraview-interfoam-simulation.html)

arhabib September 27, 2019 14:19

Depth-averaged quantities in ParaView (interFOAM simulation)
 
Hi,

How can one generate maps of depth-averaged velocity in ParaView.
I am post-processing a VOF simulation (air/water) done in interFOAM.
What I am looking for is a 2D map of depth-averaged quantities such as velocity in the entire domain. Just integrating/averaging over a vertical line won't work (I need this done in the entire domain).

Thanks

KateBradbrook May 2, 2023 11:32

1 Attachment(s)
First use calculator on results dataset to get vel=mag(U)
Then use ResampleToImage with default 100x100x100
The select programmableFilter, click "Copy Arrays" and paste in following code (also in attachment):


# Code for 'Script'.
#Note click "Copy Arrays" option to keep alpha.water to plot surface contour later
import numpy as np
#RequestData (First calc mag(U)-> vel, then ResampleToImage 100x100x100)
input0=inputs[0]
#set up variables
dp = input0.PointData["p"]/9810
dv = input0.PointData["vel"]
da = input0.PointData["alpha.water"]

#Loop through x,y directions
for i in range(0, 100):
for j in range(0, 100):
#vertical averaging
dmax=0
vsum=0
asum=0
for k in range(0, 100):
id=(k*10000)+(j*100)+i
vsum=vsum+dv[id]*da[id]
asum=asum+da[id]
if dp[id]>dmax:
dmax=dp[id]
#assign vertical averages throughout depth
vAv = 0
if dmax>0:
vAv = vsum/asum
for k in range(0, 100):
id=(k*10000)+(j*100)+i
dp[id]=dmax
dv[id]=vAv
output.PointData.append(dp,"depth")
output.PointData.append(dv,"avVel")

#Now can also use calculator to get Froude Number :-)


All times are GMT -4. The time now is 09:04.