|
[Sponsors] |
Access Flow variables at an arbitrary location using UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 11, 2019, 08:34 |
Access Flow variables at an arbitrary location using UDF
|
#1 |
Member
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10 |
Hello All,
I need to get the flow quantities inside a rectangular 2d (100mmx50mm) domain at a distance of 50mm from inlet. I have two case files One without splitting the domain at the location I need and the other with an interior boundary at the location I need so that I get to access a thread ID from Fluent. However I get this mysterious error from Fluent where I can't get to access the values inside the domain. I would really appreciate your help. Thanks Please find attached code: CODE: This code is attached to a domain without any explicit interior lines. I search for a location I need inside the domain. The next code has an explicit thread defined,coz I created the case by splitting the domain at the position I need. I also made sure I added user defined memory locations before I interpreted this udf DEFINE_ADJUST(adjcell,d) { face_t f; Thread *th, *r_thread; real FC[2]; int ctr,ctr1,n_faces; cell_t c; d = Get_Domain(1); th = Lookup_Thread(d,3); c = F_C0(f,th); ctr=0; ctr1=0; r_thread = Lookup_Thread(d,ID_rplane); n_faces = THREAD_N_ELEMENTS_INT(r_thread); begin_c_loop(c,th) { C_CENTROID(FC,c,th); if(FC[0]>51.512e-3&&FC[0]<51.516e-3) { if(ctr<5) { printf("Xcoor %f Ycoor %f\n",FC[0],FC[1]); *** printf("Uvel is %f\n",C_U(c,th)); *** C_UDMI(c,th,0) = C_U(c,th); } ctr++; } } end_c_loop(c,th) printf("No of faces in outlet %d\n",n_faces); printf("No of faces in recycle plane is %d\n",ctr); } CODE2: This code is hooked to a case where, I have a BC condition of a line inside the domain (50mm from inlet) set to Interior DEFINE_ADJUST(adjface,d) { face_t f; Thread *th, *r_thread; real FC[2]; int ctr,ctr1,n_faces; cell_t c; d = Get_Domain(1); th = Lookup_Thread(d,12); c = F_C0(f,th); ctr=0; ctr1=0; r_thread = Lookup_Thread(d,15); n_faces = THREAD_N_ELEMENTS_INT(r_thread); begin_f_loop(f,th) { F_CENTROID(FC,f,th); if(ctr<5) { printf("Xcoor %f Ycoor %f\n",FC[0],FC[1]); *** printf("Uvel is %f\n",F_U(f,th)); *** printf("Uvel cell is %f\n",C_U(c,th)); } ctr++; } end_f_loop(f,th) printf("No of faces in outlet %d\n",n_faces); printf("No of faces in recycle plane is %d\n",ctr); } OUTPUT: 1. When I do not include the *** statements Xcoor 0.051515 Ycoor 0.000002 Xcoor 0.051515 Ycoor 0.000008 Xcoor 0.051515 Ycoor 0.000013 Xcoor 0.051515 Ycoor 0.000018 Xcoor 0.051515 Ycoor 0.000024 No of faces in outlet 140 No of faces in recycle plane is 140 2. When I include the *** statements ================================================== ============================ Node 0: Process 18176: Received signal SIGSEGV. ================================================== ============================ MPI Application rank 0 exited before MPI_Finalize() with status 2 The fluent process could not be started. Please tell me what is going wrong with this error. I just cant find a way to access the flow variables at a location i need inside the domain. I can however access the values at the inlet and outlet though. |
|
November 12, 2019, 08:05 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
And what happens if you only include the first *** lines, where you print?
|
|
November 12, 2019, 19:17 |
|
#3 | |
Member
Joshua
Join Date: Aug 2014
Posts: 49
Rep Power: 12 |
Quote:
Insert a plane and select the 'Bounded Surface' option. You provide Fluent with the (x,y,z) coordinates of three points that define a rectangle. Figure out the coordinates that define your rectangle and you are good to go. You can then select that surface to do all the normal reporting stuff with. No need for a UDF or to split the domain. Additionally, you can split the domain and label the face you want with a named selection (ex 'interior-my-face') and use that instead. |
||
November 13, 2019, 00:02 |
|
#4 | |
Member
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10 |
Quote:
If I include any of the *** lines in my code I get the error which I mentioned above. Only if I remove those lines(essentially I'm not able to print the values inside the domain). However I'm able to print the values of Coordinates in that domain. Nothing other than that. If I change the thread to either of outlet or inlet plane I'm able to print all the variables. It just wouldn't work only for any other region/thread inside the domain. Please let me know if you have some ideas to circumvent this |
||
November 13, 2019, 00:03 |
|
#5 | |
Member
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10 |
Quote:
This is the usual way to just get the values at any location by creating a line/rake. However I need to do this over and over for Every iteration and do some calculations based on those values and solve the NS eqns accordingly. |
||
November 13, 2019, 04:10 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Do you do this in a simulation that has already a solution, or a simulation that is not initialized yet? I can understand that you would get this error when you initialize, but you did not mention anything about initializing.
|
|
November 13, 2019, 12:35 |
|
#7 |
Member
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10 |
I am not using this during initialization. I read a data file and then hook the udf and then start my calculations again
|
|
November 13, 2019, 16:37 |
|
#8 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I just noticed that you talk about 'interpreting'. Don't do that. Compile it.
(Even if it does not solve your current problem, it will help you in the future.) Otherwise, I have no idea. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Extracting flow variables inside domain in UDF | Abhinand | Fluent UDF and Scheme Programming | 8 | November 20, 2019 15:42 |
How could I access drag term in multiphase flow using UDF | Jay Yin | Fluent UDF and Scheme Programming | 0 | October 23, 2016 23:10 |
Multiphase flow - incorrect velocity on inlet | Mike_Tom | CFX | 6 | September 29, 2016 02:27 |
UDF profile based on function of flow time ERROR! | Ash Kot | Fluent UDF and Scheme Programming | 1 | September 2, 2016 10:35 |
UDF to calculate phase-averaged turbulence variables in a periodic flow | ShuangqingXu | Fluent UDF and Scheme Programming | 0 | October 27, 2011 00:48 |