|
[Sponsors] |
December 1, 2014, 16:18 |
UDF to read and file flow variables
|
#1 |
New Member
Pramode Das K
Join Date: Dec 2014
Posts: 1
Rep Power: 0 |
Dear friends
I wish to do the following in Fluent. 1) A certain region of the mesh (called pod_plane) is to be marked out in the geometry/mesh 2)After every 1 sec,say, I wish to write down the flow variables (u and v) in the pod_plane to a file 'pod_file_%f', where %f is the current time value. This means that my file will have rows equal to the number of cells in the pod_plane (say, 20000)and 4 cloumns corrosponding to x, y, u, and v (x and y: cell centroid). In other words, after 10 seconds I will have 10 files of size 20000X4 each. Accordingly, I have done the following: 1)Created a new zone in the mesh called pod_plane(zoneID = 11). 2) Wrote a UDF to extract the relevant variables at the end of every one second and write them down to files with names as mentioned above. The UDF is attached for your kind perusal. However I face the following problem: Simulation runs smoothly for the 1st one second after which and before writing the file at the end of it, Fluent shows the error for Segmentation Violation and stops the simulation and generates an empty file. I tried to remedy this by changing the User Defined Memory to higher values and modifications of the UDF etc, but to no avail. Also, due to some strange reason, it disregards the if-loop but executes commands within the loop without looping. I tried changing the if-loop to while, but still the problem persists. I am sure the problem is with the UDF. Can anyone please help me? Thanks in advance and regards Given below is my UDF: #include "udf.h" #include "dynamesh_tools.h" #include "stdio.h" /*for input output*/ static int zoneID = 11; /*plane for pod_data*/ DEFINE_EXECUTE_AT_END(Calculation_function) { Domain *d = Get_Domain(1); Thread *t_pod = Lookup_Thread(d,zoneID); cell_t c_pod; face_t f_pod; real time_val = RP_Get_Real("flow-time"); real time_step = RP_Get_Real("physical-time-step"); real x, y, u, v, X[ND_ND], time_previous = time_val; char buffer[32]; FILE *fp; if (time_val==time_previous) { snprintf(buffer, 32, "pod_file_%3.2f", time_val); fp = fopen(buffer,"w"); begin_c_loop(c_pod,t_pod) { C_CENTROID(X, c_pod, t_pod); ND_SET(x, y, v, X[0], X[1], C_V(c_pod, t_pod)); u = C_U(c_pod, t_pod); fprintf (fp, "%lf\t %lf\t %lf\t %lf\n", x, y, u, v); } end_c_loop(c_pod,t_pod) fclose(fp); time_previous=time_previous+1.000000; } } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to calculate mass flow rate on patches and summation of that during the run? | immortality | OpenFOAM Post-Processing | 104 | February 16, 2021 09:46 |
[swak4Foam] swak4foam building problem | GGerber | OpenFOAM Community Contributions | 54 | April 24, 2015 17:02 |
How to setup a simple OpenFOAM cluster? | TommiPLaiho | OpenFOAM Installation | 3 | October 27, 2013 16:15 |
parallel code | samiam1000 | SU2 | 3 | March 25, 2013 05:55 |
PHI file structure | Eugene | Phoenics | 9 | November 2, 2001 23:00 |