CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

How to get a mean value field along one direction?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 2, 2016, 09:05
Default How to get a mean value field along one direction?
  #1
New Member
 
Aaron
Join Date: Apr 2016
Posts: 23
Rep Power: 3
Aaron_L is on a distinguished road
Sponsored Links
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?

Last edited by Aaron_L; August 2, 2016 at 21:31. Reason: add information
Aaron_L is offline   Reply With Quote
Sponsored Links

Old   August 2, 2016, 21:37
Default T_mean pic
  #2
New Member
 
Aaron
Join Date: Apr 2016
Posts: 23
Rep Power: 3
Aaron_L is on a distinguished road
attachment picture is T_mean equation, I want to get T_mean along z direction using xy plane average
Attached Images
File Type: png T_mean.png (8.7 KB, 8 views)
Aaron_L is offline   Reply With Quote

Reply

Tags
mesh and grid

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Openfoam - Run Wind Simulations in Different Direction YK123 OpenFOAM 3 May 16, 2016 07:38
Direction of flow for far field inlet Sharkfinner FLUENT 0 March 15, 2016 09:27
NREL SOWFA ABLTerrainSolver tutorial problem cico0815 OpenFOAM Running, Solving & CFD 18 February 1, 2016 19:16
Using sample to Inlet velocity field amanbearpig OpenFOAM Running, Solving & CFD 14 November 16, 2015 06:47
funkySetBoundaryFields - Manipulation of existing field jhertel OpenFOAM Pre-Processing 15 March 19, 2015 09:42

Sponsored Links


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