|
[Sponsors] |
Strange problem: unresolved external symbol only for parallel UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 26, 2017, 11:34 |
Strange problem: unresolved external symbol only for parallel UDF
|
#1 | |
Member
Join Date: Oct 2014
Posts: 43
Rep Power: 12 |
Dear all,
I got a very strange problem: The UDF.c can be compiled successfully for serial, while an error occurs with parallel process. Since it works pretty good for serial, I don't think that the problem is related to the settings of environment. So the code is listed below: Code:
#include "udf.h" #include "species.h" #include "math.h" #include "stdio.h" #include "string.h" #include "stdlib.h" #include "pdf_props.h" #include "sg_mem.h" #include "mem.h" #include "storage.h" #include "sg_pdf.h" static real logNOxvsT = -27473.2; static real Tad = 1918.6; /*need to be calculated in advance*/ static real p = 101325; static real WT_CH4=16.043; static real WT_CO=28.0106; static real WT_CO2=44.01; static real WT_C=12.0112; /*reaction index*/ /* NO+N->N2+O 0*/ /* N2O+O->2NO 1*/ /* NH+NO->N2O+H 2*/ /*0 and 2 need to be calculate with the equilibrium constant*/ static real AcEnergy[3]={355.00,23150.00,0.0}; /*units, cal/mol, the activation energy of reactions*/ static real PreExponent[3]={2.7e13,2.9e13,3.65e14}; /*units, according to the reaction, the pre-exponent of reactions*/ static real beta[3]={0.0,0.0,-0.45}; DEFINE_ADJUST(adjust_fcn,d) { /*argument type*/ real postflame_NOx_rate_heatloss; real exponent; real source_ff; real source_pf; real turbulent_flame_speed, c_source; real temp; real carbon_conversion; real rr; real rate_explicit; real rate_implicit; real rr_l; real rr_t; real phi; real Teq; real X_N2, X_O, X_H, X_N2O, Y_C; real Conc; real Rate1,Rate2; real flamefront_NOx; char combMd[10]; int i; float a[401][10]={{0}}; float b1,b2,b3,b4,b5,b6,b7,b8,b9,b10; int n=0; /*define array a to store equilibrium value*/ /*column 1: equivalence ratio*/ /*column 2: unburned temperature*/ /*column 3: equilibrium constant, NO+N->N2+O*/ /*column 4: equilibrium constant, NH+NO->N2O+H*/ /*column 5: equilibrium mole fraction of N2*/ /*column 6: equilibrium mole fraction of O*/ /*column 7: equilibrium mole fraction of H*/ /*column 8: equilibrium mole fraction of N2O*/ /*column 9: NO value in flame front*/ /*column 10: equilibrium temperature with constant pressure and enthalphy*/ Thread *t; cell_t c; FILE *fp; /*read equilibrium from file*/ if((fp=fopen("equilibrium.txt","r"))==NULL) { printf("error in reading file !\n"); exit(1); } else { while(!feof(fp)) { ++n; if(fscanf(fp,"%f%f%f%f%f%f%f%f%f%f",&b1,&b2,&b3,&b4,&b5,&b6,&b7,&b8,&b9,&b10)==EOF) break; a[n-1][0]=b1; a[n-1][1]=b2; a[n-1][2]=b3; a[n-1][3]=b4; a[n-1][4]=b5; a[n-1][5]=b6; a[n-1][6]=b7; a[n-1][7]=b8; a[n-1][8]=b9; a[n-1][9]=b10; // Message("%.2e%.2e%.2e%.2e\n",a[n-1][0],a[n-1][1],a[n-1][2],a[n-1][3]); } fclose(fp); // system("pause"); } thread_loop_c(t,d) { begin_c_loop_all(c,t) { C_UDMI(c,t,0) = 0; C_UDMI(c,t,1) = 0; Y_C =WT_C/WT_CO2*Pdf_Yi(c,t,1)+WT_C/WT_CO*Pdf_Yi(c,t,4) + WT_C/WT_CH4*Pdf_Yi(c,t,3); phi = Y_C/12*16/(1-Y_C/12*16)/(16/(2*32+7.52*28));; // Message("%.2e\n",phi); // system("pause"); carbon_conversion=(Y_C-WT_C/WT_CH4*Pdf_Yi(c,t,3))/Y_C; for(i=0;i<n-1;i++) { if(phi<=a[i+1][0]&&phi>=a[i][0]) { // Message("%.2e\n",carbon_conversion); // system("pause"); flamefront_NOx=(phi-a[i][0])/(a[i+1][0]-a[i][0])*(a[i+1][8]-a[i][8])+a[i][8]; if (carbon_conversion >=0.95) { Teq=(phi-a[i][0])/(a[i+1][0]-a[i][0])*(a[i+1][9]-a[i][9])+a[i][9]; Conc= p/(1e6*8.314*Teq); X_N2=(phi-a[i][0])/(a[i+1][0]-a[i][0])*(a[i+1][4]-a[i][4])+a[i][4]; X_O= (phi-a[i][0])/(a[i+1][0]-a[i][0])*(a[i+1][5]-a[i][5])+a[i][5]; X_H= (phi-a[i][0])/(a[i+1][0]-a[i][0])*(a[i+1][6]-a[i][6])+a[i][6]; X_N2O=(phi-a[i][0])/(a[i+1][0]-a[i][0])*(a[i+1][7]-a[i][7])+a[i][7]; // Message("for test 8\n"); Rate1 = 2*X_N2*Conc*X_O*Conc*PreExponent[0]*exp(-AcEnergy[0]*4.186/8.314/Teq)/a[1][2]*pow(Teq,beta[0]); Rate2 = 2*X_N2O*Conc*X_O*Conc*PreExponent[1]*exp(-AcEnergy[1]*4.186/8.314/Teq)*pow(Teq,beta[1])+X_N2O*Conc*X_H*Conc*PreExponent[2]*exp(-AcEnergy[2]*4.186/8.314/Teq)/a[1][3]*pow(Teq,beta[2]); C_UDMI(c,t,0) = 28*(Rate1+Rate2)*1000; Turbulent_Premixed_Source(c,t,&turbulent_flame_speed,&c_source); C_UDMI(c,t,1)=c_source*flamefront_NOx; } else { // Message("test for explicit\n"); // system("pause"); C_UDMI(c,t,0)=0; Turbulent_Premixed_Source(c,t,&turbulent_flame_speed,&c_source); C_UDMI(c,t,1)=c_source*flamefront_NOx; } break; } else if(phi<a[0][0]||phi>a[n-1][0]) { // Message("else if\n"); C_UDMI(c,t,0)=1; C_UDMI(c,t,1)=1; continue; } } } end_c_loop_all(c,t) } } Quote:
Any discussion is welcome. And thanks in advance. Shan |
||
May 29, 2017, 23:50 |
|
#2 |
Member
Join Date: Oct 2014
Posts: 43
Rep Power: 12 |
The problem has been fixed. To Solve it, we need to make sure that no error with code and then for parallel, one sentence need to be added: # IF !RP_HOST. It means the calculation occurs on the nodes, the code will be executed.
In Fluent, the host usually is used to store data or process figures. Thanks for your attention on this question. Shan |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
my udf problem!!! | mostanad | Fluent UDF and Scheme Programming | 3 | January 10, 2017 13:23 |
UDF Problem Fluent 13 | ZsoltiV | Fluent UDF and Scheme Programming | 4 | October 30, 2016 03:47 |
UDF compiling problem | Wouter | Fluent UDF and Scheme Programming | 6 | June 6, 2012 05:43 |
problem in compoile UDF | h.daniyel | FLUENT | 5 | June 12, 2008 06:06 |
Unresolved external symbol | Hamsdi | CFX | 1 | November 5, 2001 15:01 |