CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Access violation error pointer to a file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 8, 2011, 10:18
Default Access violation error pointer to a file
  #1
New Member
 
selim
Join Date: Sep 2009
Location: UK
Posts: 19
Rep Power: 16
salihovic is on a distinguished road
Hallo,


Here is my UDF:


#include "udf.h"
#include "random.h"

DEFINE_CG_MOTION(airfoil, dt, vel, omega, time, dtime)
{

FILE *pf;

real plungeampl, pitchampl, w, pi;

pi = 3.14159265;

/* define motion variables */
plungeampl = 0*0.000254; /* 1-inch plunge amplitude */
pitchampl = 1 * pi / 180; /* 45-degree pitch amplitude */
w = 2 * pi * 25; /* 25 Hz frequency */

/* define airfoil motion */
vel[1] = w * plungeampl * cos(w * time); /* y-component of velocity */
omega[2] = w * pitchampl * rand()/RAND_MAX;/* z-component of angular velocity */
Message("time=%f omega=%f\n",time,omega[2]*180.0/3.1415926) ;

if(NULL == (pf = fopen("bubu.txt","a")))
Error("Could not open file for append!\n");

fprintf(pf,"%e\n",omega[2]);
fclose(pf);
}


My problem is:

When I remove the pointer to the file pf and only use Message it works fine. But I want to store the values on the screen to a file. When I use the above UDF, I got Access violation error.

Any suggestions?

Thanks in advance,
Selim
salihovic is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
tecio compilation errors in latest 1.6.x rsamuel OpenFOAM Bugs 2 June 25, 2021 08:10
c++ libraries and solver compiling vaina74 OpenFOAM Installation 13 February 3, 2012 17:43
[OpenFOAM] ParaView 33 canbt open OpenFoam file hariya03 ParaView 7 September 25, 2008 17:33
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 14:00
PHI file structure Eugene Phoenics 9 November 2, 2001 22:00


All times are GMT -4. The time now is 04:54.