|
[Sponsors] |
![]() |
![]() |
#1 |
Senior Member
Join Date: Jul 2013
Posts: 124
Rep Power: 13 ![]() |
Hi All,
Suppose I have output velocity/pressure from an OpenFOAM simulation. Is it possible to use ParaView to calculate the depth-averaged velocities? I do not have any experience with the custom filters. For example, suppose I modify the cavity tutorial to be 3D, and then I want to look at the depth-averaged velocity profile. How can I do that with ParaView? Thanks so much Edit: I'm sorry, I just saw that there is a separate ParaView forum, but I am unable to delete or move this thread. |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Join Date: Jul 2019
Posts: 148
Rep Power: 7 ![]() |
I am wondering if you found the way. Thanks.
|
|
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
Join Date: Jul 2013
Posts: 124
Rep Power: 13 ![]() |
I never found a way to do this. I'm guessing with a simple regular grid you could just program it in the python filter.
|
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Join Date: Jul 2019
Posts: 148
Rep Power: 7 ![]() |
Thanks for the reply. I have been looking into this for a while and could not get any useful answer. In my case, I have 2D domain (x-y plane) and I want to average the phase fraction at every y and repeat the process at each time step. The mesh I am using is rectangular, but it is non-uniform. I normally do my postprocessing with MATLAB; however, I find it difficult to do the area weighted average on the interpolated data which I extract from OpenFOAM (i.e. no information on the area of each cell).
|
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Join Date: Jul 2013
Posts: 124
Rep Power: 13 ![]() |
One thing you could possibly try is to use a slice filter at each x value, and use the integrate variables filter to find the average for that x. Then you can write a macro that changes the x values of the slice filter and records the corresponding average.
|
|
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
Join Date: Jul 2019
Posts: 148
Rep Power: 7 ![]() |
Thank you for the suggestion. Right, I did it for one slice. Unfortunately, I do not know how to write programmable macros (i.e. I am not a python user). I should look into that. I would appreciate any references if you are aware of any useful ones.
|
|
![]() |
![]() |
![]() |
![]() |
#7 |
Senior Member
Join Date: Jul 2013
Posts: 124
Rep Power: 13 ![]() |
What I have done whenever I need a paraview macro is something like this:
1. Load your case (Apply). 2. Then you want to record a macro where you manually setup the filters and such that you need. In my version of paraview this starts with Tools -> Start Trace. Go with "only *user-modified* properties" in the trace. 3. After that be careful because everything you do will be recorded in the macro, so you only want the necessary commands. Click the slice filter and set it in the correct plane and the correct starting position and then apply it. 4. Then add the integrate variables filter and apply. 5. Then switch to the slice filter and change the x coordinate and apply again. 6. Change the x coordinate and apply again. 7. Change the x coordinate and apply again. 8. Then go to Tools -> Stop trace 9. Then you should save the python code that is generated as a macro. 10. Next, you will need to try to understand the python code it generated. The most important parts will be going near the end of the code there will be probably a line like this " slice1.SliceType.Origin = [-7.0, 0.0, 0.004999999888241291]" Probably you will have multiple of those lines for each time you changed the origin of the slice filter. You will need to learn enough python to write a for loop to iterate over the positions you need, for you I think this is the x-coordinate. The other thing you will need to learn, which I do not know about, is how to access the value of the integrated variables, and then output that value along with the x value into probably a csv file for your data. Sorry that I can't help with this step, but hopefully by trying to understand the code produced in the python trace you will get some hints that will help you google about this. Once you have edited your macro, you can just click it to run the macro again, but make sure your current "state" in paraview is identical to when you started recording the macro. You have to delete all the filters and such before you run the macro again. Also, one thing to note, when I have done something like this before, it was important to set the x values and the dx exactly such that I was cutting through the center of the cells. If you try to take multiple values within a single cell for instance, you might get some small oscillations happening. p, li { white-space: pre-wrap; } |
|
![]() |
![]() |
![]() |
![]() |
#8 |
Senior Member
Join Date: Jul 2019
Posts: 148
Rep Power: 7 ![]() |
Thank you for your time. Much appreciated.
|
|
![]() |
![]() |
![]() |
![]() |
#9 |
New Member
Kate Bradbrook
Join Date: Nov 2015
Posts: 12
Rep Power: 11 ![]() |
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: # 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):output.PointData.append(dp,"depth")#vertical averaging output.PointData.append(dv,"avVel") #Now can use calculator to get Froude Number :-) Last edited by KateBradbrook; May 4, 2023 at 10:10. Reason: indents for code didn't copy properly |
|
![]() |
![]() |
![]() |
Tags |
depth-averages, paraview |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calculate field and patch averages in multiple zones, large mesh | buffi | OpenFOAM Post-Processing | 2 | July 21, 2022 06:45 |
[OpenFOAM] Paraview client/server does not work with ParaView 5.0.1 | snak | ParaView | 0 | October 17, 2016 11:22 |
a variable/expression to calculate water depth | hmasenger | CFX | 3 | January 31, 2015 17:46 |
Newbie: Install ParaView 3.81 on OF-1.6-ext/OpenSuse 11.2? | lentschi | OpenFOAM Installation | 1 | March 9, 2011 03:32 |
calculate average in Paraview | alain | Main CFD Forum | 0 | March 14, 2006 06:49 |