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

assign transient random data to inlet face

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 8, 2013, 03:05
Default assign transient random data to inlet face
  #1
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
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.
colopolo is offline   Reply With Quote

Old   July 8, 2013, 05:42
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Use profile if you have the time series of the random data. Otherwise use
Code:
DEFINE_PROFILE
UDF macro.
blackmask is offline   Reply With Quote

Old   July 8, 2013, 05:45
Default
  #3
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
Use profile if you have the time series of the random data. Otherwise use
Code:
DEFINE_PROFILE
UDF macro.
Thanks for your comment. I cannot make profile of my random data.
colopolo is offline   Reply With Quote

Old   July 8, 2013, 06:11
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
If you have data for each node then you sure could use
Code:
DEFINE_PROFILE
You need to find the mapping between the random data and the area those data would apply. I assume you could find it some way, e.g., for a uniform spaced mesh you might use something like
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;
}
If you data is stored in an array named
Code:
real data[NX*NY][2000];
you can use
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)
to set the corresponding data for each nodes at given time step.
blackmask is offline   Reply With Quote

Old   July 8, 2013, 20:41
Default
  #5
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
If you have data for each node then you sure could use
Code:
DEFINE_PROFILE
You need to find the mapping between the random data and the area those data would apply. I assume you could find it some way, e.g., for a uniform spaced mesh you might use something like
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;
}
If you data is stored in an array named
Code:
real data[NX*NY][2000];
you can use
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)
to set the corresponding data for each nodes at given time step.
Very thanks!!!
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.
colopolo is offline   Reply With Quote

Old   July 8, 2013, 21:46
Default
  #6
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
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)
}
You might need to modify the above code to suit your needs.
blackmask is offline   Reply With Quote

Old   July 8, 2013, 21:49
Default
  #7
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
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)
}
You might need to modify the above code to suit your needs.
Thank for your kindness.
colopolo is offline   Reply With Quote

Old   July 8, 2013, 22:26
Default
  #8
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
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)
}
You might need to modify the above code to suit your needs.
I am sorry to bother you. I mistake my data type.
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?
colopolo is offline   Reply With Quote

Old   July 8, 2013, 22:43
Default
  #9
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
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)
}
blackmask is offline   Reply With Quote

Old   July 8, 2013, 22:51
Default
  #10
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
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)
}
Thanks again. I owe you a lot.
colopolo is offline   Reply With Quote

Old   July 9, 2013, 02:36
Default
  #11
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
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)
}
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)
}
I changed your code for y-z plane (the dimension of inlet face is 8m (lateral) by 1.5m (vertical).

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.
colopolo is offline   Reply With Quote

Old   July 9, 2013, 03:01
Default
  #12
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
this file is my input file.
the length of sample data is 10 data with y and z coordinate.
Attached Files
File Type: txt voutu.txt (4.7 KB, 11 views)
colopolo is offline   Reply With Quote

Old   July 9, 2013, 06:00
Default
  #13
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
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)
}
blackmask is offline   Reply With Quote

Old   July 9, 2013, 20:06
Default
  #14
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
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)
}
Sorry to bother you and very appreciate you help me !!
colopolo is offline   Reply With Quote

Old   July 16, 2013, 22:43
Default
  #15
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
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)
}
First, I compiled your udf but I got an error.
..\..\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?
colopolo is offline   Reply With Quote

Old   July 16, 2013, 22:55
Default
  #16
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
I saw a lot of warnings but not an error. Would you please help me highlight the error line?
blackmask is offline   Reply With Quote

Old   July 17, 2013, 02:01
Default
  #17
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
I saw a lot of warnings but not an error. Would you please help me highlight the error line?
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)
}
When I compiled the above file, I got an error like the below;

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
colopolo is offline   Reply With Quote

Old   July 18, 2013, 21:21
Default
  #18
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
This is not the code I wrote for you, it it?
blackmask is offline   Reply With Quote

Old   July 24, 2013, 04:49
Default
  #19
Member
 
^^
Join Date: Aug 2011
Posts: 70
Rep Power: 15
colopolo is on a distinguished road
Quote:
Originally Posted by blackmask View Post
This is not the code I wrote for you, it it?
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
colopolo is offline   Reply With Quote

Old   July 24, 2013, 05:26
Default
  #20
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
Add
Code:
#include <math.h>
after
Code:
#include <stdio.h>
blackmask 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
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


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