|
[Sponsors] |
May 19, 2010, 07:38 |
|
#21 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 |
Hi,
I've checked many times that what there is in that journal file is what I want Fluent to pick up... What I'm gonna do is to smash both the .cas and .dat files and start over. I'll even delete the folder where they're located. I haven't run your script because I don't understand the meaning of 13 () no pressure () no I'll let you know where I end up. |
|
May 19, 2010, 08:25 |
|
#22 | |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Quote:
Code:
/file/export The GUI record macro was just a pedagogical exercise. |
||
May 19, 2010, 10:58 |
|
#23 |
Member
Ivan
Join Date: Aug 2009
Posts: 63
Rep Power: 17 |
I know what you mean.
Well it doesn't seem to work either. I've created the journal file attached to this post, following your instructions ad you'll be able to see. However, I keep getting the same error message related to out of malloc memory (see picture attached). On the other hand, just to see if that malloc memory issue could be solved somehow, I'm running a single precision simulation based on the same case and it seems to work. I don't know what else I can do. Do you have idea how many extra iterations per time step I have to run compared to a double precision case? Cheers, Ivan. |
|
May 19, 2010, 12:36 |
|
#24 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
The journal file looks ok, at first glance. Most likely there is something wrong with the case file.
You could ask fluent support for that error. I don't think it matters how many iterations you run in single precision, if both calculations are converged, the double precision should always be more accurate. However, the difference may sometimes be insignificant. |
|
March 8, 2011, 09:28 |
|
#25 |
Member
Join Date: Sep 2009
Posts: 69
Rep Power: 17 |
HI dmoroian
I am having a slightly different problem and I was wondering if you know of any other way around it. I need to monitor approximately 5000 points in my simulation per time step. 1.Surface point monitors do not work as they crash due to too many individual points 2. I tried file/transient-export TUI, this works in my PC. But when I load the simulation into a cluster, it does not give me the option to write it into 'ascii' format. Further investigation points out that Fluent Parallel dosent support transient-export in 'ascii' format. Do you have any idea how else I can monitor so many individual points?? Thanks in advance. |
|
March 9, 2011, 05:13 |
|
#26 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Code:
void mapCell(real *x, cell_t *cell, Thread **thread) { Domain *d = Get_Domain(1); Thread *t; cell_t c; real centroid[ND_ND]; real dist2[ND_ND]; real min = 1.0e6; thread_loop_c(t,d) { begin_c_loop(c,t) { C_CENTROID(centroid,c,t); NV_VV(dist2,=,centroid,-,x); if (min > NV_MAG2(dist2)) { min = NV_MAG2(dist2); *cell = c; *thread = t; } } } } DEFINE_EXECUTE_AT_END(bubu) { static cell_c *mapCells = NULL; static Thread **mapThreads = NULL; static real points[5000][3] = {{0,0,0},{1,1,1}......};/*this is the vector defining the monitoring points*/ int i; char name[100]; if(NULL == (mapCells = (cell_c*)calloc(5000,sizeof(cell_c)))) Error("Could not allocate the memory!\n"); if(NULL == (mapThreads = (Thread**)calloc(5000,sizeof(Thread*)))) Error("Could not allocate the memory!\n"); for(i = 0; i < 5000; i++) { mapCell(points[i], &mapCells[i], &mapThreads[i]); sprintf(name,"m-%05d.out",i); pf = fopen(name,"a"); fprintf(pf,"%f\n",C_T(mapCells[i],mapThreads[i])); fclose(pf); } } Take the above code as it is "just an example". I did not try it, it is not optimized, nor it correctly works in parallel. Basically it finds the corresponding cell for each monitor and prints out the temperature in a separate file. I hope this is helpful! |
|
October 16, 2012, 05:23 |
|
#27 |
New Member
Ian Maes
Join Date: Oct 2011
Posts: 10
Rep Power: 15 |
Hi,
thank you for providing this example here! Can I ask you 2 questions about it? - How do you choose the value of 'min'? 1.0e6 seems like a very big value! - Is it necessary to retreive the cell location and thread (filled in by mapmyCell) every time-step, or could it be possible to do this upon loading? Thank you in advance, Kind regards, Ian |
|
October 16, 2012, 16:44 |
|
#28 | ||
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Quote:
Quote:
|
|||
October 18, 2012, 05:58 |
|
#29 |
New Member
Ian Maes
Join Date: Oct 2011
Posts: 10
Rep Power: 15 |
Hi dmoroian,
Thanks for the answers! This is the code that works, where the coordinates of a line across my domain are read in from xcord.txt. Code:
#include "udf.h" static real points[56][3]; DEFINE_EXECUTE_ON_LOADING(print_line,libname) { int m1, m2, i, j; FILE *fin; m1=56; m2=3; fin=fopen("xcord.txt","r"); for (i=0;i<m1;i++) { for (j=0;j<m2;j++) fscanf(fin,"%lf\n",&points[i][j]); } fclose(fin); Message ("points is loaded!\n"); } void mapCell(real *x, cell_t *cell, Thread **thread) { Domain *d = Get_Domain(1); Thread *t; cell_t c; real centroid[ND_ND]; real dist2[ND_ND]; real min = 1.0e6; thread_loop_c(t,d) { begin_c_loop(c,t) { C_CENTROID(centroid,c,t); NV_VV(dist2,=,centroid,-,x); if (min > NV_MAG2(dist2)) { min = NV_MAG2(dist2); *cell = c; *thread = t; } } end_c_loop(c,t) } } DEFINE_EXECUTE_AT_END(bubi) { static cell_t *mapCells = NULL; static Thread **mapThreads = NULL; int i; FILE *pf; if(NULL == (mapCells = (cell_t*)calloc(56,sizeof(cell_t)))) Error("Could not allocate the memory!\n"); if(NULL == (mapThreads = (Thread**)calloc(56,sizeof(Thread*)))) Error("Could not allocate the memory!\n"); if(NULL == (pf = fopen("Ux.txt","a"))) Error("Could not open file!\n"); for(i = 0; i < 56; i++) { mapCell(points[i], &mapCells[i], &mapThreads[i]); fprintf(pf,"%f\t",C_T(mapCells[i],mapThreads[i])); } fprintf(pf,"\n"); fclose(pf); } Code:
============================================================================== Stack backtrace generated for node id 999999 (pid = 26808) on signal 11 : /opt/Fluent13.0.0/ansys_inc/v130/fluent/fluent13.0.0/lnamd64/3ddp_host/fluent.13.0.0[0x129da24] /opt/Fluent13.0.0/ansys_inc/v130/fluent/fluent13.0.0/lnamd64/3ddp_host/fluent.13.0.0[0x129e7a8] /lib64/libpthread.so.0[0x37ffa0f500] libudf/lnamd64/3ddp_host/libudf.so(bubi+0xcb)[0x7f39bd7a1876] Check the file fluenterror.log for details. Please include this information with any bug report you file on this issue! ============================================================================== Thank you! Ian |
|
October 18, 2012, 09:03 |
|
#30 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Input/Ouput in parallel is not trivial, and certainly doesn't work straight from the serial implementation.
You'll have to look at the Fluent UDF Manual, chapter 7 "Parallel Considerations" for some more details. There is a sample of udf debugging on cfd-online wiki: http://www.cfd-online.com/Wiki/Fluen..._udf_using_gdb |
|
June 29, 2013, 16:14 |
|
#31 | |
New Member
Join Date: Jun 2013
Posts: 7
Rep Power: 13 |
Quote:
I added the -%t for automated data export at each time step, but it seems to export only once filename-0000 and stops. Do I need to include some sort of a loop structure? I am using: Code:
file/export/ascii directory/filename-%t surface () no air-vof () yes Alfred |
||
June 29, 2013, 16:52 |
|
#32 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
I would use the command within "execute-commands" and run it periodically every time-step or every iteration.
|
|
June 29, 2013, 17:44 |
|
#33 | |
New Member
Join Date: Jun 2013
Posts: 7
Rep Power: 13 |
Quote:
Future reference for others. The full syntax is: Code:
/solve/execute-commands/add-edit command-1 1 "time-step" "file/export/ascii directory/filename-%t surface () no parameter () yes" |
||
July 17, 2013, 10:15 |
UDF time step in file name
|
#34 |
Member
Pranab N Jha
Join Date: Nov 2009
Location: Houston, TX
Posts: 86
Rep Power: 17 |
Hello friends,
On a related topic, I have been having trouble with saving files from a UDF every n time steps, while running Fluent in parallel in batch mode. Fluent does not allow me to save files in ascii format in parallel mode, so I chose to go with a UDF instead. I found part of the UDF online and from the Fluent manual and have modified the rest to suit my purpose. Without the time part (between /*** ... ***/) the UDF runs well and gives me the output in desired format. But I want to add a timestep to my filename so that every time step, I have a new file. This does not work. My guess is that the time data is stored somewhere else, while I am trying to get it back from the host. If you can spare a few minutes, it would be of great help. Thanks. Below is the UDF: #include "udf.h" #define FNAME "datafile" #define TSTEP(t) (t % 2) DEFINE_EXECUTE_AT_END(dod_writer) { FILE* fp; #if !RP_HOST int cell_counter = 0, dummy, len; double pressure, cell_center[ND_ND] ; Domain *d; Thread *t; cell_t c; d = Get_Domain(1); /* Get the domain using Fluent utility */ #else /*************************** int cur_ts = RP_Get_Integer("time-step"); char str1[] = "file-"; char str2[] = ".dat"; strcat (str1, cur_ts); strcat (str1, str2); len = strlen(str1); Message("\n 1. current time step = %d, name = %s \n", cur_ts, str1); /* Send time-step and filename to all nodes */ node_to_host_int_1(cur_ts); host_to_node_string(str1,len); /* remember terminating NUL character ***************************************/ #endif #if RP_NODE if(!I_AM_NODE_ZERO_P)PRF_CRECV_INT(myid-1,&dummy,1,myid-1); fp = fopen(filename,(I_AM_NODE_ZERO_P?"w":"a")); #else fp = fopen(filename,"w"); #endif /* for RP_NODE*/ #if !RP_NODE if (fp!=NULL) { Message("\nThe file opened in the working directory \n"); } else { Message("Error in opening file \n"); } #endif /* for !RP_NODE*/ #if RP_NODE fprintf(fp,"cell-number X-cord Y-cord Z-cord Pressure"); #endif #if !RP_HOST thread_loop_c(t,d) { /*Message0("starting the loopn");*/ begin_c_loop_int(c,t) { cell_counter++; C_CENTROID(cell_center,c,t); pressure=C_P(c,t); #if RP_2D fprintf(fp,"n %d %10.3e %10.3e %10.3e",cell_counter, cell_center[0], cell_center[1], pressure); #else fprintf(fp,"n %d %10.3e %10.3e %10.3e %10.3e",cell_counter, cell_center[0], cell_center[1], cell_center[2], pressure); #endif } end_c_loop_int(c,t) } #endif /* for !RP_HOST*/ #if RP_NODE fclose(fp); if(!I_AM_NODE_LAST_P)PRF_CSEND_INT(myid+1,&dummy,1 ,myid); #else fclose(fp); Message("\n The loop ends\n"); #endif /* for RP_NODE*/ } |
|
July 17, 2013, 15:03 |
Stack overflow
|
#35 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
This is a classical example of stack overflow programming error:
Code:
char str1[] = "file-"; char str2[] = ".dat"; strcat (str1, cur_ts); strcat (str1, str2); To solve the problem, just allocate enough memory in str1: Code:
char str1[200]; sprintf(str1,"file-%d.dat",cur_ts); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 21:02 |
UDF Getting data from file | jreig | FLUENT | 0 | July 10, 2009 09:07 |
Smallest binary file format to save large data | Zonexo | Main CFD Forum | 2 | June 2, 2008 21:25 |
[blockMesh] Axisymmetrical mesh | Rasmus Gjesing (Gjesing) | OpenFOAM Meshing & Mesh Conversion | 10 | April 2, 2007 15:00 |
UDF (write a data file) problem | lichun Dong | FLUENT | 2 | July 29, 2005 12:39 |