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

Strange problem: unresolved external symbol only for parallel UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 26, 2017, 10:34
Default Strange problem: unresolved external symbol only for parallel UDF
  #1
Member
 
Join Date: Oct 2014
Posts: 43
Rep Power: 11
lisa_china is on a distinguished road
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)	
	}	
	
}
And the error is:
Quote:
Copied E:\Shane\2_Simulation\FGMTest\PPJB\Check2.c to check\src
udf_names.c and user_nt.udf files in 2ddp_host are upto date.
(system "copy "D:\Program Files\ANSYS Inc\v150\fluent"\fluent15.0.0\src\makefile_nt.udf "check\win64\2ddp_host\makefile" ")
1 file(s) copied
(chdir "check")(chdir "win64\2ddp_host")# Generating ud_io1.h
Check2.c
# Generating udf_names.c because of Check2.obj
udf_names.c
udf_names.c(10) : warning C4113: “void (*)()”differs in parameter lists from 'void (*)(void)
udf_names.c(11) : warning C4113: “void (*)()”differs in parameter lists from 'void (*)(void)
udf_names.c(12) : warning C4113: “void (*)()”differs in parameter lists from 'void (*)(void)
# Linking libudf.dll because of udf_names.obj Check2.obj
Microsoft (R) Incremental Linker Version 11.00.61030.0
Copyright (C) Microsoft Corporation. All rights reserved.

Creating library libudf.lib and object libudf.exp
Check2.obj : error LNK2019: unresolved external symbol __imp_Turbulent_Premixed_Source referenced in adjust_fcn
libudf.dll : fatal error LNK1120: 1 unresolved externals

udf_names.c and user_nt.udf files in 2ddp_node are upto date.
(system "copy "D:\Program Files\ANSYS Inc\v150\fluent"\fluent15.0.0\src\makefile_nt.udf "check\win64\2ddp_node\makefile" ")
1 file(s) copied.
(chdir "check")(chdir "win64\2ddp_node")# Generating ud_io1.h
Check2.c
# Generating udf_names.c because of Check2.obj
udf_names.c
udf_names.c(10) : warning C4113: “void (*)()”和“void (*)(void)”differs in parameter lists from 'void (*)(void)
udf_names.c(11) : warning C4113: “void (*)()”和“void (*)(void)”differs in parameter lists from 'void (*)(void)
udf_names.c(12) : warning C4113: “void (*)()”和“void (*)(void)”differs in parameter lists from 'void (*)(void)
# Linking libudf.dll because of udf_names.obj Check2.obj
Microsoft (R) Incremental Linker Version 11.00.61030.0
Copyright (C) Microsoft Corporation. All rights reserved.
Also, it was confirmed the error occurs when the code is compiled for host, because when I added the sentence # if !RP_HOST after the curly brace of the DEFINE_ADJUST, the code for parallel is compiled with no error.

Any discussion is welcome. And thanks in advance.

Shan
lisa_china is offline   Reply With Quote

Old   May 29, 2017, 22:50
Default
  #2
Member
 
Join Date: Oct 2014
Posts: 43
Rep Power: 11
lisa_china is on a distinguished road
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
lisa_china 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
my udf problem!!! mostanad Fluent UDF and Scheme Programming 3 January 10, 2017 12:23
UDF Problem Fluent 13 ZsoltiV Fluent UDF and Scheme Programming 4 October 30, 2016 02:47
UDF compiling problem Wouter Fluent UDF and Scheme Programming 6 June 6, 2012 04:43
problem in compoile UDF h.daniyel FLUENT 5 June 12, 2008 05:06
Unresolved external symbol Hamsdi CFX 1 November 5, 2001 14:01


All times are GMT -4. The time now is 06:32.