CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF-reference to a different thread (https://www.cfd-online.com/Forums/fluent-udf/95464-udf-reference-different-thread.html)

Bionico December 19, 2011 08:56

UDF-reference to a different thread
 
Hi everybody,
I have to create a UDF for a wall: in particular the wall temperature must depend on the temperature of a point not next to the boundary (in this point there's a temperature sensor and the wall temperature changes thanks to a feedback)
I don't now how to create the thread, in the UDF, referring to this point (so that I can use C_T function...)
I should have, in the end, two threads in my UDF: the one belonging to the boundary (declared in DEFINE_PROFILE) and this new thread...
Some suggestions?
(excuse for my bad english)

Amir December 19, 2011 12:13

Quote:

Originally Posted by Bionico (Post 336339)
Hi everybody,
I have to create a UDF for a wall: in particular the wall temperature must depend on the temperature of a point not next to the boundary (in this point there's a temperature sensor and the wall temperature changes thanks to a feedback)
I don't now how to create the thread, in the UDF, referring to this point (so that I can use C_T function...)
I should have, in the end, two threads in my UDF: the one belonging to the boundary (declared in DEFINE_PROFILE) and this new thread...
Some suggestions?
(excuse for my bad english)

Dear Flavio,

you can easily separate your desired volume which encompasses the sensor with this procedure:
1) Adapt->region ..... (define your volume as small as possible which contains the sensor location)
2) grid ->separate-> cells ..... (separate the selected volume)
3) define-> boundary condition ..... (find its ID)
4) if this volume contains more than 1 cell, do proper consideration in UDF such as finding average of properties in this volume and then use it as sensor variable...
5) Enjoy!

Bests,

Bionico December 20, 2011 04:20

Thank you very much, Amir :)
I haven't tried your solution yet because I would prefer one independent on the mesh
I have written this UDF, but it doesn't work

Code:


DEFINE_ADJUST(tsensor,domain)
{
 real trif_coordinate[ND_ND];
 real trif;
 real xmin;
 real xmax;
 real ymin;
 real ymax;
 real zmin;
 real zmax;
 real x,y,z,nt;
 
 cell_t c;
 Domain *d;
 Thread *t;
 d = Get_Domain(1);
 
 xmin=-1.940;
 xmax=-1.860;
 ymin=-1.040;
 ymax=-0.960;
 zmin=1.360;
 zmax=1.440;
 
 thread_loop_c(t,d)
 {
 nt=0.0;
 begin_c_loop(c,t)
 {
  C_CENTROID(trif_coordinate,c,t);
 
  x=trif_coordinate[0];
  y=trif_coordinate[1];
  z=trif_coordinate[2];
 
 
  if ((x >= xmin) && (x <= xmax))
  {
  if ((y >= ymin) && (y <= ymax))
  {
    if ((z >= zmin) && (z <= zmax))
    {
    trif=trif + C_T(c,t);     
    nt=nt+1.0;     
    }
  }
  }
 }
 end_c_loop(c,t)
 }
 trif=trif/nt;
}
 
DEFINE_PROFILE(twall, thread, position)
{
 real trif;
 real tlimit;
 face_t f;
 tlimit=291.65;
 if (trif>tlimit)
 
  begin_f_loop(f,thread)
 {
    F_PROFILE(f, thread, position) = 291.15-(trif-291.15); 
 }
  end_f_loop(f, thread)
 else
  begin_f_loop(f,thread)
 {
    F_PROFILE(f, thread, position) = 291.15;   
 }
  end_f_loop(f, thread)
 
}


wall temperature doesn't decrease even if trif>tlimit :(
maybe in DEFINE_PROFILE trif isn't the one defined in the previuos function (DEFINE_ADJUST)?

Amir December 20, 2011 04:47

Yes; use global variable for "trif"

Bests,


All times are GMT -4. The time now is 08:15.