|
[Sponsors] |
map outlet boundary profile as an inlet condition using UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 18, 2014, 20:21 |
map outlet boundary profile as an inlet condition using UDF
|
#1 |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
Hello to all
I have a channel with arbitrary cross section and I need a fully developed velocity profile for the inlet. I know that I can use write/read profile options in fluent, however I need to manipulate data as I need to know u/u_mean ratio for the cross section in fully developed condition. Then I use the calculated ratio for the real transient boundary condition in my UDF. So I have created a straight channel with the same cross section. Then I have used write profile option for velocity magnitude at the outlet. After that, I have manually calculated velocity ratio. I have two different input file: 1) mean transient velocity magnitude 2) velocity ratio At the end, I need to apply transient fully developed velocity profile for the inlet. Here is the code: Code:
#include "udf.h" int size = 0; real radius = 0.0; float u_mean[1201]; float *u_ratio; DEFINE_ON_DEMAND(readUmean) { #if !RP_HOST int i = 0; FILE *fp_read; for (i=0;i<1201;i++) { u_mean[i] = 0.0; } fp_read = fopen("mean_velocity.txt","r"); if (fp_read!=NULL) { Message("\nReading file"); for (i=0;i<1201;i++) { fscanf(fp_read, "%f\n", &u_mean[i]); } Message("\nEnd of Reading file"); Message("\n"); } else { Message("\nError opening file"); Message("\n"); exit(EXIT_FAILURE); } fclose(fp_read); Message("First mean velocity: %.9f", u_mean[0]); Message("\n"); #endif } DEFINE_ON_DEMAND(readUratio) { #if !RP_HOST int j = 0; FILE *fp; Domain *d; Thread *t; d = Get_Domain(1); t = Lookup_Thread(d,11); size = THREAD_N_ELEMENTS_INT(t); u_ratio = (float *)malloc(size * sizeof(float)); for (j=0;j<size;j++) { u_ratio[j] = 0.0; } fp = fopen("outlet_velocity_ratio.txt","r"); if (fp!=NULL) { Message("\nReading file"); for (j=0;j<size;j++) { fscanf(fp, "%f\n", &u_ratio[j]); } Message("\nEnd of Reading file"); Message("\n"); } else { Message("\nError opening file"); Message("\n"); exit(EXIT_FAILURE); } fclose(fp); Message("First ratio: %.9f", u_ratio[0]); Message("\n"); #endif } DEFINE_PROFILE(z_velocity_unsteady,thread_unsteady,index_unsteady) { #if !RP_HOST real current_time; real steady_offset; int counter; face_t f_unsteady; steady_offset = 4.0; //steady-state time current_time = CURRENT_TIME; counter = (current_time - steady_offset) / CURRENT_TIMESTEP; begin_f_loop(f_unsteady,thread_unsteady) { F_PROFILE(f_unsteady,thread_unsteady,index_unsteady) = u_mean[counter]*u_ratio[f_unsteady]; } end_f_loop(f_unsteady,thread_unsteady) #endif } DEFINE_PROFILE(z_velocity_steady,thread_steady,index_steady) { #if !RP_HOST face_t f_steady; begin_f_loop(f_steady,thread_steady) { F_PROFILE(f_steady,thread_steady,index_steady) = u_mean[0]*u_ratio[f_steady]; } end_f_loop(f_steady,thread_steady) #endif } I know the problem is here, when I use f_steady for the array index which means the written data and current face indexing is inconsistent: Code:
F_PROFILE(f_steady,thread_steady,index_steady) = u_mean[0]*u_ratio[f_steady]; |
|
December 19, 2014, 04:34 |
|
#2 |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
To further illustrate the problem, I want to know whether it is possible to do the following in a udf:
1) I have a file containing x,y,z and velocity magnitude for the outlet of a straight tube. 2) I want to map this velocity at the inlet of another case using a UDF ( I know I can read the profile using fluent itself but I need to do the same thing in my UDF) |
|
June 20, 2016, 12:53 |
|
#3 |
New Member
Join Date: May 2012
Posts: 2
Rep Power: 0 |
Hi,
have you achieved any success? If yes, I would highly appreciate if you could explain your final workflow. Thanks in advance! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem with assigned inlet velocity profile as a boundary condition | Ozgur_ | FLUENT | 5 | August 25, 2015 05:58 |
Time dependant pressure boundary condition | yosuke1984 | OpenFOAM Verification & Validation | 3 | May 6, 2015 07:16 |
Pressure Inlet Boundary Condition Profile | arapha | FLUENT | 0 | April 4, 2011 17:23 |
Inlet and outlet boundary condition | David Baker | FLUENT | 3 | June 22, 2005 01:42 |
what the result is negatif pressure at inlet | chong chee nan | FLUENT | 0 | December 29, 2001 06:13 |