|
[Sponsors] |
July 8, 2013, 03:05 |
assign transient random data to inlet face
|
#1 |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
Dear All.
Could you tell me how to import/assign time series of velocity at each node (y-z plane) of inlet face? My transient velocity data is random data so It can't be defined as a profile or function. the velocity is random value in a certain range. I would like to import/assign time series of random data to each node of inlet face in Fluent or CFX. For example, the inlet face has 5 by 5 nodes (vertically 5, lateral 5) and the length of time series is 2,000 (time step =0.05, total time : 10sec). in other words, each node has velocity with 2000 data length. In this case, what am I going to do? Many thanks for your comments on this problem. Last edited by colopolo; July 8, 2013 at 20:45. |
|
July 8, 2013, 05:45 |
|
#3 |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
||
July 8, 2013, 06:11 |
|
#4 |
Senior Member
|
If you have data for each node then you sure could use
Code:
DEFINE_PROFILE Code:
#define NX 5 #define NY 5 #define dx 0.1 #define dy 0.2 #define xbl -1.234 #define ybl -5.678 int find_the_index(real x, real y) { int i, j; i = round( (x-xbl)/dx ); j = round( (y-ybl)/dy ); return (int)i+(int)j*NX; } Code:
real data[NX*NY][2000]; Code:
int it = N_TIME; real x[ND_ND]; face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); if ( it < 2000 ) F_PROFILE(f,t,i) = data[find_the_index(x[0],x[1])][it]; else {} } end_f_loop(f,t) |
|
July 8, 2013, 20:41 |
|
#5 | |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
Quote:
Could you mind if I have more questions? 1. do I use 'fscanf' after defined 'real mydata[NX*NY][2000]? 2. data[find_the_index(x[0],x[1])][it] -> what kind of array type can be read by the above profile? my data type likes this; time , z (lateral)_coord , y(vertical)_coord , data1 , data2 , data3 ....................data 2000 0.01 , 0 , 0.2 , x x x x 0.01 , 0 , 0.4 , x x x x . . . 0.01 , 0 , 1.0 , x x x x 0.01 , 0.1 , 0.2 , x x x x 0.01 , 0.1 , 0.4 , x x x x . . . 0.01 , 0.1 , 1.0 , after all data of all nodes at one time are mapped, the time goes to the next time 0.02 sec. ======================== in this case how to array my data to easy use your code? Sorry to bother you and appreciate you spend time with me. |
||
July 8, 2013, 21:46 |
|
#6 |
Senior Member
|
Something looks like
Code:
#include<stdio.h> #include "udf.h" #define NX 5 #define NY 5 #define NT 2000 float data[NX][NY][NT]; DEFINE_EXECUTE_AFTER_CASE (read_data, libname) { FILE *fp; float tmp; int ix, iy, it; fp = fopen("data", "r"); for (ix = 0; ix < NX; ix++) for (iy = 0; iy < NY; iy++){ it = 3; while(it-- > 0) fscanf(fp, "%f,", &tmp); for (it = 0; it < 10; it ++) fscanf(fp, "%f,", &data[ix][iy][it]); } } int find_ix(real x) { return (int) lround(x/0.1); } int find_iy(real y) { return (int) lround(y/0.2); } DEFINE_PROFILE(u_profile,t,i) { int it = N_TIME; real x[ND_ND]; face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); if ( it < NT ) F_PROFILE(f,t,i) = data[find_ix(x[0])][find_iy(x[1])][it]; else { // do something for time step >= NT } } end_f_loop(f,t) } |
|
July 8, 2013, 21:49 |
|
#7 | |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
Quote:
|
||
July 8, 2013, 22:26 |
|
#8 | |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
Quote:
there is no time column (1st column). actually data 1 is a velocity at time step 0.01, data 2 is a vel. at time step 0.02.. in this case, could you help me please? |
||
July 8, 2013, 22:43 |
|
#9 |
Senior Member
|
Code:
#include<stdio.h> #include "udf.h" #define NX 5 #define NY 5 #define NT 2000 float data[NX][NY]; void data_from_it (int it) { FILE *fp; float tmp; int ix, iy; char filename[200]; sprintf(filename, "data %d", it); fp = fopen(filename, "r"); for (ix = 0; ix < NX; ix++) for (iy = 0; iy < NY; iy++){ it = 2; while(it-- > 0) fscanf(fp, "%f,", &tmp); fscanf(fp, "%f,", &data[ix][iy]); } } int find_ix(real x) { return (int) lround(x/0.1); } int find_iy(real y) { return (int) lround(y/0.2); } DEFINE_PROFILE(u_profile,t,i) { int it = N_TIME; real x[ND_ND]; face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); if ( it < NT ) F_PROFILE(f,t,i) = data[find_ix(x[0])][find_iy(x[1])][it]; else { // value for time step >= 2000 } } end_f_loop(f,t) } |
|
July 8, 2013, 22:51 |
|
#10 | |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
Quote:
|
||
July 9, 2013, 02:36 |
|
#11 | |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
Quote:
Code:
#include<stdio.h> #include "udf.h" #define NY 5 #define NZ 5 #define NT 20 float data[NY][NZ]; void data_from_it (int it) { FILE *fp; float tmp; int iy, iz; char filename[200]; sprintf(filename, "data %d", it); fp = fopen(filename, "r"); for (iy = 0; iy < NY; iy++) for (iz = 0; iz < NZ; iz++){ it = 2; while(it-- > 0) fscanf(fp, "%f,", &tmp); fscanf(fp, "%f,", &data[iz][iy]); } } int find_iz(real z) { return (int) lround(z/0.1); } int find_iy(real y) { return (int) lround(y/0.2); } DEFINE_PROFILE(u_profile,t,i) { int it = N_TIME; real x[ND_ND]; /* this will hold the position vector */ real y,z; face_t f; /* f=all the cell faces on the boundary */ begin_f_loop(f,t) /* t=given boundary zone, defined automatically when the UDF is hooked to inlet boundary begin_f_loop is applied to all the cell faces */ { F_CENTROID(x,f,t); /* if ( it < NT ) */ F_PROFILE(f,t,i) = data[find_iz(x[2])][find_iy(x[1])][it]; /* else { */ // value for time step >= 2000 /* } */ } end_f_loop(f,t) } 1) I got an error when this code was complied. 2) the node coordinates of this code and inlet face of real domain are should be matched? for example, the node distributes by this code are uniform distribution but my mesh of inlet face are non-uniform distribution. in this case, this mapping has no problem? or I should use exactly same coordinate between your code and grid point of inlet face? Sorry for you many questions. I will attached my input file. |
||
July 9, 2013, 03:01 |
|
#12 |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
this file is my input file.
the length of sample data is 10 data with y and z coordinate. |
|
July 9, 2013, 06:00 |
|
#13 |
Senior Member
|
My code above is sketchy because I do not know much details of your grid distribution and/or your input data format. I am a bit frustrated that the description of your input data format changes all the time.
Assume that 1. the y,z coordinates given in "voutu.txt" coincides with the cell centers of the inlet boundary. Otherwise you need to interpolation the data yourself or use profile instead of UDF. 2. your data format is the same as the one given in "voutu.txt". You need to change the NT value (10 here) to the actual number of data points. Code:
#include<stdio.h> #include "udf.h" #define NY 5 #define NZ 5 #define NT 10 float data[NY][NZ][NT]; void data_from_it (int it) { FILE *fp; float tmp; int iy, iz; char filename[200]; sprintf(filename, "voutu.txt"); fp = fopen(filename, "r"); for (iy = 0; iy < NY; iy++) for (iz = 0; iz < NZ; iz++){ it = 2; while(it-- > 0) fscanf(fp, "%f,", &tmp); for (it = 0; it < NT; it++) { fscanf(fp, "%f", &data[iy][iz][it]); } } } int find_iz(real z) { return (int) lround(z/0.25-1); } int find_iy(real y) { return (int) lround(y/2.0+2); } DEFINE_EXECUTE_AFTER_CASE(init_data, libname) { data_from_it(0); } DEFINE_PROFILE(u_profile,t,i) { int it = N_TIME; real x[ND_ND]; /* this will hold the position vector */ real y,z; face_t f; /* f=all the cell faces on the boundary */ begin_f_loop(f,t) /* t=given boundary zone, defined automatically when the UDF is hooked to inlet boundary begin_f_loop is applied to all the cell faces */ { F_CENTROID(x,f,t); if ( it < NT ) F_PROFILE(f,t,i) = data[find_iy(x[1])][find_iz(x[2])][it]; else { } } end_f_loop(f,t) } |
|
July 9, 2013, 20:06 |
|
#14 | |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
Quote:
|
||
July 16, 2013, 22:43 |
|
#15 | |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
Quote:
..\..\src\mapped01.c(14) : warning C4996: 'sprintf'이(가) deprecated C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(345) : 'sprintf' 메시지: 'This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.' ..\..\src\mapped01.c(16) : warning C4996: 'fopen'이(가) deprecated C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(234) : 'fopen' 메시지: 'This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.' ..\..\src\mapped01.c(20) : warning C4996: 'fscanf'이(가) deprecated C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(249) : 'fscanf' 메시지: 'This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.' ..\..\src\mapped01.c(22) : warning C4996: 'fscanf'이(가) deprecated로 선언되었습니다. C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(249) : 'fscanf' 선언을 참조하십시오. 메시지: 'This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.' # Generating udf_names.c because of mapped01.obj So I delete "#include <stdio.h>" then re-compiled it. I got 2nd error - udf_names.c(6) : error C2449: found '{' at file scope (missing function header?) udf_names.c(32) : fatal error C1004: unexpected end-of-file found Could you let me know what is wrong in here? |
||
July 17, 2013, 02:01 |
|
#17 | |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
Quote:
Code:
#include "udf.h" #define NY 5 #define NZ 5 #define NT 10 float data[NY][NZ][NT]; void data_from_it (int it) { FILE *fp; float tmp, data[NY][NZ][NT]; int iy, iz; char filename[200]; sprintf(filename, "voutu10.txt"); fp = fopen(filename, "r"); for (iy = 0; iy < NY; iy++) for (iz = 0; iz < NZ; iz++){ it = 2; while(it-- > 0) fscanf(fp, "%f,", &tmp); for (it = 0; it < NT; it++) { fscanf(fp, "%f", &data[iy][iz][it]); } } } int find_iz(real z) { return (int) lround(z/0.25-1); } int find_iy(real y) { return (int) lround(y/2.0+2); } DEFINE_EXECUTE_AFTER_CASE(init_data, libname) { data_from_it(0); } DEFINE_PROFILE(u_profile,t,i) { int it = N_TIME; real x[ND_ND]; /* this will hold the position vector */ real y,z; face_t f; /* f=all the cell faces on the boundary */ begin_f_loop(f,t) /* t=given boundary zone, defined automatically when the UDF is hooked to inlet boundary begin_f_loop is applied to all the cell faces */ { F_CENTROID(x,f,t); if ( it < NT ) F_PROFILE(f,t,i) = data[find_iy(x[1])][find_iz(x[2])][it]; else { } } end_f_loop(f,t) } udf_names.c file in 3d is upto date. (system "copy "C:\PROGRA~1\ANSYSI~1\v145\fluent"\fluent14.5.0\sr c\makefile_nt.udf "libudf\win64\3d\makefile" ") 1 file is copied. (chdir "libudf")() (chdir "win64\3d")() # Generating ud_io1.h mapped01.c # Generating udf_names.c because of mapped01.obj udf_names.c udf_names.c(6) : error C2449: found '{' at file scope (missing function header?) udf_names.c(20) : fatal error C1004: unexpected end-of-file found |
||
July 24, 2013, 04:49 |
|
#19 |
Member
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15 |
I am sorry for late reply. I was out of office.
Yes. The above error was happend when I compiled your code without "#include<stdio.h>". When I compiled your original code, Copied d:\gambit\2013 cyber wind tunnel test\wt00/D:\Gambit\2013 Cyber Wind Tunnel Test\WT00\mapped00.c to libudf\src Creating user_nt.udf file for 3d ... (system "copy "C:\PROGRA~1\ANSYSI~1\v145\fluent"\fluent14.5.0\sr c\makefile_nt.udf "libudf\win64\3d\makefile" ") 1 file was copied. (chdir "libudf")() (chdir "win64\3d")() # Generating ud_io1.h mapped00.c ..\..\src\mapped00.c(17) : warning C4996: 'sprintf' deprecated C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(345) : 'sprintf' message: 'This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.' ..\..\src\mapped00.c(20) : warning C4996: 'fopen' deprecated. C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(234) : 'fopen' . message: 'This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.' ..\..\src\mapped00.c(24) : warning C4996: 'fscanf' deprecated C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(249) : 'fscanf' message: 'This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.' ..\..\src\mapped00.c(25) : warning C4996: 'fscanf' deprecated. C:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(249) : 'fscanf' message: 'This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.' blackmask00.obj : error LNK2019: lround unresolved external symbol ( find_iz function). blackmask00.obj : error LNK2001: lround unresolved external symbol . libudf.dll : fatal error LNK1120: 1 unresolved external symbol . type Done. Blue is just warning and bold character is error mesage |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create an internal face | aylalisa | OpenFOAM Pre-Processing | 1 | June 19, 2013 13:02 |
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem | Attesz | OpenFOAM Meshing & Mesh Conversion | 12 | May 2, 2013 11:52 |
Inlet profile from 2D velocity and turbulence data | Attesz | OpenFOAM Pre-Processing | 2 | March 11, 2012 07:09 |
Map external data (heat flux in) on solid face | jerry1977 | CFX | 2 | January 31, 2012 14:32 |
Transient Inlet boundary condition - fully develop | Omer | CFX | 3 | November 28, 2006 17:22 |