need some corrections in my UDF
1 Attachment(s)
Hi all
I am trying to simulate flow in a 2D channel by giving motion to the channel wall. here is the udf but after building the library fluent shows some errors. I need someone who can kindly correct my UDF. #include "udf.h" #include <stdlib.h> #include <math.h> #define AH 0.1 // Average Height of Channel #define XL 1.0 // Length #define WA 0.01 // Wave Amplitude #define PI 3.1415925 #define C 0.05 //Wave Speed #define Lambda 3.0 // wavelength #define XStep 0.001 #define XSize XL/XStep #define HStep 0.0001 #define HSize AH/HStep DEFINE_GRID_MOTION(peristaltic, domain, dt, time, dtime) { Thread *tf = DT_THREAD(dt) ; face_t f ; float curr_time = CURRENT_TIME ; //float xVec[XSize] ; //based on XStep you can pre compute how much should be the vector dimension (number of elements in xVec, say 1000 (replace it here) float xVec[1000] ; xVec[0] = 0 ; face_t counter = 1 ; for (counter = 1 ; counter < XSize ; counter++) { xVec[counter] = xVec[counter - 1] + XStep; } float hVec[1000] ; //if float is not available then it may be real (check it out and also change others) begin_f_loop(f,tf) { curr_time = CURRENT_TIME; float sint = sin (2 * PI/Lambda * xVec - C * curr_time); hVec = AH * WA * sint; //i = i + 1; //This statement has no effect so just delete it if not needed } end_f_loop(f,tf) } |
As the error shows, the problem is on line 26:
Code:
face_t counter = 1 ; |
thank you 'e' for your quick response. I have very little understanding of C language and UDF's. This code is written for me by my Brother. As a software engineer he does not understand proper syntax recognized by fluent. Can you kindly make the necessary changes in my code.
that will help me a lot. Regards |
Try:
Code:
#include "udf.h" |
Thank you so much 'e'.
After running your code the errors reduced to just two. given below #include "udf.h" #include <stdlib.h> #include <math.h> #define AH 0.1 // Average Height of Channel #define XL 1.0 // Length #define WA 0.01 // Wave Amplitude #define PI 3.1415925 #define C 0.05 //Wave Speed #define Lambda 3.0 // wavelength #define XStep 0.001 #define XSize XL/XStep #define HStep 0.0001 #define HSize AH/HStep DEFINE_GRID_MOTION(peristaltic, domain, dt, time, dtime) { Thread *tf = DT_THREAD(dt) ; int counter ; face_t f ; float curr_time = CURRENT_TIME ; //float xVec[XSize] ; //based on XStep you can pre compute how much should be the vector dimension (number of elements in xVec, say 1000 (replace it here) float xVec[1000] ; xVec[0] = 0 ; for (counter = 1 ; counter < XSize ; counter++) { xVec[counter] = xVec[counter - 1] + XStep; } float hVec[1000] ; //if float is not available then it may be real (check it out and also change others) begin_f_loop(f,tf) { curr_time = CURRENT_TIME; float sint = sin (2 * PI/Lambda * xVec - C * curr_time); } end_f_loop(f,tf) } # Generating ud_io1.h udfnew.c ..\..\src\udfnew.c(32) : error C2143: syntax error : missing ';' before 'type' ..\..\src\udfnew.c(37) : error C2143: syntax error : missing ';' before 'type' Done. |
That's the same error, move the declarations to the start of the code block:
Code:
#include "udf.h" |
Great.the previous errors have vanished :) but we have the following two new errors :o
..\..\src\final_UDF2.c(37) : error C2297: '*' : illegal, right operand has type 'float [1000]' ..\..\src\final_UDF2.c(37) : error C2198: 'sin' : too few arguments for call |
In this line you should add in the xVec the counter ([counter] or something like that).
sint = sin (2 * PI/Lambda * xVec[counter] - C * curr_time); |
All times are GMT -4. The time now is 02:00. |