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

udf to get pressure of the cell with the minimum temperature

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 8, 2023, 11:24
Default udf to get pressure of the cell with the minimum temperature
  #1
New Member
 
Springyuu
Join Date: Nov 2019
Posts: 14
Rep Power: 7
Springyuu is on a distinguished road
Hi, everyone!I'm trying to write an udf to get the minimum temperature of cell, then get pressure and coordinates of that cell.
The udf I wrote can be load and built, but when execute on demand, an error message occurs,"Node 999999: Process 98196: Received signal SIGSEGV. The fl process could not be started.".
Can anyone give me some advice or help me fix the code? thanks~


#include "udf.h"

DEFINE_ON_DEMAND(on_demand_calc)
{
Domain *d;
real tmin = 0;
real temp, press, tmin_x,tmin_y;
Thread *t;
cell_t c;
cell_t tmin_cell;
Thread *tmin_t;

real xc[ND_ND];

d = Get_Domain(1);

thread_loop_c(t, d)
{
begin_c_loop(c, t)
{
temp = C_T(c, t);
if (temp < tmin || tmin == 0.0)
{
tmin = temp;
tmin_cell = c;
tmin_t = t;
}
}
end_c_loop(c, t)
}

C_CENTROID(xc,tmin_cell,tmin_t);
tmin_x = xc[0];
tmin_y = xc[1];
printf("\n Xtmin=%g Ymin=%g\n", tmin_x, tmin_y);

press = C_P(tmin_cell, tmin_t);

printf("\n Tmin=%g Press=%g\n",tmin, press);
}
Springyuu is offline   Reply With Quote

Old   November 9, 2023, 00:33
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
#include "udf.h"

DEFINE_ON_DEMAND(on_demand_calc)
{
Domain *d;
real tmin = 0;
real temp, press, tmin_x,tmin_y;
Thread *t;
cell_t c;
cell_t tmin_cell;
Thread *tmin_t;

real xc[ND_ND];

d = Get_Domain(1);

thread_loop_c(t, d)
{
begin_c_loop(c, t)
{
temp = C_T(c, t);
if (temp < tmin || tmin == 0.0)
{
tmin = temp;
tmin_cell = c;
tmin_t = t;
}
}
end_c_loop(c, t)
}

C_CENTROID(xc,tmin_cell,tmin_t);
tmin_x = xc[0];
tmin_y = xc[1];
Message0("\n Xtmin=%g Ymin=%g\n", tmin_x, tmin_y);

press = C_P(tmin_cell, tmin_t);

Message0("\n Tmin=%g Press=%g\n",tmin, press);
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 9, 2023, 08:29
Default
  #3
New Member
 
Springyuu
Join Date: Nov 2019
Posts: 14
Rep Power: 7
Springyuu is on a distinguished road
thanks, it's useful to use Message0 or Message instead of printf.
Springyuu 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
Temperature anomoly at pressure reference cell will.logie OpenFOAM Running, Solving & CFD 22 July 17, 2021 00:26
UDF in case with DPM modle POSTHU Fluent UDF and Scheme Programming 0 March 3, 2021 08:21
UDF for pressure outlet backflow total temperature MrDaimon FLUENT 13 June 23, 2017 01:45
UDF: Pointing Cell Pressure Jim87 Fluent UDF and Scheme Programming 4 October 20, 2013 14:56
Cells with t below lower limit Purushothama Siemens 2 May 31, 2010 22:58


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