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

problem with reading data from txt file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 18, 2024, 09:04
Default problem with reading data from txt file
  #1
New Member
 
amina
Join Date: Feb 2020
Posts: 9
Rep Power: 6
aminalaouti is on a distinguished road
hi everyone ,

I want to know if my data file (containing 20,000 values) is being read by the udf. To do this, I've created a small program that reads the data from the data.txt file and prints it to another file (data1.txt).
My program compiles well, the library is created and I've hooked my udf to execute on demand.
The data.txt file contains 4 values:
0.2
0.2
0.1
0.1
results on file data1.txt are :
0.000 0.000 0.000 0.000

????????? where is the problem????

this is my udf:

#include "udf.h"
double coef[4];


DEFINE_ON_DEMAND(lire)
{

FILE* rfile;
FILE* rfile1;

rfile = fopen("C:\\Codes\\data.txt", "r");
rfile1 = fopen("C:\\Codes\\data1.txt", "w");
int i;
i = 0;
for (i = 0; i <4; i++)
{
fscanf(rfile, "%f", &coef[i]);
fprintf(rfile1, "%f", coef[i]);
}
fclose(rfile);
fclose(rfile1);
}
aminalaouti 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
Custom Thermophysical Properties wsmith02 OpenFOAM 4 June 1, 2023 15:30
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 07:42
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 keepfit ParaView 60 September 18, 2013 04:23
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 14:59
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 11:23


All times are GMT -4. The time now is 15:07.