|
[Sponsors] |
September 6, 2002, 11:16 |
UDF for second order moments in LES
|
#1 |
Guest
Posts: n/a
|
finally i solved my problem, here's the UDF i made if someone's interested (it runs in parallel without any problem).
/************************************************** ************************/ /* UDF computing some Reynolds Stresses and Density-Velocity correlations */ /* Skewness and Flateness are also computed */ /************************************************** ************************/ #include "udf.h" #include "sg.h" #include "math.h" #include "metric.h" /****************************************/ /* Application domain (over fluid only) */ /****************************************/ /* 1 fluide fluid cell */ static int fluid_thread_ids = 1; /***********************/ /* User Define Scalars */ /***********************/ enum { /* Mean Values */ UMOY,VMOY,WMOY,RhoMoy, /* Fluctuations */ Uprime,Vprime,Wprime,Rhoprime, /* Reynolds stresses */ UprimeVprimeMoy,UprimeWprimeMoy,VprimeWprimeMoy, /* Density velocity correlations */ RhoprimeUprimeMoy,RhoprimeVprimeMoy,RhoprimeWprime Moy, /* Standard deviations */ UcarreMoy,VcarreMoy,WcarreMoy,RhocarreMoy, /* Skewness and flatness */ Uprime3Moy,Uprime4Moy,Su,Fu }; DEFINE_ADJUST(fluctuations,domain) { /**********************/ /* GLOBAL VARIABLES */ /**********************/ static int count=0; /* user counter of time step */ int n1,n2=50; /* fluent counters of time step */ int n3=286 /* offset (nb of time steps done before including subroutine) */ cell_t c; Thread *t_fluid= Lookup_Thread(domain,fluid_thread_ids); /***************************************/ /* Initialisation of time step counter */ /***************************************/ n1 = RP_Get_Integer("time-step")-n3; /****************************************/ /* message dispalayed at each iteration */ /****************************************/ Message(" Counters %d %d \n",count,n1); /************************************************** ***/ /* First n2 time steps mean values only are computed */ /************************************************** ***/ if ((count <= n2) && (count == n1)) /* updating statistics at each time step */ { Message(" Inside mean loop counters %d %d \n",count,n1); count++; begin_c_loop(c,t_fluid) { /***************/ /* Mean Values */ /***************/ C_UDSI(c,t_fluid,UMOY) = ( C_UDSI(c,t_fluid,UMOY)*(count - 1) + C_U(c,t_fluid) )/count; C_UDSI(c,t_fluid,VMOY) = ( C_UDSI(c,t_fluid,VMOY)*(count - 1) + C_V(c,t_fluid) )/count; C_UDSI(c,t_fluid,WMOY) = ( C_UDSI(c,t_fluid,WMOY)*(count - 1) + C_W(c,t_fluid) )/count; C_UDSI(c,t_fluid,RhoMoy) = ( C_UDSI(c,t_fluid,RhoMoy)*(count - 1) + C_R(c,t_fluid) )/count; /****************/ /* Fluctuations */ /****************/ C_UDSI(c,t_fluid,Uprime) = 0.0; C_UDSI(c,t_fluid,Vprime) = 0.0; C_UDSI(c,t_fluid,Wprime) = 0.0; C_UDSI(c,t_fluid,Rhoprime) = 0.0; /************************/ /* Reynolds stresses */ /************************/ C_UDSI(c,t_fluid,UprimeVprimeMoy) = 0.0; C_UDSI(c,t_fluid,UprimeWprimeMoy) = 0.0; C_UDSI(c,t_fluid,VprimeWprimeMoy) = 0.0; /****************/ /* Correlations */ /****************/ C_UDSI(c,t_fluid,RhoprimeUprimeMoy) = 0.0; C_UDSI(c,t_fluid,RhoprimeVprimeMoy) = 0.0; C_UDSI(c,t_fluid,RhoprimeWprimeMoy) = 0.0; /***********************/ /* Standrad deviations */ /***********************/ C_UDSI(c,t_fluid,UcarreMoy) = 0.0; C_UDSI(c,t_fluid,VcarreMoy) = 0.0; C_UDSI(c,t_fluid,WcarreMoy) = 0.0; C_UDSI(c,t_fluid,RhocarreMoy) = 0.0; /*****************************/ /* Dissymetry and Flatness F */ /*****************************/ C_UDSI(c,t_fluid,Uprime3Moy) = 0.0; C_UDSI(c,t_fluid,Uprime4Moy) = 0.0; C_UDSI(c,t_fluid,Su) = 0.0; C_UDSI(c,t_fluid,Fu) = 0.0; } end_c_loop(c,t_fluid) } else /* after n2 iteration statistics are computed */ { if ((count > n2) && (count == n1)) /* updating statistics at each time step */ { Message(" inside statistic loop %d %d\n",count,n1); count++ ; begin_c_loop(c,t_fluid) { /**************/ /* Mean Values */ /****************/ C_UDSI(c,t_fluid,UMOY) = ( C_UDSI(c,t_fluid,UMOY)*(count - 1) + C_U(c,t_fluid) )/count; C_UDSI(c,t_fluid,VMOY) = ( C_UDSI(c,t_fluid,VMOY)*(count - 1) + C_V(c,t_fluid) )/count; C_UDSI(c,t_fluid,WMOY) = ( C_UDSI(c,t_fluid,WMOY)*(count - 1) + C_W(c,t_fluid) )/count; C_UDSI(c,t_fluid,RhoMoy) = ( C_UDSI(c,t_fluid,RhoMoy)*(count - 1) + C_R(c,t_fluid) )/count; /***************/ /* Fluctuations */ /****************/ C_UDSI(c,t_fluid,Uprime) =C_UDSI(c,t_fluid,UMOY) - C_U(c,t_fluid); C_UDSI(c,t_fluid,Vprime) =C_UDSI(c,t_fluid,VMOY) - C_V(c,t_fluid); C_UDSI(c,t_fluid,Wprime) =C_UDSI(c,t_fluid,WMOY) - C_W(c,t_fluid); C_UDSI(c,t_fluid,Rhoprime) =C_UDSI(c,t_fluid,RhoMoy) - C_R(c,t_fluid); /********************/ /* Reynolds Stresses */ /**********************/ C_UDSI(c,t_fluid,UprimeVprimeMoy) = ( C_UDSI(c,t_fluid,UprimeVprimeMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Uprime) * C_UDSI(c,t_fluid,Vprime)) )/(count - n2); C_UDSI(c,t_fluid,UprimeWprimeMoy) = ( C_UDSI(c,t_fluid,UprimeWprimeMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Uprime) * C_UDSI(c,t_fluid,Wprime)) )/(count - n2); C_UDSI(c,t_fluid,VprimeWprimeMoy) = ( C_UDSI(c,t_fluid,VprimeWprimeMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Vprime) * C_UDSI(c,t_fluid,Wprime)) )/(count - n2); /***************/ /* Correlations */ /*****************/ C_UDSI(c,t_fluid,RhoprimeUprimeMoy) = ( C_UDSI(c,t_fluid,RhoprimeUprimeMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Rhoprime) * C_UDSI(c,t_fluid,Uprime)) )/(count - n2); C_UDSI(c,t_fluid,RhoprimeVprimeMoy) = ( C_UDSI(c,t_fluid,RhoprimeVprimeMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Rhoprime) * C_UDSI(c,t_fluid,Vprime)) )/(count - n2); C_UDSI(c,t_fluid,RhoprimeWprimeMoy) = ( C_UDSI(c,t_fluid,RhoprimeWprimeMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Rhoprime) * C_UDSI(c,t_fluid,Wprime)) )/(count - n2); /*********************/ /* Standard deviation */ /***********************/ C_UDSI(c,t_fluid,UcarreMoy) = ( C_UDSI(c,t_fluid,UcarreMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Uprime)*C_UDSI(c,t_fluid,Uprime) ) )/(count - n2); C_UDSI(c,t_fluid,VcarreMoy) = ( C_UDSI(c,t_fluid,VcarreMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Vprime)*C_UDSI(c,t_fluid,Vprime) ) )/(count - n2); C_UDSI(c,t_fluid,WcarreMoy) = ( C_UDSI(c,t_fluid,WcarreMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Wprime)*C_UDSI(c,t_fluid,Wprime) ) )/(count - n2); C_UDSI(c,t_fluid,RhocarreMoy) = ( C_UDSI(c,t_fluid,RhocarreMoy)*(count - n2 - 1) + (C_UDSI(c,t_fluid,Rhoprime)*C_UDSI(c,t_fluid,Rhopr ime)) )/(count - n2); /******************************/ /* Skewness Su and Flatness Fu */ /********************************/ C_UDSI(c,t_fluid,Uprime3Moy) = ( C_UDSI(c,t_fluid,Uprime3Moy)*(count - n2 - 1) + pow(C_UDSI(c,t_fluid,Uprime),3) ) /(count - n2); C_UDSI(c,t_fluid,Uprime4Moy) = ( C_UDSI(c,t_fluid,Uprime4Moy)*(count - n2 - 1) + pow(C_UDSI(c,t_fluid,Uprime),4) ) /(count - n2); C_UDSI(c,t_fluid,Su) = C_UDSI(c,t_fluid,Uprime3Moy)/pow(C_UDSI(c,t_fluid,UcarreMoy),1.5); C_UDSI(c,t_fluid,Fu) = C_UDSI(c,t_fluid,Uprime4Moy)/pow(C_UDSI(c,t_fluid,UcarreMoy),2); } end_c_loop(c,t_fluid) } } } |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to access mean velocity in LES by UDF | sarah_ron2002 | FLUENT | 5 | December 20, 2006 10:44 |
Velocity LES UDF | Lourival | FLUENT | 0 | April 15, 2006 07:32 |
LES | Edward | Main CFD Forum | 25 | September 24, 2001 19:37 |
LES - numerics | David Hunt | Main CFD Forum | 8 | May 23, 2000 02:08 |
Higher order FVM | Sergey Smirnov | Main CFD Forum | 10 | April 15, 2000 01:49 |