|
[Sponsors] |
June 4, 2020, 11:35 |
Windkessel UDF using F_UDMI
|
#1 |
New Member
Connacht
Join Date: Feb 2020
Posts: 2
Rep Power: 0 |
Hi everyone,
I'm working on writing a UDF for a windkessel model (a flow-dependent pressure outlet boundary condition). This model can be thought of as an elastic bag, whose pressure increases as flow is integrated at the outlet at each timestep. To perform this integration, I am using user defined memory function F_UDMI to update the pressure from one time iteration to the next. I am reserving memory, initialising memory values, initialising my pressure using define_init, applying the windkessel model, and saving my pressure at the end of each iteration. However, when I run the solver, define_profile always thinks the initial value of F_UDMI(f,thread,0) is 0, despite the fact that I have initialised it to be 980 Pa in the functions below. Why would the solver be ignoring my initialisation functions / am I using F_UDMI correctly? Thanks so much Tom #include "udf.h" #define NUM_UDM 1 static int udm_offset = UDM_UNRESERVED; DEFINE_EXECUTE_ON_LOADING(on_loading, libname) { if (udm_offset == UDM_UNRESERVED) udm_offset = Reserve_User_Memory_Vars(NUM_UDM); if (udm_offset == UDM_UNRESERVED) Message("\nYou need to define up to %d extra UDMs in GUI and " "then reload current library %s\n", NUM_UDM, libname); else { Message("%d UDMs have been reserved by the current " "library %s\n", NUM_UDM, libname); Set_User_Memory_Name(udm_offset, "lib2-UDM-0"); } Message("\nUDM Offset for Current Loaded Library = %d", udm_offset); } DEFINE_ON_DEMAND(set_udms) { Domain* d; Thread* ft; face_t f; int i; d = Get_Domain(1); if (udm_offset != UDM_UNRESERVED) { Message("Setting UDMs\n"); for (i = 0; i < NUM_UDM; i++) { thread_loop_f(ft, d) { begin_f_loop(f, ft) { if (NUM_UDM > 0 && BOUNDARY_FACE_THREAD_P(ft)) { F_UDMI(f, ft, udm_offset + i) = 980.0; printf("The UDM value is %g \n ", F_UDMI(f, ft, udm_offset + i)); } } end_f_loop(f, ft) } } } else Message("UDMs have not yet been reserved for library 1\n"); } DEFINE_INIT(init_func, domain) { face_t f; Thread* ft = Lookup_Thread(domain, 7); begin_f_loop(f,ft) { F_P(f,ft)= 980.0; } end_f_loop(f,ft) } DEFINE_PROFILE(unsteady_pressure, thread, position) { face_t f; real flow = 0.0f; real C = 1.0f; real deltat = CURRENT_TIMESTEP; //should be current timestep? real R = 0.3f; real integrated; begin_f_loop(f, thread) { flow += F_FLUX(f, thread); } end_f_loop(f, thread); begin_f_loop(f, thread) { integrated = F_UDMI(f,thread,0) + ((1 / C) * (flow * deltat) * (10 ^ 4)); F_PROFILE(f, thread, position) = integrated; } end_f_loop(f, thread); } DEFINE_EXECUTE_AT_END(pressure_save) { Domain* domain = Get_Domain(1); Thread* thread = Lookup_Thread(domain, 7); face_t f; begin_f_loop(f, thread) { F_UDMI(f, thread, 0) = F_P(f, thread); } end_f_loop(f, thread) printf("Step Pressure Recorded!"); } |
|
June 24, 2021, 21:42 |
|
#2 |
New Member
weidong yang
Join Date: Jun 2021
Posts: 3
Rep Power: 5 |
I would like to ask you if this problem has been solved. I am also working on the Windkessel boundary problem.Can you share the code?thank you
|
|
June 25, 2021, 01:45 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
code above should be modified
In define_init macro author doesn't change the value of F_UDMI(f,thread,0)
__________________
best regards ****************************** press LIKE if this message was helpful |
|
June 25, 2021, 03:07 |
|
#4 |
New Member
weidong yang
Join Date: Jun 2021
Posts: 3
Rep Power: 5 |
||
June 25, 2021, 04:34 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
if you want to get help here, you are expected to do following:
describe your model in details show the code you have show log file after compiling describe problems
__________________
best regards ****************************** press LIKE if this message was helpful |
|
Tags |
f_udmi, udf, udm, user defined memory, windkessel |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
udf for one dimensional linear motion based on force | maccheese | Fluent UDF and Scheme Programming | 2 | September 1, 2019 03:18 |
Save output of udf in another udf! | JuanJoMex | FLUENT | 0 | February 8, 2018 13:43 |
UDF Compilation Error - Loading Library - COMMON Problem! Help! | robtheslob | Fluent UDF and Scheme Programming | 8 | July 24, 2015 01:53 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |