CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

velocity inlet function of the average temperature of a wall

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By doruk
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 7, 2017, 10:58
Default velocity inlet function of the average temperature of a wall
  #1
Member
 
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9
youhane is on a distinguished road
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)
}
youhane is offline   Reply With Quote

Old   December 8, 2017, 04:26
Default
  #2
New Member
 
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9
doruk is on a distinguished road
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.
doruk is offline   Reply With Quote

Old   December 8, 2017, 07:57
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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)
}
pakk is offline   Reply With Quote

Old   December 9, 2017, 16:38
Default
  #4
Member
 
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9
youhane is on a distinguished road
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 ?
youhane is offline   Reply With Quote

Old   December 11, 2017, 09:39
Default
  #5
Member
 
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9
youhane is on a distinguished road
Any helps please
youhane is offline   Reply With Quote

Old   December 11, 2017, 11:23
Default
  #6
New Member
 
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9
doruk is on a distinguished road
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)
}
doruk is offline   Reply With Quote

Old   December 11, 2017, 13:13
Default
  #7
Member
 
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9
youhane is on a distinguished road
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
youhane is offline   Reply With Quote

Old   December 12, 2017, 03:51
Default
  #8
New Member
 
Doruk Yelkenci
Join Date: Apr 2017
Posts: 20
Rep Power: 9
doruk is on a distinguished road
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.
youhane likes this.
doruk is offline   Reply With Quote

Old   December 12, 2017, 10:07
Default
  #9
Member
 
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9
youhane is on a distinguished road
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 ??
youhane is offline   Reply With Quote

Old   December 12, 2017, 16:48
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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.
youhane likes this.
pakk is offline   Reply With Quote

Old   December 13, 2017, 20:04
Default
  #11
Member
 
youhane kha
Join Date: Sep 2017
Posts: 36
Rep Power: 9
youhane is on a distinguished road
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..
youhane 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
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


All times are GMT -4. The time now is 14:12.