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

UDF Getting data from file

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   July 10, 2009, 08:07
Default UDF Getting data from file
  #1
New Member
 
Jordi
Join Date: Jul 2009
Posts: 3
Rep Power: 8
jreig is on a distinguished road
Hi everybody!!


I am trying to get some data from an input file to use it as an Energy source.

When interpreting the udf appears this message:

Error:
FLUENT received fatal signal (ACCESS_VIOLATION)

The error comes when trying to close the file, or to scan the file to get the data. If I comment the lines "fscanf" and "fclose" no error message appears.

Maybe the error is caused by a wrong oppening of the file.

Here is the code:


**************************

#include "udf.h"


DEFINE_SOURCE(source,c,t)
{
real xc[ND_ND];
real q;
FILE *fp;
float data[108];
int i;
i=0;
fp = fopen("out.txt","r");

while (i<108){
fscanf(fp,"%f",&data[i]);
i++;
}

fclose(fp);

C_CENTROID(xc,c,t);
if (xc[0]>0.5)
q=10000;
else
q=0;
return q;
}

**************************


Can anyone help me please??
jreig is offline   Reply With Quote

Reply

Tags
file, source, udf

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM 300 October 29, 2014 19:00
Regarding FoamX running Kindly help out hariya03 OpenFOAM Pre-Processing 0 April 18, 2008 04:26
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51
how to handel transient data with less file space steven CFX 2 October 27, 2006 17:01
I/O of a real value by "DEFINE_RW_FILE" (UDF) Pietro Asinari FLUENT 0 October 18, 2003 05:05


All times are GMT -4. The time now is 00:58.