|
[Sponsors] |
May 22, 2016, 23:51 |
How can I save the all data to txt file?
|
#1 |
New Member
S.J Chung
Join Date: Mar 2015
Posts: 6
Rep Power: 11 |
Hi guys. I always thank you for your help.
I learn lots of info. and techniques for udf. However, I have one problem. I finished calculating cell volumes and centroids. This is my code ===================================== #include "udf.h" DEFINE_ON_DEMAND(demo_calc) { real volume, vol_tot; Domain* domain; Thread* t; cell_t c; real x[ND_ND]; real y, z; vol_tot = 0.; domain = Get_Domain(1); thread_loop_c(t, domain) { begin_c_loop(c, t) { volume = C_VOLUME(c, t); Message("Cell Volume=%g\n", volume); vol_tot += volume; C_CENTROID(x, c, t); y = x[1]; z = x[2]; Message("x_centroid=%g, y_centroid=%g, z_centroid=%g\n", x[0], x[1], x[2]); } end_c_loop(c, t) } Message("Total Volume=%g\n", vol_tot); } ============================================ But, I cannot find method which save these data (each cells volume, centroid coordinates) to txt file. Naturally, it is possible by mouse (copy and paste to notepad) But I want to know how can i automate this result. Waiting your help |
|
May 23, 2016, 04:11 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
From memory:
Code:
#include "udf.h" DEFINE_ON_DEMAND(demo_calc) { real volume, vol_tot; Domain* domain; Thread* t; cell_t c; real x[ND_ND]; real y, z; file *foutput; vol_tot = 0.; domain = Get_Domain(1); foutput = fopen("outputfile.txt",a); thread_loop_c(t, domain) { begin_c_loop(c, t) { volume = C_VOLUME(c, t); fprintf(foutput,"Cell Volume=%g\n", volume); vol_tot += volume; C_CENTROID(x, c, t); y = x[1]; z = x[2]; fprintf(foutput,"x_centroid=%g, y_centroid=%g, z_centroid=%g\n", x[0], x[1], x[2]); } end_c_loop(c, t) } fprintf(foutput,"Total Volume=%g\n", vol_tot); fclose(foutput); } Last edited by pakk; May 23, 2016 at 06:25. |
|
Tags |
.txt, result to txt, text file, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] groovyBC in openFOAM-2.0 for parabolic velocity bc | ofslcm | OpenFOAM Community Contributions | 25 | March 6, 2017 11:03 |
[OpenFOAM.org] Error creating ParaView-4.1.0 OpenFOAM 2.3.0 | tlcoons | OpenFOAM Installation | 13 | April 20, 2016 18:34 |
[swak4Foam] Problem installing swak_2.x for OpenFoam-2.4.0 | towanda | OpenFOAM Community Contributions | 6 | September 5, 2015 22:03 |
[swak4Foam] Error bulding swak4Foam | sfigato | OpenFOAM Community Contributions | 18 | August 22, 2013 13:41 |
[swak4Foam] build problem swak4Foam OF 2.2.0 | mcathela | OpenFOAM Community Contributions | 14 | April 23, 2013 14:59 |