CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Spanwise averaging of three-dimensional field

Register Blogs Community New Posts Updated Threads Search

Like Tree24Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 13, 2012, 12:46
Default Spanwise averaging of three-dimensional field
  #1
New Member
 
Marian Fuchs
Join Date: Dec 2010
Location: Berlin, Germany
Posts: 9
Rep Power: 16
Fuchs is on a distinguished road
Hi everyone,

i'm currently running a NACA0021 profile in 3D. Since the mean flow field for this case is basically 2D, the common procedure for post-processing is to average the 3D flow field in spanwise direction (z) to obtain a two-dimensional field of all mean quantities. I'm wondering if there is already a post-processing utility for this purpose available within the community, since spanwise averaging is a common procedure for many (at least) academic cases (e.g. airfoils, cylinders, etc.). I know that OpenFOAM contains the utility "postChannel", maybe someone has already modified the utility so that it does averaging in only one spatial direction instead of 2 and outputs a two-dimensional field?

Thanks for your help,
Marian
Fuchs is offline   Reply With Quote

Old   October 12, 2012, 17:44
Default
  #2
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 128
Rep Power: 17
owayz is on a distinguished road
Send a message via MSN to owayz
Hallo Marian,
Did you get any easy method to perform spatial averaging?
Regards,
awais
owayz is offline   Reply With Quote

Old   October 23, 2012, 07:14
Default
  #3
New Member
 
Marian Fuchs
Join Date: Dec 2010
Location: Berlin, Germany
Posts: 9
Rep Power: 16
Fuchs is on a distinguished road
Hi Awais,

I managed to modify the "postChannel" utility to do the spanwise averaging. Unfortunately, the output is still not optimal. A 3D field is output, which is of course averaged in one particular spatial direction (so that the field can be viewed in paraview like any other field). A header in the output is still missing, the data is currently written as ASCII only. I hadn't had the time to implement it, yet. If you like I can provide you with the source code of my utility and you can add the missing feature.

best regards,
Marian
Fuchs is offline   Reply With Quote

Old   November 12, 2012, 10:48
Default
  #4
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 128
Rep Power: 17
owayz is on a distinguished road
Send a message via MSN to owayz
Hallo Marian,
Sorry for the late reply. I was trying someother utilities is well. But seems like I will have to work on this thing.
If you could provide me the code, I would like to complete it.
Regards,
Awais
owayz is offline   Reply With Quote

Old   November 15, 2012, 10:23
Default
  #5
New Member
 
Marian Fuchs
Join Date: Dec 2010
Location: Berlin, Germany
Posts: 9
Rep Power: 16
Fuchs is on a distinguished road
Hallo Awais,

sorry for the late reply, I had the last few days off. Here is the source code of my utility. I attached a small test case as well,
a simple channel with 3 cells in the homogeneous direction. To fix the output problem, it is probably best to look first into the
source code file 'collapse.H'. I tested my utility for a flow around a NACA0021 profile (grid had about 1.8 mio. cells and 134 cells
in spanwise direction) and the results looked good, so the basic algorithm which performs the averaging seems to work. Let me know if anything is unclear or if you face problems running the utility. I'd be glad if you could send me the modified source code in case you succeed in fixing the output.

best regards,
Marian
Attached Files
File Type: gz postSpanwiseAverage.tar.gz (12.9 KB, 331 views)
sunliming, kreddy and rajibroy like this.
Fuchs is offline   Reply With Quote

Old   November 29, 2012, 09:33
Default
  #6
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 128
Rep Power: 17
owayz is on a distinguished road
Send a message via MSN to owayz
Hi Marian,
Thanks for sharing the code. I can definitely see the issues you pointed out.
I just have a small question can we use volScalarFields instead of scalarFields?
Regards,
awais
owayz is offline   Reply With Quote

Old   November 30, 2012, 00:26
Default
  #7
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 128
Rep Power: 17
owayz is on a distinguished road
Send a message via MSN to owayz
Hi Marian,
I made a small change to write the average Fields in peoper form. It still writes the whole averaged value on all the intenal cells. But the boundary field is zero. but I guess thats OK since we are only interested in averaged value we can check it anywhere in the mesh.
Code:
    volScalarField avgUx
    (
	IOobject
	(
	    "avgUx",
	    runTime.timeName(),
	    mesh,
	    IOobject::NO_READ,
	    IOobject::AUTO_WRITE
	),
        mesh,
        dimensionedScalar("avgUx", dimVelocity, 0.0)
    );
    scalarField spanavgUMeanX
    (
        meshIndexing.collapse(UMean.component(vector::X)())
    );

    avgUx.internalField() = spanavgUMeanX;
    avgUx.write();
Tell me if this looks ok.

regards,
Awais
owayz is offline   Reply With Quote

Old   December 2, 2012, 20:42
Default
  #8
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 128
Rep Power: 17
owayz is on a distinguished road
Send a message via MSN to owayz
Hi Marian,
Here is the modified utility
Thanks again, it will help me alot.

regards,
Awais
owayz is offline   Reply With Quote

Old   December 2, 2012, 20:45
Default
  #9
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 128
Rep Power: 17
owayz is on a distinguished road
Send a message via MSN to owayz
Sorry was unable to attach in 1st post.
Attached Files
File Type: gz postSpanwiseAverage.tar.gz (17.2 KB, 324 views)
owayz is offline   Reply With Quote

Old   December 2, 2012, 22:24
Default
  #10
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 128
Rep Power: 17
owayz is on a distinguished road
Send a message via MSN to owayz
Sorry again. I forgot to write the averaged data. After each calculation we should write avgUx, avgUy, avgUz and avgP.
so it could be done by adding:
Code:
avgUx.write();
And doing the same for Uy , Uz and P as well.
Regards,
awais
owayz is offline   Reply With Quote

Old   December 2, 2012, 22:48
Default
  #11
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 128
Rep Power: 17
owayz is on a distinguished road
Send a message via MSN to owayz
Only problem is that the values at the boundaries is written zero.
owayz is offline   Reply With Quote

Old   December 4, 2012, 07:28
Default
  #12
New Member
 
Marian Fuchs
Join Date: Dec 2010
Location: Berlin, Germany
Posts: 9
Rep Power: 16
Fuchs is on a distinguished road
Hallo Awais,

thanks for your effort and for sharing the modified code. I guess the boundary value isn't really a problem, but that depends of course on your application and what you're trying to post-process exactly...

best regards,
Marian
Fuchs is offline   Reply With Quote

Old   June 20, 2014, 19:14
Default
  #13
Member
 
Manjura Maula Md. Nayamatullah
Join Date: May 2013
Location: San Antonio, Texas, USA
Posts: 42
Rep Power: 13
mmmn036 is on a distinguished road
Hello,

I would like to use this tool for my case to do the span-wise averaging of fields. But in my case the boundary value are important for post processing.

Did you guys include the boundary value in that utility or give me an idea to include the boundary to that source code?

I would appreciate your help.

Thanks
MMMN
mmmn036 is offline   Reply With Quote

Old   June 24, 2014, 07:07
Default
  #14
New Member
 
Marian Fuchs
Join Date: Dec 2010
Location: Berlin, Germany
Posts: 9
Rep Power: 16
Fuchs is on a distinguished road
Hi Manjura,

which type of boundary condition are you exactly referring to? I've started to work on an updated version of my code some time ago but haven't had the time to finish and test it yet. The new code in fact copies the boundary conditions of the original variable to the time-averaged field, but does not perform any additional operation on the BC's. Plus it now runs in parallel, also the domain should not be devided in spanwise-direction for the utility to work.

I'll upload the new code as soon as its finished, which will be in probably 2 weeks.

best regards,
Marian
mmmn036 likes this.
Fuchs is offline   Reply With Quote

Old   July 3, 2014, 06:27
Default Ohter approach
  #15
New Member
 
Gregory
Join Date: Nov 2010
Location: Dresden
Posts: 14
Rep Power: 16
catapult is on a distinguished road
Hi guys,

I have developed a small OF-routine that averages the UMean in the z-spanwise direction. It uses anoter approach but works well and is fast. Exectution time < 1min for a mesh of about 1.2 Million cells. Good things: the method theoretically works for unstructured mesh (The interpolator needs to be improved though). Hope anyone finds it useful.

Gregory.
Attached Files
File Type: gz avg.tar.gz (2.1 KB, 425 views)
owayz, tfuwa, mmmn036 and 7 others like this.
catapult is offline   Reply With Quote

Old   July 22, 2015, 05:24
Default
  #16
Senior Member
 
Ehsan Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by Fuchs View Post
Hi Manjura,

which type of boundary condition are you exactly referring to? I've started to work on an updated version of my code some time ago but haven't had the time to finish and test it yet. The new code in fact copies the boundary conditions of the original variable to the time-averaged field, but does not perform any additional operation on the BC's. Plus it now runs in parallel, also the domain should not be devided in spanwise-direction for the utility to work.

I'll upload the new code as soon as its finished, which will be in probably 2 weeks.

best regards,
Marian

Dear Marian,

Could you finish the updated version of your code? Is it possible to share it with us??

Thanks,
Syavash
syavash is offline   Reply With Quote

Old   July 22, 2015, 05:39
Default
  #17
Senior Member
 
Ehsan Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by catapult View Post
Hi guys,

I have developed a small OF-routine that averages the UMean in the z-spanwise direction. It uses anoter approach but works well and is fast. Exectution time < 1min for a mesh of about 1.2 Million cells. Good things: the method theoretically works for unstructured mesh (The interpolator needs to be improved though). Hope anyone finds it useful.

Gregory.

Nice job Gregory! But I think your code may ignore some cells when trying to match x and y coordinates. I have applied your routine to my case, a 3-D channel homogeneous is z direction.
I could get a nice smooth field of velocity, but when noting the legend bar, I could see that the velocity range is half of that which should be!!
Actually, I have developed a similar utility/code for Ansys Fluent and it also suffers from the same issue.
Due to writing precision of the grid generator tool (Gambit and ICEM CFD in my case), not the entire cells aligned in z direction have THE EXACT similar x and y coordinates. So, it is normal that the code ignores some cells and their contributions to the velocity field are neglected.
For fixing this problem, I introduced a tolerance factor in my case which somewhat improved span-wise averaging.
Can you do the same in your routine?

P.S.: Is it possible to include pressure field as well??

Regards,
Syavash
syavash is offline   Reply With Quote

Old   November 5, 2015, 23:15
Default
  #18
Member
 
Manjura Maula Md. Nayamatullah
Join Date: May 2013
Location: San Antonio, Texas, USA
Posts: 42
Rep Power: 13
mmmn036 is on a distinguished road
Hello Marian,

Do you have the code available for span wise averaging that runs parallel? I would really appreciate if you have the code available and share with us.

Thanks
MMMN
mmmn036 is offline   Reply With Quote

Old   November 5, 2015, 23:15
Default
  #19
Member
 
Manjura Maula Md. Nayamatullah
Join Date: May 2013
Location: San Antonio, Texas, USA
Posts: 42
Rep Power: 13
mmmn036 is on a distinguished road
Quote:
Originally Posted by Fuchs View Post
Hi Manjura,

which type of boundary condition are you exactly referring to? I've started to work on an updated version of my code some time ago but haven't had the time to finish and test it yet. The new code in fact copies the boundary conditions of the original variable to the time-averaged field, but does not perform any additional operation on the BC's. Plus it now runs in parallel, also the domain should not be devided in spanwise-direction for the utility to work.

I'll upload the new code as soon as its finished, which will be in probably 2 weeks.

best regards,
Marian
Hello Marian,

Do you have the code available for span wise averaging that runs parallel? I would really appreciate if you have the code available and share with us.

Thanks
MMMN
mmmn036 is offline   Reply With Quote

Old   November 21, 2016, 00:13
Default spanwise averaging in a cellZone
  #20
Member
 
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10
pvpnrao is on a distinguished road
can some one explain how to use the postSpanwiseaverage tool to carryout the averaging in a particular cellZone?
pvpnrao 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
problems after decomposing for running alessio.nz OpenFOAM 7 March 5, 2021 05:49
Starting field averaging using libFunctionObject after certain time eelcovv OpenFOAM Programming & Development 25 December 7, 2015 23:28
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
Averaging field over a spatial direction fs82 OpenFOAM 10 August 12, 2009 11:44
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51


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