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

UDF for inflow

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 26, 2013, 15:14
Default UDF for inflow
  #1
New Member
 
Join Date: Jan 2013
Posts: 10
Rep Power: 13
OMJT is on a distinguished road
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

Last edited by OMJT; April 26, 2013 at 16:57.
OMJT is offline   Reply With Quote

Old   April 29, 2013, 22:34
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 21
blackmask will become famous soon enough
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)
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
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 06:12
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


All times are GMT -4. The time now is 01:47.