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

Question about UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 17, 2006, 16:49
Default Question about UDF
  #1
summer
Guest
 
Posts: n/a
Hello, everyone. Now I am writing a UDF to define the source term in UDS. I have the unsteady term defined as follows: DEFINE_UDS_UNSTEADY(uns_time,c,mix_thread,i,apu,su ) { cell_t c; Thread *mix_thread; real physical_dt; int i=0;

/*find the threads for the gas-bubble(secondary phase)*/ thread_g=THREAD_SUB_THREAD(mix_thread,s_col); /*secondary phase*/

void_g=C_VOF(c,thread_g); /*gas volume fraction*/

physical_dt=RP_Get_Real("physical-time-step");

*apu=-1/3*void_g/physical_dt; /*implicit part*/ phi_old=C_STORAGE_R(c,thread_g,SV_VOF_M1(i)); *su=1/3*phi_old/physical_dt; /*explicit part*/ } And then I want to use it in another macro called DEFINE_SOURCE in the same c file. Could I use apu and su directly? Need I use the User-defined Memory to store them first? Thanks in advance.
  Reply With Quote

Old   July 18, 2006, 11:13
Default Re: Question about UDF
  #2
greg
Guest
 
Posts: n/a
i don`t know udf`s well but as I remember (u can chack it everything in UDF User guide) you should use user defined memory for such thing. I attached a udf example. Meybe it will help you

#include "udf.h" static real spark_center[ND_ND]={20e-3, 1e-3}; static int fluid_chamber_ID = 2;

DEFINE_ADJUST(adjust, domain) { real vol, xc[ND_ND], dis[ND_ND], radius; cell_t c; Thread * tc; tc = Lookup_Thread(domain, fluid_chamber_ID); radius = RP_Get_Real("spark/radius"); vol = 0; begin_c_loop_int (c, tc) { C_CENTROID(xc, c, tc); NV_VV(dis, =, xc, -, spark_center); if (NV_MAG(dis) < radius) { vol += C_VOLUME(c, tc); } } end_c_loop_int (c, tc) vol = PRF_GRSUM1(vol); begin_c_loop_int (c, tc)

{

/****** THIS IS A PART U NEED I THINK******/

C_UDMI(c, tc, 1) = vol; } end_c_loop_int (c, tc) return; } DEFINE_SOURCE(energy_source, c, t, dS, eqn) { #if !RP_HOST real xc[ND_ND], dis[ND_ND]; real source, radius, vol, CA, rpm, start_CA; rpm = RP_Get_Real("dynamesh/in-cyn/crank-rpm"); start_CA = RP_Get_Real("spark/start-ca"); CA = rpm*CURRENT_TIME*6+RP_Get_Real("dynamesh/in-cyn/crank-start-angle"); if(CA>=start_CA&&CA<(start_CA+RP_Get_Real("spark/duration")*rpm*6)) { radius = RP_Get_Real("spark/radius");

/******* AND AGAIN WHAT U WANT **********/

vol = C_UDMI(c, t, 1); C_CENTROID(xc, c, t); NV_VV(dis, =, xc, -, spark_center); if (NV_MAG(dis) < radius) { source = RP_Get_Real("spark/energy")/RP_Get_Real("spark/duration")/vol; return source; } else { return 0; } } else { return 0; } #endif }

GOOD LUCK!!!!
  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
A simple UDF question Pirooz Darabi FLUENT 0 October 31, 2007 16:22
Yet another UDF question. Bee FLUENT 0 October 9, 2006 04:46
Basic question: UDF for wall heat flux Carl FLUENT 1 August 5, 2006 20:01
UDF question Ryan FLUENT 2 July 5, 2006 15:54
A question about the dynamic mesh UDF Tango FLUENT 1 November 27, 2003 03:56


All times are GMT -4. The time now is 12:37.