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

Inquire about the max() function in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 28, 2016, 06:58
Default Inquire about the max() function in OpenFOAM
  #1
New Member
 
Join Date: May 2015
Posts: 9
Rep Power: 10
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, 10:28
Default
  #2
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 17
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, 10:30
Default hi
  #3
New Member
 
Join Date: May 2015
Posts: 9
Rep Power: 10
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, 10:37
Default
  #4
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 17
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, 10:44
Default
  #5
New Member
 
Join Date: May 2015
Posts: 9
Rep Power: 10
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


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
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 05:29
Problem of simulating of small droplet with radius of 2mm liguifan OpenFOAM Running, Solving & CFD 5 June 3, 2014 02:53
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 05:42
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 10: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 19:53


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