CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for inflow (http://www.cfd-online.com/Forums/fluent-udf/116871-udf-inflow.html)

OMJT April 26, 2013 15:14

UDF for inflow
 
Hi everyone,

I am having an issue getting fluent to work with a ramped inflow condition. I have a UDF file for a simple ramp written and I have a journal file written but I get back an error everytime saying:

"Primitive Error at Node 1: interpolate_profile_field: thread 24: profile \"\" does not exist."

It is running in 2D and uses parrallel processing. Here are the files:

ramped_inflow.c

Code:

#include "udf.h"

DEFINE_PROFILE(inlet_velocity, thread, position)
{
    real ramp = 0.0;
    real t_ramp = 0.0;
    real u_target = 0.0;
    real u_in = 0.0;

    t_ramp = RP_Get_Real("t_ramp");
    u_target = RP_Get_Real("u_target");

    #if !RP_HOST /* (serial or compute process, i.e. not host process) */
        real x[ND_ND];
        face_t f;
   
        if (CURRENT_TIME <= t_ramp && t_ramp > 0.0)
        {   
                ramp = CURRENT_TIME/t_ramp;
            u_in = ramp * u_target;   
                                     
                    if (u_in == 0.0)
                    {
                        u_in = 0.02;    /* cannot initialise flow if u=0 m/s */
                    }
        }
        else
        {
            ramp = 1.0;
            u_in = ramp * u_target;
        }

        begin_f_loop(f,thread)
        {
            F_CENTROID(x, f, thread);
       
            F_PROFILE(f, thread, position) = u_in;
        }
        end_f_loop(f,thread)

    #endif

}

Here is the journal file:

Code:

; READ MESH
/file rc "F2R2T1a.cas"
;
; COMPILE UDFS
/define ud cf c "libudf" y "ramped_inflow.c" , ,
;
; set target velocity = 2.0 m/s
(rp-var-define 'u_target 1.0 'real #f)
;
; set ramp time = 10 s
(rp-var-define 't_ramp 10 'real #f)
/define ud cf l "libudf"
;
; BOUNDARY CONDITIONS
/define bc vi inlet y y y y "udf" "inlet_velocity::libudf" n 0 y n n 0 y n 1 n 1
;
; INITIALISE
/solve initialize compute-defaults vi inlet y
/solve initialize initialize-flow
;
; SOLVE
/solve dual-time-iterate 30000 40
;
; SAVE CASE AND DATA FILES
/file write-case-data F2R2T1ax.cas y
/file write-case-data F2R2T1ax.dat y
;
/exit yes

All help will be much appreciated!

Thanks,

Matt

blackmask April 29, 2013 22:34

I think that you should attach the running log of fluent while reading the journal file.

I barely know UDF so I am a bit confused when reading your source code. Maybe you could help me with the following two questions?
1. Judge from the macro you used (!RP_HOST), the RP_Get... should be executed by HOST only. So why broadcasting those values to non-host processes is unnecessary?
2. Two floating numbers could be equal (r1 == r2 could be true) but people seldom do this. The more common practice I saw is ( fabs(r1-r2) < some_eps ). So do you have any particular reason for this line of code?
if (u_in == 0.0)


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