|
[Sponsors] |
[swak4Foam] Averaging along an axis.. swak4foam? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 2, 2014, 14:02 |
Averaging along an axis.. swak4foam?
|
#1 |
Senior Member
Timofey Mukha
Join Date: Mar 2012
Location: Stockholm, Sweden
Posts: 119
Rep Power: 14 |
Dear Foamers!
I am performing some channel flow LES. I would like to look at different statistics and how they converge, yet I have to be reasonable about the size of the data my simulation produces. To stick to a simple example, let us assume that I am interested in seeing how the mean velocity profile is developing. Ideally, I would want to have OpenFOAM average the x-velocity component along z and x and produce a single profile along y. Then I can afford to save this profile at each iteration (or every 100, doesn't matter) and see how it is developing. Similar reasoning can be applied for second order moments, skewness etc. So the question is whether I can do this averaging without starting to mess with pimpleFoam. Function objects enriched with swak4foam come to mind, so I started looking at that. As far as I see there is no averaging along an axis/direction implemented, probably because this is meangless in a lot of cases. Any ideas? This is, after all, a pretty comon task for those who deal with turbulence investigation. |
|
October 2, 2014, 15:44 |
|
#2 |
Senior Member
Chris Sideroff
Join Date: Mar 2009
Location: Ottawa, ON, CAN
Posts: 434
Rep Power: 22 |
There isn't an existing function object to do this but there is a utility called postChannel found in $WM_PROJECT_DIR/applications/utilities/postProcessing/miscellaneous . You could use this utility as a basis to incorporate this functionality into a function object.
|
|
October 2, 2014, 19:14 |
|
#3 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
averageUxDistributionY { type swakExpressionAverageDistribution; verbose true; outputControlMode outputTime; valueType internalField; expression "U.x"; weight "vol()"; mask "1"; abscissa "pos().y"; binNumber 50; valueIfZero -100; }
__________________
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 |
||
October 3, 2014, 05:41 |
|
#4 |
Senior Member
Timofey Mukha
Join Date: Mar 2012
Location: Stockholm, Sweden
Posts: 119
Rep Power: 14 |
Thank you so much Bernhard, will look into this!
To clarify further what I am trying too achieve.. The postChannel utility implements a part of the functionality I want in the specific case of channel flow. It "collapses" some results, like mean velocity, into a single profile by averaging across the statistically homogeneous directions. The utility works only on written data, but I would like to do similar things at run-time. Again, in other words, I want to be able, with some flexibility, to perform averaging of statistical moments of different order along a chosen direction, which is statistically homogeneous, at run-time . |
|
October 3, 2014, 08:49 |
|
#5 | |
Senior Member
Timofey Mukha
Join Date: Mar 2012
Location: Stockholm, Sweden
Posts: 119
Rep Power: 14 |
Quote:
1) Calculate the average of U.x for all cells with equal y 2) Place the computed average in one of the bins 2) Write out the distribution. This is a nice thing on its own, but it seems like I completely loose all the information about which values of U.x correspond to which y. Can I somehow make it simply write out the computed averages along with the y-values instead/in addition to computing the distribution? I.e. a two-column list: y.pos() <U.x> |
||
October 3, 2014, 15:49 |
|
#6 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Of course it is not really a distribution but "average U.x as a function of y" Quote:
__________________
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 |
|||
October 7, 2014, 09:54 |
|
#7 | |
Senior Member
Timofey Mukha
Join Date: Mar 2012
Location: Stockholm, Sweden
Posts: 119
Rep Power: 14 |
Quote:
It turned out I am the slow one . I thought the bins were velocity values, not y values. Anyhow, this does more or less do what I wanted it to. I am wondering about some things however: 1) the "key" in the output, that corresponds to the bin obviously, but what exactly. I have a mesh where y is [0;2] and the last "key" I get is 2.00991, which is then out of bounds. 2) Can i hardcode the bins? So that I really get an average of every cell layer. 3) A bit of a side question, I would perhaps like to average not U, but the field UMean produced by fieldAverage. But swak function objects don't seem to see that field, is there a way to hook things together? I fought with it for quite a bit and even tried to create my own UMean with swak instead, using stored variables, but miserably failed TT. |
||
October 7, 2014, 18:30 |
|
#8 | |||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
The out-of-bounds-behaviour I'd have to check Quote:
__________________
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 |
||||
March 23, 2018, 09:46 |
|
#9 |
New Member
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9 |
Dear Bernhard!
I'm using the swakExpressionAverageDistribution type function to get the average temperature along an axis. I works fine when I use it during run-time, writing it into controlDict, but I like to use it after the simulation is complete, as a post processing. For this, I have created a file, called "postDict" in my case directory and called the funkyDoCalc like this : "funkyDoCalc -latestTime postDict". My postDict file cointains the followings: Function { type swakExpressionAverageDistribution; libs ( "libOpenFOAM.so" "libsimpleSwakFunctionObjects.so" "libswakFunctionObjects.so" "libgroovyBC.so" ); writeStartTime no; valueType internalField; expression "T"; verbose true; weight "vol()"; mask "1"; abscissa "pos().z"; dynamicExtremesAbscissa false; minAbscissa 0; maxAbscissa 150; binNumber 75; valueIfZero 0; accumulations ( average ); } But this turned out with an error messege which I can not solve: --> FOAM FATAL ERROR: The expected return type bool is different from the stored result type "scalar" From function tmp<Field<Type> > ExpressionResult::getResult() in file ../../Libraries/swak4FoamParsers/lnInclude/ExpressionResultI.H at line 250. FOAM exiting I would be thankful is you could take a look at that, and hint some crumbs about what this file should contain. Thank you in advance, Gábor |
|
March 26, 2018, 07:58 |
|
#10 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
mask "true";
__________________
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 |
||
March 26, 2018, 08:22 |
|
#11 |
New Member
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9 |
I tried it with - mask "true" - , and it looks like it do something, but not the thing I wanted.
It gives back one single number, i.e. an average , for the whole domain, and not the list of values in the bins. |
|
March 26, 2018, 08:32 |
|
#12 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Doesn't even write something to postProcessing? I'll have to have a look
__________________
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 |
|
March 26, 2018, 08:43 |
|
#13 |
New Member
Hungary (Ungarn)
Join Date: Sep 2017
Posts: 16
Rep Power: 9 |
I used funkyDoCalc -latestTime PostDict -writeCsv, so it created a text file which contains only the time value and one average value.
If I don't add -writeCsv at the end, then it does not creates anything, nor the postProcessing directory that it used to when it runs during simulation. |
|
December 28, 2018, 08:46 |
|
#14 |
Senior Member
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10 |
Hi
I also get an out of bound value for "key". Did you manage to find why it is? Regards Manu
__________________
Regards Manu |
|
August 3, 2019, 08:21 |
|
#15 | |
New Member
George Sof
Join Date: Jun 2019
Posts: 13
Rep Power: 7 |
Quote:
Hello Bernhard, I am sorry to recover an old thread here, but is it possible to calculate the distribution of averaged U.x along y, with this tool? Thank you |
||
August 4, 2019, 19:14 |
|
#16 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
I don't understand how that differs from what has been discussed in the example that was discussed
__________________
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 |
||
August 6, 2019, 05:25 |
|
#17 | |
New Member
George Sof
Join Date: Jun 2019
Posts: 13
Rep Power: 7 |
Quote:
To be more specific, I need to average spatially U.z over a homogeneous direction z of a pipe. Result of the averaging should be a surface field U.z(x,y). Is it possible? |
||
August 7, 2019, 04:27 |
|
#18 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Unfortunately not. What swakExpressionAverageDistribution can do is U.z(x)
__________________
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 |
||
August 7, 2019, 04:51 |
|
#19 |
New Member
George Sof
Join Date: Jun 2019
Posts: 13
Rep Power: 7 |
||
August 7, 2019, 05:17 |
|
#20 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
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 |
||
Tags |
averaging, les, swak4foam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] averaging in spanwise direction of a patch | kenny13 | OpenFOAM Community Contributions | 1 | October 3, 2017 11:07 |
[swak4Foam] problems with averaging a new field | fgarita | OpenFOAM Community Contributions | 1 | October 28, 2016 04:27 |
Starting field averaging using libFunctionObject after certain time | eelcovv | OpenFOAM Programming & Development | 25 | December 7, 2015 23:28 |
Axis treatment in axisymmetrical problem | Jakob1 | OpenFOAM Pre-Processing | 2 | August 25, 2014 04:09 |
[swak4Foam] fails in parallel with -otherTime? | Phicau | OpenFOAM Community Contributions | 3 | June 26, 2013 14:00 |