-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to parallize the UDF code of dynamic contact angle #1
Comments
@brucelqs |
Hello, this is the parallelization code I am using now, maybe you can find useful information from it.
#include "udf.h" double contact_line_position = 0; double time = 0; double theta_e_radian = (110.0 * M_PI / 180.0); double dynamic_contact_angle = 110.0; int first_time = 1; double contact_velocity = 0; FILE* file; double sum = 0.0, R; DEFINE_ADJUST(Contact_Angle_Update, domain) { Thread* thread = Lookup_Thread(domain, 9); Thread** pt = THREAD_SUB_THREADS(thread); cell_t cell; face_t f; real x[ND_ND]; double max_x = 0, f_Hoff_inverse, x_hoff, temp, Ca, volume; int n; sum = 0.0; begin_c_loop_all(cell, pt[1]) { if (C_VOF(cell, pt[1]) != 0) { C_CENTROID(x, cell, pt[1]); if (x[0] > max_x) max_x = x[0]; } sum += C_VOF(cell, pt[1]); } end_c_loop_all(cell, pt[1]) #if RP_NODE sum = PRF_GRSUM1(sum); #endif R = sqrt(sum * 1.0e-08 / M_PI); Message0("max_x=%f R=%f contact_velocity=%f time=%f dynamic_contact_angle=%f sum=%f\n", max_x, R, contact_velocity, time, dynamic_contact_angle, sum); if (first_time == 0) { contact_velocity = (R - contact_line_position) / (RP_Get_Real("flow-time") - time); contact_line_position = R; time = CURRENT_TIME; Ca = contact_velocity * 1e-3 / 0.0728; temp = 0.5 - 0.5 * cos(theta_e_radian); temp = 0.5 * log((1.0 + temp) / (1.0 - temp)); f_Hoff_inverse = -(9.78546 * pow(temp, 1.416430594900850)) / (12.819 * pow(temp, 1.41643) - 100.0); x_hoff = Ca + f_Hoff_inverse; if (contact_velocity >= 0) dynamic_contact_angle = acos(1. - 2. * tanh(5.16 * pow((x_hoff / (1. + 1.31 * pow(x_hoff, .99))), 0.706))) * 180.0 / M_PI; else dynamic_contact_angle = 2. * theta_e_radian * 180.0 / M_PI - acos(1. - 2. * tanh(5.16 * pow((x_hoff / (1. + 1.31 * pow(x_hoff, .99))), 0.706))) * 180.0 / M_PI; node_to_host_real_5(max_x, R, contact_velocity, time, dynamic_contact_angle); #if RP_HOST file = fopen("file.txt", "a+"); fprintf(file, "max_x=%f R=%f contact_velocity=%f time=%f dynamic_contact_angle=%f\n", max_x, R, contact_velocity, time, dynamic_contact_angle); fclose(file); #endif if (R > 1e-18 && first_time == 1) { contact_line_position = R; time = CURRENT_TIME; first_time = 0; #if RP_HOST file = fopen("file.txt", "a+"); fprintf(file, "max_x=%f R=%f contact_velocity=%f time=%f\n", max_x, R, contact_velocity, time); fclose(file); #endif } } } DEFINE_PROFILE(Contact_Angle_Set_Profile, t, i) { face_t f; begin_f_loop(f, t) { F_PROFILE(f, t, i) = dynamic_contact_angle; } end_f_loop(f, t) }
…------------------ 原始邮件 ------------------
发件人: "siramirsaman/Contact-Angle" ***@***.***>;
发送时间: 2022年5月11日(星期三) 上午10:46
***@***.***>;
抄送: "●·`Mr ***@***.******@***.***>;
主题: Re: [siramirsaman/Contact-Angle] How to parallize the UDF code of dynamic contact angle (Issue #1)
@brucelqs
hi,
Have you finish the parallelizing? I am now working on it. For the DESIRED_INTERVALS_BETWEEN_TWO_MEASUREMENTS, I think you should define the time step by yourself.
And can I watch your code, please? I am not sure how to parralleliz this
thanks!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
ah! Thanks for your code! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@siramirsaman
Dear Sir, I am a beginner, I am very grateful to you for providing the code for the dynamic contact angle. I have encountered some problems when parallelizing the code. I would like to ask you to answer. I am confused about some of your comments in the "UDF_CA_parallel.c" file. Why are the calculation of the 'capillary velocity' and the update of the 'contact_velocity' and 'dynamic_contact_angle' separate? When I compiled this code, FLUENT prompted some errors, such as: "DESIRED_INTERVALS_BETWEEN_TWO_MEASUREMENTS" is not defined. What is the reason for adding those variables? For which variables should this operation be performed? If you can reply to me, it will be my honor, thank you very much!
The text was updated successfully, but these errors were encountered: