|
[Sponsors] |
December 18, 2015, 17:56 |
UDF for square wave - not compiling
|
#1 |
New Member
Sarah Garden
Join Date: Sep 2014
Posts: 10
Rep Power: 12 |
Hello,
I have attempted to write a UDF, below, which needs to do as the comment in the header says. The model is an aerofoil with a small 'slot' where a 'pressure-outlet' boundary condition is designated. When I tested it, it didn't compile; the error says 'XtGrabPointer failed'. I think there need to be three statements in the 'for'. Although I seem to remember reading that you can get by with only two statements, and neglect the last one, so long as you keep the semicolon for the first two. Can somebody please verify this?? Also, can anybody please hint as to a better way of structuring this? Perhaps different kinds of loops.. I am (obviously) a novice in C, I'm afraid, so any feedback will be much appreciated. /* alpha cycles upwards then downwards in angle of attack between 3 and 8 degrees. A pressure ejection must begin at ~5 degrees while alpha is decreasing, and finish at ~3 degrees while still decreasing, like an on-off switch. This matches a half square wave with phase delay of -2pi/3*/ #include "udf.h" #define PI 3.14159 DEFINE_PROFILE(blowing, thread, position) { face_t f; begin_f_loop(f, thread) { real period = 12.08305; real t = CURRENT_TIME; real alpha; int n=0; for(alpha = (5.5+2.5*sin(0.52*t)); t<=(n+1)*period; ) { if(t<=(n+1)*period) { if(((2*n+1)*(period/2)<=t<=(n+1)*period) && (5.0584>=alpha>=3.0392) ) { F_PROFILE(f, thread, position) = 0.5; } else { F_PROFILE(f, thread, position) = 0; } } else { n += 1; /*if t>(n+1)*period, increment integer counter by 1 before going further*/ } /* still in the body of the for, so back to first if?- sarah does not understand*/ } } end_f_loop(f, thread) } Last edited by SarahG; December 19, 2015 at 17:10. |
|
December 21, 2015, 04:12 |
|
#2 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[waves2Foam] Waves2Foam Related Topics | ngj | OpenFOAM Community Contributions | 660 | August 20, 2018 13:39 |
Basic question regarding compiling a UDF | A.Jalal | Fluent UDF and Scheme Programming | 2 | August 6, 2015 14:57 |
UDF compiling problem in Flient 6.3 | jeevan kumar | FLUENT | 2 | February 25, 2009 01:43 |
error while compiling a udf | rahul | FLUENT | 10 | August 30, 2006 09:33 |
On Compiling a UDF | David Chabot | FLUENT | 5 | May 20, 2005 10:13 |