|
[Sponsors] |
velocity inlet function of the average temperature of a wall |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 7, 2017, 10:58 |
velocity inlet function of the average temperature of a wall
|
#1 |
Member
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9 |
Hello everybody.
Can any one help me please. I'm trying to do an udf that makes the velocity inlet in a pipe varies with respect to the average temperature of a wall (domain 11 in my udf). When I try to initialise after interpreting the udf file, I get this error: Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: () This is my udf code: #include "udf.h" DEFINE_PROFILE(unsteady_velocity_profile, th, position) { Domain *d; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */ face_t f; real tavg = 0.; real tempe,volume,vol_tot; Thread *t; cell_t c; d = Get_Domain(11); /* Get the domain using Fluent utility */ /* Loop over all cell threads in the domain */ thread_loop_c(t,d) { /* Compute volume-averaged temperature */ /* Loop over all cells */ begin_c_loop(c,t) { volume = C_VOLUME(c,t); /* get cell volume */ tempe = C_T(c,t); /* get cell temperature */ vol_tot += volume; tavg += (tempe*volume); } end_c_loop(c,t) tavg /= vol_tot; } begin_f_loop(f, th) { if ( tavg <= 301 ) F_PROFILE(f, th, position) = 0.1; if ( tavg > 301 ) F_PROFILE(f, th, position) = 0.; } end_f_loop(f, th) } |
|
December 8, 2017, 04:26 |
|
#2 |
New Member
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9 |
If you are trying to get a temperature from a wall you should use face values not cell. You are trying to get cell values from a face thread and domain.
|
|
December 8, 2017, 07:57 |
|
#3 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You misunderstood what "domain" means. If your wall had ID=11, it does not mean that your domain should have ID 11, but your thread should have ID 11.
A quick attempt to get this (might give errors, I did not test it): Code:
#include "udf.h" DEFINE_PROFILE(unsteady_velocity_profile, th, position) { Domain *d; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */ face_t f; real tavg = 0.; real tempe,volume,vol_tot; Thread *t; cell_t c; d = Get_Domain(1); /* Get the domain using Fluent utility */ /* Loop over all cell threads in the domain */ thread_loop_c(t,d) { /* only use thread with id=11 */ if (THREAD_ID(t)==11) { /* Loop over all cells */ begin_c_loop(c,t) { volume = C_VOLUME(c,t); /* get cell volume */ tempe = C_T(c,t); /* get cell temperature */ vol_tot += volume; tavg += (tempe*volume); } end_c_loop(c,t) tavg /= vol_tot; } } begin_f_loop(f, th) { if ( tavg <= 301 ) F_PROFILE(f, th, position) = 0.1; if ( tavg > 301 ) F_PROFILE(f, th, position) = 0.; } end_f_loop(f, th) } |
|
December 9, 2017, 16:38 |
|
#4 |
Member
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9 |
Thank you for your answers Mrs Doruk and Park. The udf given by Mr Pakk don't generate any errors but it does not give the true value of T avg (Tavg =0 k always).
Should I use faces instead of cells like what said Mr Doruk ? How can I do that please ? |
|
December 11, 2017, 09:39 |
|
#5 |
Member
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9 |
Any helps please
|
|
December 11, 2017, 11:23 |
|
#6 |
New Member
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9 |
This should work. I just changed pakk's code from cell to face.
#include "udf.h" DEFINE_PROFILE(unsteady_velocity_profile, th, position) { Domain *d; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */ face_t f; real tavg = 0.; real tempe,volume,vol_tot,area; Thread *t; real A[ND_ND]; cell_t c; d = Get_Domain(11); /* Get the domain using Fluent utility */ /* Loop over all cell threads in the domain */ thread_loop_f(t,d) { /* Compute volume-averaged temperature */ /* Loop over all cells */ begin_f_loop(f,t) { volume = F_AREA(A,f,t); /* get cell volume */ tempe = F_T(f,t); /* get cell temperature */ area=NV_MAG(A); vol_tot += area; tavg += (tempe*area); } end_f_loop(f,t) tavg /= vol_tot; } begin_f_loop(f, th) { if ( tavg <= 301 ) F_PROFILE(f, th, position) = 0.1; if ( tavg > 301 ) F_PROFILE(f, th, position) = 0.; } end_f_loop(f, th) } |
|
December 11, 2017, 13:13 |
|
#7 |
Member
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9 |
thanks for your help Doruk, I tried your code but it re-gives the famous error:
C:\PROGRA~1\ANSYSI~1\v145\fluent\fluent14.5.0\win6 4\2ddp\fl1450s.exe received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. I tried also to modify the "d = Get_Domain(11)" to "d = Get_Domain(1)" and add the condition: if (THREAD_ID(t)==11) { ... } but, that also gives the same error |
|
December 12, 2017, 03:51 |
|
#8 |
New Member
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9 |
try putting the
tavg /= vol_tot; inside of the loop. I remember this example from ansys help. If you modify their examples to suit your needs you have to be careful about the threads domains and whats being calculated inside of the loops. |
|
December 12, 2017, 10:07 |
|
#9 |
Member
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9 |
I tried to put it inside the loop and there is no change, the same error
This is the code ( after I re_puted "tavg /= vol_tot" to it's place): #include "udf.h" DEFINE_PROFILE(unsteady_velocity_profile, th, position) { Domain *d; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */ face_t f; real tavg = 0.; Thread *t; real tempe,volume,vol_tot,area; real A[ND_ND]; d = Get_Domain(1); /* Get the domain using Fluent utility */ /* Loop over all cell threads in the domain */ thread_loop_f(t,d) { /* only use thread with id=11 */ if (THREAD_ID(t)==11) { /* Loop over all cells */ begin_f_loop(f,t) { volume = F_AREA(A,f,t); /* get cell volume */ tempe = F_T(f,t); area=NV_MAG(A); vol_tot += area; tavg += (tempe*area); } end_f_loop(f,t) tavg /= vol_tot; } } begin_f_loop(f, th) { if ( tavg <= 301 ) F_PROFILE(f, th, position) = 0.1; if ( tavg > 301 ) F_PROFILE(f, th, position) = 0.; } end_f_loop(f, th) } Can some one help me to recognize the mistake with that ?? |
|
December 12, 2017, 16:48 |
|
#10 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Try to initialize it without the UDF, and use the UDF afterwards.
It could be that your UDF is trying to read the temperature just before it is defined. |
|
December 13, 2017, 20:04 |
|
#11 |
Member
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9 |
thank you very much pakk, I initialized without the udf and I used it afterwards. And that works perfectly. Nevertheless, it shows a warning message : " reversed flow in 8 faces on pressure-outlet 9" when the velocity equal to zero on the inlet. But, that does not affect the final result I think..
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Divergence in AMG solver! | marina | FLUENT | 20 | August 1, 2020 12:30 |
Radiation interface | hinca | CFX | 15 | January 26, 2014 18:11 |
A girl fail to plot velocity profile when mesh changes + Wall function | asherah | STAR-CCM+ | 0 | February 19, 2010 18:45 |
Inlet Velocity in CFX | aeroman | CFX | 12 | August 6, 2009 19:42 |
what the result is negatif pressure at inlet | chong chee nan | FLUENT | 0 | December 29, 2001 06:13 |