CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to get a mean value field along one direction? (https://www.cfd-online.com/Forums/openfoam-solving/175619-how-get-mean-value-field-along-one-direction.html)

Aaron_L August 2, 2016 09:05

How to get a mean value field along one direction?
 
Hi, foamers,
I want to get mean temperature field from T field if z coordinate is equal , this is my test code,
Code:

//get T mean along z axis
    forAll(mesh.C(),celli)
    {
        scalar zi = mesh.C()[celli].component(vector::Z);
        scalar& Tmeani = T_mean[celli];
        scalar& Ti = T[celli];
        scalar Vi = mesh.V()[celli];
        scalar Vtotal = Vi;
        scalar Ttotal = Ti*Vi;
        forAll(mesh.C(),cellj)
        {
            scalar zj = mesh.C()[cellj].component(vector::Z);
            if(zi == zj)
            {
                scalar& Tj = T[cellj];
                scalar Vj = mesh.V()[cellj];
                Vtotal = Vtotal + Vj;
                Ttotal = Ttotal + Tj*Vj;
            }
        }
        Tmeani = Ttotal/Vtotal ;
    }

but it was run too slow because I use for two nested loop, how can I handle for it for one loop?
any suggestions? or someone can give me some brief solutions?

Aaron_L August 2, 2016 21:37

T_mean pic
 
1 Attachment(s)
attachment picture is T_mean equation, I want to get T_mean along z direction using xy plane average

miha23 November 9, 2017 07:44

Process
 
Dear Aaron!

Have you made any process with it ever since?

Aaron_L November 12, 2017 00:28

no, it is not very important, so I didn't complete it.


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