|
[Sponsors] |
September 3, 2015, 05:42 |
need some corrections in my UDF
|
#1 |
Member
|
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) } |
|
September 3, 2015, 07:43 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
As the error shows, the problem is on line 26:
Code:
face_t counter = 1 ; |
|
September 4, 2015, 01:42 |
|
#3 |
Member
|
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 |
|
September 4, 2015, 02:40 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Try:
Code:
#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); hVec = AH * WA * sint; //i = i + 1; //This statement has no effect so just delete it if not needed } end_f_loop(f,tf) } |
|
September 4, 2015, 02:57 |
|
#5 |
Member
|
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. |
|
September 4, 2015, 17:16 |
|
#6 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
That's the same error, move the declarations to the start of the code block:
Code:
#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] ; float hVec[1000] ; //if float is not available then it may be real (check it out and also change others) float sint ; xVec[0] = 0 ; for (counter = 1 ; counter < XSize ; counter++) { xVec[counter] = xVec[counter - 1] + XStep; } begin_f_loop(f,tf) { curr_time = CURRENT_TIME; sint = sin (2 * PI/Lambda * xVec - C * curr_time); } end_f_loop(f,tf) } |
|
September 7, 2015, 03:47 |
|
#7 |
Member
|
Great.the previous errors have vanished but we have the following two new errors
..\..\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 |
|
September 7, 2015, 11:09 |
|
#8 |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
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); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 08:37 |
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF | acasas | CFD Freelancers | 1 | January 23, 2015 08:26 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
How to add a UDF to a compiled UDF library | kim | FLUENT | 3 | October 26, 2011 22:38 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |