CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Scheme macro with random creation of waterdrops

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 31, 2011, 05:05
Default Scheme macro with random creation of waterdrops
  #1
New Member
 
Join Date: Jan 2011
Posts: 8
Rep Power: 15
schemer is on a distinguished road
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!
schemer is offline   Reply With Quote

Old   January 31, 2011, 11:12
Default
  #2
New Member
 
Join Date: Jan 2011
Posts: 8
Rep Power: 15
schemer is on a distinguished road
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.
schemer is offline   Reply With Quote

Old   January 31, 2011, 22:41
Default
  #3
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
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
ComputerGuy is offline   Reply With Quote

Old   February 1, 2011, 10:05
Default
  #4
New Member
 
Join Date: Jan 2011
Posts: 8
Rep Power: 15
schemer is on a distinguished road
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.;
     }
    }
}
That is what I wrote until now and I know it's wrong. But I don't know how to say that he should fill the drop area which is at the x/y coordinate position with water.
Any help would be great!
schemer is offline   Reply With Quote

Old   February 7, 2011, 04:12
Default
  #5
New Member
 
Join Date: Jan 2011
Posts: 8
Rep Power: 15
schemer is on a distinguished road
Is there anyone who can help me? I couldn't make any progress in that problem...
schemer is offline   Reply With Quote

Reply

Tags
command, macro, scheme


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 15:17.