|
[Sponsors] |
Printing out boundary velocity using execute at end macro |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 24, 2019, 14:59 |
Printing out boundary velocity using execute at end macro
|
#1 |
New Member
Firas Abdullatif
Join Date: Nov 2019
Posts: 4
Rep Power: 7 |
Hi all,
I am try to do a coupling scheme between two cases. Before I start start writing a code using another software I am trying to get preliminary results by transferring data using I/O files. Here I am trying to print the facet velocity of a certain face on a boundary. Now this code works but for about a quarter of the data its printing out zeros. It prints out zeros at random times. I believe that an error occurs during storing the values into the variables or looking up the thread for the domain. The macro is being executed as each time step but for some time steps the correct values are not printing. Please comment with any help you can provide. Thank you! float p_i[5]; float p_f[5]; float v_f_u[5]; float v_f_v[5]; FILE * fp; DEFINE_EXECUTE_AT_END(print_data) { face_t f; Domain *domain; domain=Get_Domain(1); Thread *t = Lookup_Thread(domain, 6); i=0; begin_f_loop(f, t) { v_f_u[i]=F_U(f,t); v_f_v[i]=F_V(f,t); p_f[i]=F_P(f,t); i++; } end_f_loop(f, t) fp = fopen("outletdata.txt", "a"); fprintf(fp,"%.16f ",v_f_u[3]); fclose(fp); } |
|
November 24, 2019, 16:11 |
|
#2 |
Member
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10 |
It's recommended to initialize an array before you use to prevent unphysical values
And do you have just 5 faces in the thread of your domain? Provide details of your domain to get more help -Abhinand |
|
November 24, 2019, 16:22 |
|
#3 |
New Member
Firas Abdullatif
Join Date: Nov 2019
Posts: 4
Rep Power: 7 |
Hi Abhinand,
I initialized the variables to zeros as follows. I truncated the code a little to make it more clear. float v_f_u[5]={0,0,0,0,0}; Also the domain is the outlet of a test case which is a pipe and at the outlet there are five faces. When you call in any of the five faces or just one at certain time steps only zeros are printed. Also more lines are printed that the number of time steps. Even after removing the lines with the zeros though, the number of line with correct values don't add up to the number of time steps. I will make another post with pictures for clarity Firas. |
|
November 24, 2019, 16:49 |
|
#4 |
New Member
Firas Abdullatif
Join Date: Nov 2019
Posts: 4
Rep Power: 7 |
I will post the exact UDF I just ran and a picture of the mesh. The values that are printing are correct because I compare them with the monitors that you can use for Fluent. I know what I am doing makes things more complicated but I am trying to exchange data between two boundaries of different cases (i.e. 2-d and 3-d cases).
int i=0; float v_f_u[5]={0,0,0,0,0}; FILE *fp; DEFINE_EXECUTE_AT_END(read_write_u_velocity) { face_t f; Domain *domain; domain=Get_Domain(1); Thread *t = Lookup_Thread(domain, 6); i=0; begin_f_loop(f, t) { v_f_u[i]=F_U(f,t); i++; } end_f_loop(f, t) fp = fopen("outlet_u_velocity.txt", "a"); fprintf(fp,"%.16f\n",v_f_u[3]); fclose(fp); } Here are the results I get: 0.0000000000000000 0.5000000000000000 0.5010696649551392 0.5014420151710510 0.0000000000000000 0.5015594363212585 0.5015631318092346 0.0000000000000000 0.0000000000000000 0.5015637874603271 0.5015637874603271 0.5015637874603271 0.0000000000000000 0.5015637874603271 0.0000000000000000 0.5015637874603271 0.5015637874603271 0.5015637874603271 0.5015637874603271 0.0000000000000000 0.5015637874603271 0.5015637874603271 0.5015637874603271 Note that without the zeros there are only 16 lines of proper values. mesh.JPG I tried using a while loop to make sure that the stored velocity is not zero but that always causes Fluent to crash. while(v_f_u[3]==0){ face_t f; Domain *domain; domain=Get_Domain(1); Thread *t = Lookup_Thread(domain, 6); i=0; begin_f_loop(f, t) { v_f_u[i]=F_U(f,t); i++; } end_f_loop(f, t) } |
|
November 25, 2019, 00:40 |
|
#5 |
Member
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10 |
Are you running an unsteady case or steady?
I feel your code is correct, but I would debug the code by printing the location where it prints the values inside each loop for every iteration and check if you are accessing the correct locations. -Abhinand |
|
November 25, 2019, 15:27 |
|
#6 |
New Member
Firas Abdullatif
Join Date: Nov 2019
Posts: 4
Rep Power: 7 |
I am running a transient case. The locations are correct. I ran an execute on demand macro that after a couple of executes prints out the proper values.
I think that I need to parallelize the code to print it in a file while the code is running. I could be wrong so please let when know if you have any experience with that. I got that information from this thread: fluent udf problem: write specific data for every iteration in a file. -Firas. |
|
November 26, 2019, 04:37 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
for input/output: if you run case in parallel you must use parallel version of udf
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
sliding mesh problem in CFX | Saima | CFX | 46 | September 11, 2021 08:38 |
mass flow in is not equal to mass flow out | saii | CFX | 12 | March 19, 2018 06:21 |
Difficulty in calculating angular velocity of Savonius turbine simulation | alfaruk | CFX | 14 | March 17, 2017 07:08 |
Overflow Error in Multiphase Modelling with Two Continuous Fluids | ashtonJ | CFX | 6 | August 11, 2014 15:32 |
error message | cuteapathy | CFX | 14 | March 20, 2012 07:45 |