|
[Sponsors] |
December 14, 2017, 09:14 |
UDF to locate coordinates of least pressure
|
#1 |
New Member
Join Date: Dec 2017
Posts: 11
Rep Power: 9 |
Dear all,
I am working with swirl flow confined in a cylinder. The center of rotating inner vortex undergoes displacement with time. I wrote a UDF to run with fluent 16.2. Basically, I need the coordinates of the points with least pressure on a plane with time. Though I am getting the values of least pressure on that plane, yet I am unable to extract the coordinates - in my case it is x-y plane with z direction coinciding with the axis of cylinder. My programming skills are not good enough. I am sharing to what I have been able to do so far. #include "udf.h" #include "mem.h" #include "metric.h" DEFINE_ADJUST(least_pressure,d) { face_t f; Thread *t; real x[ND_ND]; float pressure; int zone_ID; float coordinate[ND_ND]; float least_press = 10000; FILE *fp; thread_loop_f(t,d) { zone_ID = THREAD_ID(t); if(zone_ID == 7) { begin_f_loop(f,t) { pressure = F_P(f,t); if(pressure<least_press) { F_CENTROID(x,f,t); NV_V(coordinate, =, x); least_press = pressure; } end_f_loop(f,t) } fp = fopen("pressure_writer.txt","a"); fprintf(fp,"%f* ",coordinate); fprintf(fp," %f\n",least_press); fclose(fp); } } } Could anyone simply point out where am I going wrong? This I ran in serial mode as I have least idea of programming for parallel processing. Regards, Kukka |
|
December 14, 2017, 21:27 |
|
#2 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Quote:
try this code Code:
#include "udf.h" #include "mem.h" #include "metric.h" DEFINE_ADJUST(least_pressure,d) { face_t f; Thread *t; real x[ND_ND]; float pressure; int zone_ID; real coordinate; float least_press = 10000; FILE *fp; thread_loop_f(t,d) { zone_ID = THREAD_ID(t); if(zone_ID == 7) { begin_f_loop(f,t) { pressure = F_P(f,t); if(pressure<least_press) { F_CENTROID(x,f,t); coordinate = x[0]; least_press = pressure; } end_f_loop(f,t) } fp = fopen("pressure_writer.txt","a"); fprintf(fp,"%f* ",coordinate); fprintf(fp," %f\n",least_press); fclose(fp); } } } |
||
December 15, 2017, 04:04 |
|
#3 |
New Member
Join Date: Dec 2017
Posts: 11
Rep Power: 9 |
Dear AlexanderZ,
Thanks a lot for your reply and support. It worked for me and I have started getting the x-coordinate values for minimum pressure. Now I would try getting both x- and y-coordinates, simultaneously, and I hope it would just be the same as for X. The planes which it recognizes are the boundaries and not the planes which we create manually inside the solver (FLUENT). So as a trial, I monitored at outlet boundary to generate this data. Do I need to go with cell marking to generate a boundary at my desired location (which would be, of course, inside the fluid domain) where actually I will be monitoring? Any idea on this? I look forward to hearing from you. Best Regards, Kukka |
|
December 15, 2017, 07:48 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
x-axis is x[0]
y-axis is x[1] Code:
y_coordinate = x[1]; If you need to get values from your domain across y-axis, for instance y=0, you may make a loop over all faces(for 2D), and monitor if x[1] == 0, than you save pressure (or whatever you want) I hope you got my idea. Best regards |
|
December 15, 2017, 09:43 |
|
#5 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You do everything right, except for printing the answer. You do that by:
Code:
fprintf(fp,"%f* ",coordinate); Instead, what you can do: Code:
fprintf(fp,"(%f,%f,%f) ",coordinate[0],coordinate[1],coordinate[2]); ==Edit: I was responding to the original question, did not see that there was already an answer== |
|
December 17, 2017, 08:51 |
|
#6 |
New Member
Join Date: Dec 2017
Posts: 11
Rep Power: 9 |
Dear AlexanderZ,
Thank you for your extended support. I would return to my institute on Tuesday and give it a try. I hope now it should work well :-) Best Regards, Kukka |
|
December 17, 2017, 08:53 |
|
#7 |
New Member
Join Date: Dec 2017
Posts: 11
Rep Power: 9 |
Dear Pakk,
Many thanks for your suggestions :-) I will run this code and incorporate your suggestions as well. Best Regards, Kukka |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF to adjust pressure outlet | a.lynchy | FLUENT | 4 | February 15, 2021 01:50 |
how to put udf inlet velocity and udf outlet pressure in fluent | raminostadi | Fluent UDF and Scheme Programming | 4 | July 3, 2017 07:43 |
CFX Solver stopped with error when requested for backup during solver running | Mfaizan | CFX | 40 | May 13, 2016 07:50 |
Setting up the pressure variation due to tornado in a duct(UDF)+animation | guillaume1990 | FLUENT | 0 | March 3, 2014 12:59 |
Neumann pressure BC and velocity field | Antech | Main CFD Forum | 0 | April 25, 2006 03:15 |