CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[OpenFOAM] Obtain average pressure over a range of slices?

Register Blogs Community New Posts Updated Threads Search

Like Tree9Likes
  • 2 Post By Nucleophobe
  • 7 Post By Nucleophobe

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 11, 2013, 11:55
Default Obtain average pressure over a range of slices?
  #1
Member
 
Join Date: Aug 2012
Posts: 68
Blog Entries: 1
Rep Power: 14
Nucleophobe is on a distinguished road
I am trying to post-process some data in an irregular geometry with internal flow.

I have created a range of x-normal slices, and would like to calculate the average pressure over each slice. However, when I apply the 'Integrate Variables' filter in paraview, I obtain the average pressure over the entire range instead of the average pressure over each slice.

I could of course manually move a single slice and write down data points, but this is tedious if I want the average at say 100 different x-positions.

Is there a faster way to do this?

Thanks!
-Nuc
Nucleophobe is offline   Reply With Quote

Old   April 11, 2013, 12:45
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Nucleophobe View Post
I am trying to post-process some data in an irregular geometry with internal flow.

I have created a range of x-normal slices, and would like to calculate the average pressure over each slice. However, when I apply the 'Integrate Variables' filter in paraview, I obtain the average pressure over the entire range instead of the average pressure over each slice.

I could of course manually move a single slice and write down data points, but this is tedious if I want the average at say 100 different x-positions.

Is there a faster way to do this?

Thanks!
-Nuc
In OpenFOAM the way to go would be a sampleSurface. I'm a bit ignorant and not sure whether there is a built-in utility in OF that does averaging on them (sample at least writes them out). I'd do it in swak4foam where you can do calculations on those (area weighted average pressure would be "sum(area()*p)/sum(area())"). The thing that swak does not solve is the 100 slices. But instead of tediously generating them by hand you could generate the definition of the 100 functionObjects via a script ... which stretches the definition of easy for most people ... I know (there is even something built into swak to do the generation on the fly ...)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   April 11, 2013, 13:52
Default
  #3
Member
 
Join Date: Aug 2012
Posts: 68
Blog Entries: 1
Rep Power: 14
Nucleophobe is on a distinguished road
Hmmm.. This isn't exactly what I'm looking for. The advantage of doing this is in Paraview is that I can clip the geometry so that the slice only passes through the region in which I am interested.

I have been trying to accomplish my goal by:
1) Creating a slice, say at x = 0
2) Applying the 'Integrate Variables' filter to the slice
3) Animating the slice offset, so that it moves from x = 0 to x = 10 over 10 seconds
4) Applying 'Plot selection over time' to the result of 'Integrate Variables'

This ALMOST works. The variables in the 'Integrate Variables' table update during the animation as desired. However, the plot (step 4) does not work, and the data from the table is not saved during the animation.

Edit:
Basically I'm trying to do the same thing as what was discussed here:
http://www.paraview.org/pipermail/pa...er/019544.html
It looks like programming an extra filter is the best way to go?
Any ideas on how to save the results from 'Integrate Variables' at each animation time step?
manuc and cfd lover like this.
Nucleophobe is offline   Reply With Quote

Old   April 11, 2013, 14:11
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Nucleophobe View Post
Hmmm.. This isn't exactly what I'm looking for. The advantage of doing this is in Paraview is that I can clip the geometry so that the slice only passes through the region in which I am interested.

I have been trying to accomplish my goal by:
1) Creating a slice, say at x = 0
2) Applying the 'Integrate Variables' filter to the slice
3) Animating the slice offset, so that it moves from x = 0 to x = 10 over 10 seconds
4) Applying 'Plot selection over time' to the result of 'Integrate Variables'

This ALMOST works. The variables in the 'Integrate Variables' table update during the animation as desired. However, the plot (step 4) does not work, and the data from the table is not saved during the animation.

Edit:
Basically I'm trying to do the same thing as what was discussed here:
http://www.paraview.org/pipermail/pa...er/019544.html
It looks like programming an extra filter is the best way to go?
Any ideas on how to save the results from 'Integrate Variables' at each animation time step?
"Programmable Filter" where you can have a small Python-program do whatever you want with the input (you'll need a Python-enabled Paraview for that anyway). And if you can do "whatever" then you could for instance append the data that comes in to a file. But don't ask me how to do it exactly. Last time I experimented with this is quite some time ago (and you'll probably have to erase the file before starting the animation)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   April 11, 2013, 14:43
Default
  #5
Member
 
Join Date: Aug 2012
Posts: 68
Blog Entries: 1
Rep Power: 14
Nucleophobe is on a distinguished road
Got it:

Code:
pdi = self.GetInputDataObject(0,0)  
localAArray = pdi.GetCellData().GetArray("Area") 
localPArray = pdi.GetCellData().GetArray("p") 
localA = localAArray.GetTuple(0)[0]
localP = localPArray.GetTuple(0)[0]
fout = open("/home/myUserName/results.txt",'a') 
print localA
print localP
data=str(localA)+'\t'+str(localP)+'\n'
fout.write(data)  
fout.close()

Last edited by Nucleophobe; April 11, 2013 at 17:04. Reason: Fixed code
Nucleophobe is offline   Reply With Quote

Old   October 16, 2017, 14:22
Default
  #6
New Member
 
Joseph Muskat
Join Date: Oct 2017
Posts: 7
Rep Power: 9
JMuskat is on a distinguished road
Hello,

I'd like to apologize for posting on this older thread. It seems to be exactly what I'm trying to do, but I have a few questions.

I'm looking to generate ### slices (I have been using the slice offset feature in ParaView) and look at the Surface Flow through each of them. Instead of going through each slice and manually calculating flow > exporting to Excel > doing this ### of times, I'd like to get the Surface Flow through the set of slices--for each individual slice.

Has there been an addition of an easier way to do what this thread describes? I'm not getting the code to work for my case just yet. Thought I would reach out for some help!

Joseph
JMuskat is offline   Reply With Quote

Old   October 16, 2017, 15:29
Default
  #7
Member
 
Join Date: Aug 2012
Posts: 68
Blog Entries: 1
Rep Power: 14
Nucleophobe is on a distinguished road
Hi Joseph,

I'm not familiar with the "Surface Flow" filter, but if it outputs scalars, you should be able to create a "Programmable Filter" to export the results to a file relatively easily:


Code:
pdi = self.GetInputDataObject(0,0)  
localSurfaceFlowArray = pdi.GetCellData().GetArray("SurfaceFlowVarName") 
localSurfaceFlow = localPArray.GetTuple(0)[0]
fout = open("/home/myUserName/results.txt",'a') 
print localSurfaceFlow
data=str(localSurfaceFlow)+'\n'
fout.write(data)  
fout.close()
Each time the filter is applied/executed, values will be appended to the 'results.txt' file. So, if you animate the position of a slice, you can extract the outputs at each frame of the animation.

It's a bit of a hack, but it might work for you.

Alternatively, you could use the sample utility as others in this thread suggested.

-Nuc
Nucleophobe is offline   Reply With Quote

Old   October 17, 2017, 10:18
Default
  #8
New Member
 
Joseph Muskat
Join Date: Oct 2017
Posts: 7
Rep Power: 9
JMuskat is on a distinguished road
Hello Ken,

Thank you for advice. I'll keep at it and try this code. Hopefully I'll be able to get it to work!

Joseph
JMuskat is offline   Reply With Quote

Old   October 29, 2020, 17:50
Default
  #9
Senior Member
 
Join Date: Jul 2019
Posts: 148
Rep Power: 7
Bodo1993 is on a distinguished road
Quote:
Originally Posted by Nucleophobe View Post
Hi Joseph,

I'm not familiar with the "Surface Flow" filter, but if it outputs scalars, you should be able to create a "Programmable Filter" to export the results to a file relatively easily:


Code:
pdi = self.GetInputDataObject(0,0)  
localSurfaceFlowArray = pdi.GetCellData().GetArray("SurfaceFlowVarName") 
localSurfaceFlow = localPArray.GetTuple(0)[0]
fout = open("/home/myUserName/results.txt",'a') 
print localSurfaceFlow
data=str(localSurfaceFlow)+'\n'
fout.write(data)  
fout.close()
Each time the filter is applied/executed, values will be appended to the 'results.txt' file. So, if you animate the position of a slice, you can extract the outputs at each frame of the animation.

It's a bit of a hack, but it might work for you.

Alternatively, you could use the sample utility as others in this thread suggested.

-Nuc
Hi, I am wondering where in the code you define the different levels of surfaces. Thanks.
Bodo1993 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
Wind tunnel Boundary Conditions in Fluent metmet FLUENT 6 October 30, 2019 13:23
Calculating average total pressure over a surface Vinayak- FLUENT 2 May 16, 2018 02:02
pisoFOAM (LES) - internal pipe flow - convergence gu1 OpenFOAM Running, Solving & CFD 0 January 11, 2018 17:39
outlet pressure Boundary settings -velocity streamline under ambient temp.conditions Vishnu_bharathi CFX 12 November 21, 2017 07:56
unexpected range in pressure level CFD-Post stefank CFX 4 February 2, 2011 06:27


All times are GMT -4. The time now is 17:34.