|
[Sponsors] |
August 13, 2020, 19:05 |
UDF Posting Value Twice in File
|
#1 |
New Member
David
Join Date: Aug 2020
Posts: 5
Rep Power: 5 |
Hello everyone,
As said in the title, my UDF is currently outputting the data I want twice into a data file, and I only want it to post it once. For example it would look something like this: Time RPM 0 0 0 0 1 1 1 1 I looked around on different forums, and it seems my problem might be because I need to Parallelize my UDF? I'm a newbie when it comes to writing UDF so I'm confused on the whole Parallelization issue. If anyone knows anything about my output problem, I'd very much appreciate the help. Code:
#include "udf.h" FILE *fp; /* local pointer fp to FILE */ DEFINE_ZONE_MOTION(fmotion,omega,axis,origin,velocity,time,dtime) { time = CURRENT_TIME; if (time < 0.1) { *omega = 2500.0 * time; } else { *omega = 250.0; } N3V_D (velocity,=,0.0,0.0,0.0); N3V_S(origin,=,0.0); /* default values, line could be omitted */ N3V_D(axis,=,0.0,1.0,0.0); /* default values, line could be omitted */ fp = fopen("data.txt","a+"); fprintf(fp,"Time: %f RPM: %f\n",time,*omega); fclose(fp); /* close the file pointed to by fp */ return; } |
|
August 14, 2020, 00:32 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
try this, compile code
Code:
#include "udf.h" FILE *fp; /* local pointer fp to FILE */ DEFINE_ZONE_MOTION(fmotion,omega,axis,origin,velocity,time,dtime) { time = CURRENT_TIME; if (time < 0.1) { *omega = 2500.0 * time; } else { *omega = 250.0; } N3V_D (velocity,=,0.0,0.0,0.0); N3V_S(origin,=,0.0); /* default values, line could be omitted */ N3V_D(axis,=,0.0,1.0,0.0); /* default values, line could be omitted */ #if RP_HOST fp = fopen("data.txt","a+"); fprintf(fp,"Time: %f RPM: %f\n",time,*omega); fclose(fp); /* close the file pointed to by fp */ #endif return; }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 03:30 |
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch | gschaider | OpenFOAM Installation | 225 | August 25, 2015 19:43 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 10:57 |
"parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 11:44 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 17:51 |