|
[Sponsors] |
UDF for reading velocity values and adding random perturbation |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 2, 2016, 01:46 |
UDF for reading velocity values and adding random perturbation
|
#1 |
New Member
Join Date: Jun 2015
Location: Australia
Posts: 15
Rep Power: 11 |
Hi,
I have a pipe whose inlet has 3312 elements. Inlet velocity at each cell is different than the others so that I have all those velocities. I would like to write a udf which reads all the velocity inlet data given in a text file, with 1 column and 3312 rows, and add them to random numbers generated by a wave equation, available in the same udf. Note that the random number generated by the wave equation varies as time elapses so at different time steps the code adds different numbers to the velocity inlet profile values. Then, the code takes the 3312 new velocities as new inlet velocities for the corresponding cells. The code can be interpreted and works without any errors. However, I realised that, it is malfunctioning. I guess the problem is that it does not read the 3312 initial inlet profile values or does not add them with the value computed by the wave equation so that the velocity at the inlet is just a small value generated by the wave equation. Here is my Code: #include "udf.h" double Velocity[3312]; FILE *fp; DEFINE_INIT(read_data, d) { int i; fp=fopen("velocit.txt","r"); for (i=1;i<3312;i++) { fscanf(fp,"%ld", &Velocity[i]); } fclose(fp); } DEFINE_PROFILE(temporal_wave, thread, position) { real coord[ND_ND]; real x; face_t f; real t = CURRENT_TIME; int i = t; begin_f_loop(f, thread) { F_CENTROID(coord,f,thread); x=coord[1]; F_PROFILE(f, thread, position) = Velocity[i] + 0.003*sin(500.*t); } end_f_loop(f, thread) } Could you please have look at my code and let me know where the potential error(s) is coming from. Regards Joe |
|
Tags |
perturbation, reading text file, udf, variable velocity |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How I can introduce my power heat (W) in chtMultiRegionFoam? | aminem | OpenFOAM Pre-Processing | 32 | August 29, 2019 03:23 |
adding values to transportProperties in interFoam | dgadensg | OpenFOAM Programming & Development | 15 | April 16, 2019 09:29 |
using chemkin | JMDag2004 | OpenFOAM Pre-Processing | 2 | March 8, 2016 23:38 |
ATTENTION! Reliability problems in CFX 5.7 | Joseph | CFX | 14 | April 20, 2010 16:45 |
Adding all the values in a post register | Cb | Siemens | 3 | March 11, 2005 14:40 |