
[Sponsors] 
January 31, 2011, 05:05 
Scheme macro with random creation of waterdrops

#1 
New Member
Join Date: Jan 2011
Posts: 8
Rep Power: 7 
Hello,
I am using Fluent 6.3 to calculate a complex 2D biphasic simulation. At the moment, I want to patch water drops on a surface while the simulation is running. This should simulate raindrops on a windshield. That is why I just see the possibility to do that with a macro. I already wrote a command in scheme, but there is always an error when running the simulation. I have big problems in finding the mistake, because of a missing debugger in scheme. My code is the following: (cxmacrodefine '((autodrop . "(if (= (truncate (/ (rpgetvar 'flowtime) 0.05)) (+ (truncate (/ ( (rpgetvar 'flowtime) (rpgetvar 'physicaltimestep)) 0.05)) 1)) (begin (timenuloadstring \"adapt/freeregisters yes\") (do ((x 0 (+ x 0.05))) ((>= x 1)) (timenuloadstring \"adapt/markinoutcircle yes no (* 3650 sin((/ (+ 100 (random 590)) 3650))) ( (* 3650 cos((/ (+ 100 (random 590)) 3650))) 3650) 1) (timenuloadstring \"solve/patch phasewater () spherer~a () mp 1\"))") )) I want to add randomly every 0.05s a new drop to the windshield. I do this by marking a circle on the windshield and then patching it with water, but Fluent always runs into an EOF error. The sin() and cos() functions are needed to calculate the xyposition on the windshield, because it is not flat. I hope you can help me solving this problem. Maybe there is another possibility to patch without a macro while the simulation is running, too. Thank you in advance for helping me! 

January 31, 2011, 11:12 

#2 
New Member
Join Date: Jan 2011
Posts: 8
Rep Power: 7 
Ok, I improved the whole thing a bit. It seems to work now except the creation of a random value. Normally there should be instead of the 400(bold) a random number between 100 and 690. If you have any idea how to solve that problem, please let me know.
Here's my improved code: (autodrop . "(define i 1) (define x 0) (if (= (truncate (/ (rpgetvar 'flowtime) 0.00003)) (+ (truncate (/ ( (rpgetvar 'flowtime) (rpgetvar 'physicaltimestep)) 0.00003)) 1)) (begin (+ i 1) (+ x 1) (if (= x 25) (exit)) (if (= i 15) ((= i 1) )) (timenuloadstring \"adapt/markinoutcircle yes no (* 3650 (sin (/ 400 3650))) ( (* 3650 (cos (/ 400 3650))) 3650) 1\") (timenuloadstring (format #f \"solve/patch phasewater () (~a) mp 1\" i))))") Thanks for any help. 

January 31, 2011, 22:41 

#3 
Senior Member
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 180
Rep Power: 8 
Schemer,
I'm not much for writing scheme code, but I know this can be done with a UDF via a define_adjust udf (look up begin_f_loop(f,t)). You'll loop over all faces on a boundary, choose a random (or specified) X,Y coordinate, then choose your random value for the diameter(?) of the droplet. Regards, ComputerGuy 

February 1, 2011, 10:05 

#4 
New Member
Join Date: Jan 2011
Posts: 8
Rep Power: 7 
Thanks for your answer.
At the moment, I'm giving my best to write an UDF, but I'm very unexperienced with C and writing UDFs. But here's my try: Code:
DEFINE_ADJUST(drop_inject,d) { Thread *t; cell_t c; real time = RP_Get_Real("flowtime"); real x_coord; real y_coord; real drop_area; if (time % 0.0025 ==0.) {begin_f_loop(face, face_thread) {x_coord=3650.*sin((100.+rand()%590)/3650.); y_coord=3650.+3650*cos((100.+rand()%590)/3650.); drop_area=M_PI*1.; F_VOF(face,t)=1.; } } } Any help would be great! 

February 7, 2011, 04:12 

#5 
New Member
Join Date: Jan 2011
Posts: 8
Rep Power: 7 
Is there anyone who can help me? I couldn't make any progress in that problem...


Tags 
command, macro, scheme 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
AUSM scheme ? Central Scheme  boling  Main CFD Forum  7  January 7, 2016 03:41 
how to understand high resolution scheme and high order scheme  iilw1314  Main CFD Forum  3  September 30, 2010 10:43 
Godunov scheme  Peter  Main CFD Forum  6  November 27, 2009 11:51 
Definition of limiter function for central dirrerencing scheme  sebastian_vogl  OpenFOAM Running, Solving & CFD  0  January 5, 2009 12:08 
extrapolation in MUSCL scheme  Chandra  Main CFD Forum  6  February 14, 2007 12:21 