CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Inquire about the max() function in OpenFOAM

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

Reply
 
LinkBack Thread Tools Display Modes
Old   November 28, 2016, 07:58
Default Inquire about the max() function in OpenFOAM
  #1
New Member
 
Join Date: May 2015
Posts: 9
Rep Power: 4
harvee is on a distinguished road
Hey there!
I'm confused about how the max() function works.
Currently I'm making a AMR sensor using gradrho &gradU
Code as following:
In rhoCentralFoam.C ,I add this lines.
Code:
//----------------------------sensor-------------------------------------//
        volScalarField Uy = mag(U.component(vector::Y));
        volVectorField gradUy = fvc::grad(Uy);
        volScalarField gradUyy = mag(gradUy.component(vector::Y));
        gradUyyN = gradUyy/max(gradUyy);

//        using tensor
        volTensorField gradU0 = fvc::grad(U);
        volScalarField gradU1 = mag(gradU0.component(tensor::YY)); 
        gradUtN = gradU1/max(gradU1);

        volScalarField gradrho = mag(fvc::grad(rho));
        gradrhoN = gradrho/max(gradrho);

//----------------------------sensor-------------------------------------//
I used two method to calculate the {partialUy/partialY},the result shows they're identical.However,after applied the max() function for normalization.
For using as sensor I want it ranges from 0-1.
gradrhoN works fine,and it's value range from 0-1.
But,the range of gradUyyN or gradUtN (which has the same value) shows a changing range approximately from a non-zero extremly small value to about 0.5.
Why the max value / max value is not 1?
thank you
harvee is offline   Reply With Quote

Old   November 29, 2016, 11:28
Default
  #2
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 236
Rep Power: 11
hk318i is on a distinguished road
Are you testing this code in parallel?
__________________
@HIKassem | HassanKassem.me
hk318i is offline   Reply With Quote

Old   November 29, 2016, 11:30
Default hi
  #3
New Member
 
Join Date: May 2015
Posts: 9
Rep Power: 4
harvee is on a distinguished road
Quote:
Originally Posted by hk318i View Post
Are you testing this code in parallel?
no,I'm using single cpu.
I just find the solution.
Use gMax instead of max gives the correct value.
harvee is offline   Reply With Quote

Old   November 29, 2016, 11:37
Default
  #4
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 236
Rep Power: 11
hk318i is on a distinguished road
Exactly, that's why I asked. But if you are running on single processor, max() should work fine.
__________________
@HIKassem | HassanKassem.me
hk318i is offline   Reply With Quote

Old   November 29, 2016, 11:44
Default
  #5
New Member
 
Join Date: May 2015
Posts: 9
Rep Power: 4
harvee is on a distinguished road
Quote:
Originally Posted by hk318i View Post
Exactly, that's why I asked. But if you are running on single processor, max() should work fine.
gradrho = fvc::grad(rho);
gradrhoMag = mag(gradrho);
gradrhoMax = max(gradrhoMag);

when I check the value of gradrhoMag and gradrhoMax, the maximum of gradrhoMag=gradrhoMax, but when I use max() for doing gradU,it's not work.
the value is almost twice bigger than the maximum of gradUMag.
harvee is offline   Reply With Quote

Reply

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
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 9 March 30, 2017 05:19
Problem of simulating of small droplet with radius of 2mm liguifan OpenFOAM Running, Solving & CFD 5 June 3, 2014 02:53
non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Native Meshers: blockMesh 7 April 17, 2013 05:42
Version 15 on Mac OS X gschaider OpenFOAM Installation 120 December 2, 2009 11:23
Can anybody help me to solve the list errors while compiling Openfoam 15 on Opensuse 103 32bit coompressor OpenFOAM Installation 0 November 12, 2008 20:53


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