|
[Sponsors] |
February 10, 2021, 10:00 |
udf not working properly
|
#1 |
New Member
Ravichandra
Join Date: Dec 2020
Posts: 2
Rep Power: 0 |
i have a domain for which i need to find co-ordinates of maximum stream function at all flow time values. for this i wrote a code as follows. but it worked fine for on time piston travel of my domain but for off time (i.e., after the end of piston movement the flow continues) the udf is giving same output values for all the flow time intervals. i have been working on this for a month can any one please tell me where i was wrong. the code is as follows
Code:
#include "udf.h" #include "metric.h" #include "mem.h" #include <math.h> #define ID 12 /* Zone ID (in boundary condition panel) on which node data is to be obtained */ char *what = "stream-function"; /* field variable name for which data is to be extracted */ char *what1 = "q-criterion"; /* field variable name for which data is to be extracted */ char *what2= "vorticity-mag"; /* field variable name for which data is to be extracted */ DEFINE_ON_DEMAND(on_demand_calc_stream_fun_node) { Domain *d; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */ FILE *fp; real tem,tmax=0.; real x, y,x1,y1; real z[ND_ND]; int n; real flow_time=CURRENT_TIME; Thread *t; cell_t c; Node *v; d = Get_Domain(1); /* Get the domain using ANSYS Fluent utility */ t=Lookup_Thread(d,ID); Node_Function_Values(d, what); /* Initalize all node marks on the thread == 0 */ begin_c_loop(c, t) { c_node_loop(c, t, n) { v=C_NODE(c,t,n); NODE_MARK(v) = 0; } } end_c_loop(c, t); /* Loop over the nodes and get the data */ begin_c_loop(c, t) { c_node_loop(c, t, n) { v = C_NODE(c,t,n); x = NODE_X(v); y = NODE_Y(v); if(NODE_MARK(v) == 0) /* if not already visited */ { C_CENTROID(z,c,t); if ((z[0]<=0.17967881) && (z[1]<=0.042617384)) { tem=NODE_VALUE(v); if (tem > tmax) { tmax = tem; x1=x; y1=y; } } NODE_MARK(v) = 1; } } } end_c_loop(f, t); fp = fopen("c_1_stream_fun_max_node.dat","a"); fprintf(fp,"stream_fun_max_node = %g\t x= %g\t y= %g\t flow_time = %g\n",tmax,x1,y1,flow_time); fclose(fp); } |
|
June 19, 2022, 10:24 |
field variable name
|
#2 |
New Member
Henry
Join Date: Mar 2015
Location: Manchester
Posts: 10
Rep Power: 11 |
Hiya, just saw your post, not sure if you have figured the issue out. My case is that I am modelling a multi phase simulation and I would like to export the temperature value of some certain nodes. I noticed that you defined three field variables (what, what1, and what2). How do you obtain the name of your field variables. Many thanks.
|
|
Tags |
c_loop, fluent, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Pressure UDF not working as intended | miguwhynot | FLUENT | 5 | August 29, 2018 04:22 |
Adding temperature in icoFoam. Not working properly! | mgab | OpenFOAM Programming & Development | 4 | December 19, 2016 07:38 |
UDF For Electrical Conductivity Not working | rage | Fluent UDF and Scheme Programming | 2 | December 9, 2016 10:03 |
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF | acasas | CFD Freelancers | 1 | January 23, 2015 08:26 |
Sample utility not working properly | titio | OpenFOAM | 2 | June 9, 2010 11:45 |