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

UDF Getting data from file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 10, 2009, 09:07
Default UDF Getting data from file
  #1
New Member
 
Jordi
Join Date: Jul 2009
Posts: 3
Rep Power: 17
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


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
I/O of a real value by "DEFINE_RW_FILE" (UDF) Pietro Asinari Fluent UDF and Scheme Programming 1 August 15, 2015 20:08
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM Community Contributions 300 October 29, 2014 19:00
Regarding FoamX running Kindly help out hariya03 OpenFOAM Pre-Processing 0 April 18, 2008 05: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 18:01


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