|
[Sponsors] |
Scheme macro with random creation of waterdrops |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 31, 2011, 05:05 |
Scheme macro with random creation of waterdrops
|
#1 |
New Member
Join Date: Jan 2011
Posts: 8
Rep Power: 15 |
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: (cx-macro-define '((autodrop . "(if (= (truncate (/ (rpgetvar 'flow-time) 0.05)) (+ (truncate (/ (- (rpgetvar 'flow-time) (rpgetvar 'physical-time-step)) 0.05)) 1)) (begin (ti-menu-load-string \"adapt/free-registers yes\") (do ((x 0 (+ x 0.05))) ((>= x 1)) (ti-menu-load-string \"adapt/mark-inout-circle yes no (* 3650 sin((/ (+ 100 (random 590)) 3650))) (- (* 3650 cos((/ (+ 100 (random 590)) 3650))) 3650) 1) (ti-menu-load-string \"solve/patch phase-water () sphere-r~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 x-y-position 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: 15 |
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 'flow-time) 0.00003)) (+ (truncate (/ (- (rpgetvar 'flow-time) (rpgetvar 'physical-time-step)) 0.00003)) 1)) (begin (+ i 1) (+ x 1) (if (= x 25) (exit)) (if (= i 15) ((= i 1) )) (ti-menu-load-string \"adapt/mark-inout-circle yes no (* 3650 (sin (/ 400 3650))) (- (* 3650 (cos (/ 400 3650))) 3650) 1\") (ti-menu-load-string (format #f \"solve/patch phase-water () (~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: 192
Rep Power: 16 |
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: 15 |
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("flow-time"); 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: 15 |
Is there anyone who can help me? I couldn't make any progress in that problem...
|
|
Tags |
command, macro, scheme |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to understand high resolution scheme and high order scheme | iilw1314 | Main CFD Forum | 7 | April 12, 2022 13:29 |
AUSM scheme ? Central Scheme | boling | Main CFD Forum | 7 | January 7, 2016 03:41 |
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 |