|
[Sponsors] |
November 21, 2021, 01:26 |
call temperature in Profile UDF
|
#1 |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
Hello,
In DEFINE_PROFILE , I want to call temperature of cell but when i run the file error "Node 0: Process 1404 : Received signal SIGSEGV" comes up .I'm sure problem because of C_T(c,t) .How can i call temperature in DEFINE_PROFILE? here's my udf: DEFINE_PROFILE(temperature_profile,t,i) { cell_t c; float temparc; float timeflow = CURRENT_TIME; begin_c_loop(c,t) { if (timeflow>=0.021 || timeflow<=0.0346){ temparc=C_T(c,t); F_PROFILE(c,t,i) =temparc; } else F_PROFILE(c,t,i) =600; } end_c_loop(c,t) } Best Regards, |
|
November 21, 2021, 23:47 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
instead of float use real
this UDF could work only in zones (not boundaries) apply it correctly. put #include "udf.h" in the very first line
__________________
best regards ****************************** press LIKE if this message was helpful |
|
November 22, 2021, 10:05 |
|
#3 |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
Thank you for your response, I used #include "udf.h" but I didn't copy here I forgot.
I have another problem I want to write profile (udf) which for specific time use tabular data and out of these time use the temperature that FLUENT is computed. but when i want to use temperature that FLUENT is computed it gets me the last temperature in tabular data how can I define that don't use these tabular data after specific time here is my part of code /* Interpolate temperature from look-up table and assign to cell value */ DEFINE_PROFILE(temperature_profile,t,i) { cell_t c; float time_flow = CURRENT_TIME; float temparc; float tempp=C_T(c,t); begin_c_loop(c,t) { if (time_flow>=0.021 && time_flow<=0.0346){ temparc=get_tem_from_time(time_flow); F_PROFILE(c,t,i) =temparc; }else F_PROFILE(c,t,i) =tempp; } end_c_loop(c,t) } |
|
November 22, 2021, 10:07 |
|
#4 | |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
Quote:
I have another problem I want to write profile (udf) which for specific time use tabular data and out of these time use the temperature that FLUENT is computed. but when i want to use temperature that FLUENT is computed it gets me the last temperature in tabular data how can I define that don't use these tabular data after specific time here is my part of code /* Interpolate temperature from look-up table and assign to cell value */ DEFINE_PROFILE(temperature_profile,t,i) { cell_t c; float time_flow = CURRENT_TIME; float temparc; float tempp=C_T(c,t); begin_c_loop(c,t) { if (time_flow>=0.021 && time_flow<=0.0346){ temparc=get_tem_from_time(time_flow); F_PROFILE(c,t,i) =temparc; }else F_PROFILE(c,t,i) =tempp; } end_c_loop(c,t) } |
||
November 22, 2021, 23:59 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
show code for get_tem_from_time function
__________________
best regards ****************************** press LIKE if this message was helpful |
|
November 24, 2021, 14:53 |
|
#6 |
Member
sina
Join Date: Nov 2021
Posts: 41
Rep Power: 5 |
#include "udf.h"
int NPts_tem = 111; /* number of entries in temperature table */ /* Locate the place in the interpolation vector using bisection algorithm*/ int locate(float xx[], int n, float x) { int j = 0; int jm = 0; int jl = 0; int ju = n+1; int ascnd = 0; ascnd = (xx[n] >= xx[1]); while (ju-jl > 1) { jm = (ju+jl) >> 1; if (x >= xx[jm] == ascnd) jl = jm; else ju = jm; } if (x == xx[1]) j = 1; else if (x == xx[n]) j = n-1; else j = jl; return j; } /* -----Understood------ */ float *time_vec_tem,*tem_vec; #define FAST_LOOKUP TRUE /* use bisection algorithm for interpolation */ #define TABLE_MESSAGES TRUE #define DISPLAY_TABLES TRUE /* Obtaine mu given temperature */ float get_tem_from_time(float xdata) { int i = 0; int j = 0; float xL,xU,ydata; #if FAST_LOOKUP j = locate(time_vec_tem,NPts_tem,xdata); xL = time_vec_tem[j]; xU = time_vec_tem[j+1]; ydata = tem_vec[j] + (xdata-xL)/(xU-xL)*( tem_vec[j+1] - tem_vec[j] ); #else for ( i=1; i<NPts_tem ;i++ ) { xL = time_vec_tem[i]; xU = time_vec_tem[i+1]; if ( (xdata>=xL)&&(xdata<=xU) ) { ydata = tem_vec[i] + (xdata-xL)/(xU-xL)*( tem_vec[i+1] - tem_vec[i] ); break; } } #endif if ( xdata>time_vec_tem[NPts_tem] ) { #if TABLE_MESSAGES Message("n temperature is above the bound of visc-array n"); #endif ydata = tem_vec[NPts_tem]; } if ( xdata<time_vec_tem[1] ) { #if TABLE_MESSAGES Message("n temperature is below the bound of visc-array n"); #endif ydata = tem_vec[1]; } return ydata; } /* -----Understood------*/ /* Read in the data file containing temperature as a function of time */ DEFINE_ON_DEMAND(read_arctemperature) { int i = 0; float xdata,ydata; FILE* fp; fp = fopen("arctemperature.dat","r"); if ( fp!=NULL ) { #if !RP_NODE Message(" \n"); Message("Reading file arctemperature.dat \n"); Message(" \n"); #endif } else { #if !RP_NODE Message(" \n"); Message("Error opening file \n"); Message(" \n"); #endif } time_vec_tem = (float *) malloc(NPts_tem*sizeof(float)); /*Dynamic Memory Allocation*/ tem_vec = (float *) malloc(NPts_tem*sizeof(float)); /*Dynamic Memory Allocation*/ if ( (time_vec_tem==NULL)||(tem_vec==NULL) ) { #if !RP_NODE Message("Memory allocation error \n"); #endif } for ( i=1;i<=NPts_tem;i++ ) { fscanf(fp,"%e %e \n",&xdata,&ydata); time_vec_tem[i] = xdata; tem_vec[i] = ydata; #if DISPLAY_TABLES #if !RP_NODE Message("%e %e \n",time_vec_tem[i],tem_vec[i]); #endif } #else } #if !RP_NODE Message(" \n"); #endif #endif fclose(fp); } /* Interpolate temperature from look-up table and assign to cell value */ DEFINE_PROFILE(temperature_profile,t,i) { cell_t c; float time_flow = CURRENT_TIME; float temparc; float tempp=C_T(c,t); begin_c_loop(c,t) { if (time_flow>=0.021 && time_flow<=0.0346){ temparc=get_tem_from_time(time_flow); F_PROFILE(c,t,i) =temparc; }else F_PROFILE(c,t,i) =tempp; } end_c_loop(c,t) } |
|
Tags |
profile, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Temperature Profile UDF | AC1993 | Fluent UDF and Scheme Programming | 1 | November 1, 2016 03:15 |
Temperature profile UDF for 3D cylinder surface | Himel | Fluent UDF and Scheme Programming | 1 | June 16, 2015 11:59 |
defining temperature profile with UDF | mohammadkm | Fluent UDF and Scheme Programming | 11 | July 3, 2013 01:15 |
is internalField(U) equivalent to zeroGradient? | immortality | OpenFOAM Running, Solving & CFD | 7 | March 29, 2013 02:27 |
UDF for linear temperature profile on horizontal parallel surfaces. | Chirag2302 | Fluent UDF and Scheme Programming | 0 | February 4, 2012 01:44 |