CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Spanwise averaging of three-dimensional field (http://www.cfd-online.com/Forums/openfoam-post-processing/106966-spanwise-averaging-three-dimensional-field.html)

Fuchs September 13, 2012 11:46

Spanwise averaging of three-dimensional field
 
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

owayz October 12, 2012 16:44

Hallo Marian,
Did you get any easy method to perform spatial averaging?
Regards,
awais

Fuchs October 23, 2012 06:14

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

owayz November 12, 2012 10:48

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

Fuchs November 15, 2012 10:23

1 Attachment(s)
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

owayz November 29, 2012 09:33

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 November 30, 2012 00:26

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 December 2, 2012 20:42

Hi Marian,
Here is the modified utility
Thanks again, it will help me alot.

regards,
Awais

owayz December 2, 2012 20:45

1 Attachment(s)
Sorry was unable to attach in 1st post.

owayz December 2, 2012 22:24

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 December 2, 2012 22:48

Only problem is that the values at the boundaries is written zero.

Fuchs December 4, 2012 07:28

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

mmmn036 June 20, 2014 18:14

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

Fuchs June 24, 2014 06:07

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

catapult July 3, 2014 05:27

Ohter approach
 
1 Attachment(s)
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.

syavash July 22, 2015 04:24

Quote:

Originally Posted by Fuchs (Post 498432)
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 July 22, 2015 04:39

Quote:

Originally Posted by catapult (Post 499814)
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

mmmn036 November 5, 2015 23:15

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 November 5, 2015 23:15

Quote:

Originally Posted by Fuchs (Post 498432)
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


All times are GMT -4. The time now is 03:05.