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

Define_adjust does't work

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   July 15, 2013, 09:42
Default Define_adjust does't work
  #1
New Member
 
Chen wubin
Join Date: Jul 2013
Posts: 3
Rep Power: 4
luckchen is on a distinguished road
HI,guys!
I'm aiming to write a udf to achieve getting the water vaper mass fraction and store it. the codes as follows:

DEFINE_ADJUST(water_fraction,d)
{Thread *t;
cell_t c;
real watdry;
real watwet;
real watdryav;
real watwetav;
real volume;
real vol_tot;
real vol_tot2;
thread_loop_c(t,d)
{if(THREAD_ID(t)==26) /* dry gdl */
{
begin_c_loop(c,t)
{
volume=C_VOLUME(c,t);
watdry=C_YI(c,t,0);
watdryav+=watdry*volume;
vol_tot+=volume;
}
end_c_loop(c,t)
}
else if(THREAD_ID(t)==27) /* wet gdl */
{
begin_c_loop(c,t)
{
volume=C_VOLUME(c,t);
watwet=C_YI(c,t,0);
watwetav+=watwet*volume;
vol_tot2+=volume;
}
end_c_loop(c,t)
}
}
watdryav/=vol_tot;
watwetav/=vol_tot2;
thread_loop_c(t,d)
{if(THREAD_ID(t)==26)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,1)=watdryav;
}
end_c_loop(c,t)
}
else if(THREAD_ID(t)==27)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,2)=watwetav;
}
end_c_loop(c,t)
}
}
}

I get the THREAD_ID(t) number (26,27) from fluent bc pannel,and they are porous zones,but when i run through this codes,it does't work,the value of C_UDMI(c,t,2) or C_UDMI(c,t,1) is still zero when i check out the fluent results.
Thanks in advance for any suggestions
luckchen is offline   Reply With Quote

Old   July 15, 2013, 10:06
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 315
Rep Power: 11
blackmask will become famous soon enough
You need a text editor with indention. Add a "{" after
Code:
thread_loop_c(t,d)
and put a "}" at the end of your code shown above and try again.
blackmask is offline   Reply With Quote

Old   July 15, 2013, 21:03
Default
  #3
New Member
 
Chen wubin
Join Date: Jul 2013
Posts: 3
Rep Power: 4
luckchen is on a distinguished road
Quote:
Originally Posted by blackmask View Post
You need a text editor with indention. Add a "{" after
Code:
thread_loop_c(t,d)
and put a "}" at the end of your code shown above and try again.
Hi,blackmask,thanks for your reply.in my codes,i have a "{" after the thread_loop_c(t,d),maybe you haven't seen it clearly.
Code:
thread_loop_c(t,d)
{if(THREAD_ID(t)==26)
In order to make my codes more clear,i present my codes again as follows:
Code:
DEFINE_ADJUST(water_fraction,d)
{Thread *t;
 cell_t c;
 real watdry;
 real watwet;
 real watdryav;
 real watwetav;
 real volume;
 real vol_tot;
 real vol_tot2;
 thread_loop_c(t,d)
 {
 	if(THREAD_ID(t)==26) /* dry gdl */
    {
    	begin_c_loop(c,t)
    	{
         volume=C_VOLUME(c,t);
         watdry=C_YI(c,t,0);
         watdryav+=watdry*volume;
         vol_tot+=volume;
    	}
    	end_c_loop(c,t)
    	}
    else if(THREAD_ID(t)==27) /* wet gdl */
    {
    	begin_c_loop_all(c,t)
    	{
    		volume=C_VOLUME(c,t);
    		watwet=C_YI(c,t,0);
    		watwetav+=watwet*volume;
    		vol_tot2+=volume;
    	}
    	end_c_loop_all(c,t)
    }
 }
 watdryav/=vol_tot;
 watwetav/=vol_tot2;
 thread_loop_c(t,d)
 {
 	if(THREAD_ID(t)==26)
    {
    	begin_c_loop(c,t)
    	{
        C_UDMI(c,t,1)=watdryav;
    	}
    	end_c_loop(c,t)
    }
    else if(THREAD_ID(t)==27)
    {
    	begin_c_loop(c,t)
    	{
        C_UDMI(c,t,2)=watwetav;
    	}
    	end_c_loop(c,t)
    }
  }
}
luckchen is offline   Reply With Quote

Old   July 15, 2013, 21:42
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 315
Rep Power: 11
blackmask will become famous soon enough
Fair enough. You could use
Code:
Lookup_Thread
instead of "thread_loop_c" for you purpose.

Are you sure that both "watdry" and "watwet" are the same species "C_YI(c,t,0)"? You could print the value of watdryav, watwetav, vol_tot, vol_tot2 use
Code:
Message
Make sure that the loop over cells is actually executed.
blackmask is offline   Reply With Quote

Old   July 16, 2013, 10:15
Default
  #5
New Member
 
Chen wubin
Join Date: Jul 2013
Posts: 3
Rep Power: 4
luckchen is on a distinguished road
hi blackmask,thank you for your advices.
i just try the code lookup_thread,but it also can't not work.the udf presented is a small part among my all udf documents,and there are many udfs i haven't present here including
Code:
thread_loop_c(t,d)
 {
 	if(THREAD_ID(t)==26) /* dry gdl */
    {
    	begin_c_loop(c,t)
    	{
         .......
    	}
    	end_c_loop(c,t)
    	}
 }
so i just want to figure out the mistake using the code above,which will also help modify other udfs.

both "watdry" and "watwet" are the same species "C_YI(c,t,0)",i use species transport model in my case,the fluid is a mixture of watervapor and dry air.C_YI(c,t,0) represents the watervapor.

and i use the syntax 'message' to print the value of some varibles,when run the case,all values equal to zero,so thread_loop_c(t,d) is not actually executed.
luckchen is offline   Reply With Quote

Reply

Tags
define_adjust, thread_id(t), udmi

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to work with constant pressure? Martin CD-adapco 2 February 25, 2009 14:23
Getting FoamX to work shaun OpenFOAM Installation 12 March 23, 2007 09:55
work related to brake study of a vehical aero CD-adapco 3 November 23, 2006 08:43
Why do the Plant library cases don't work? Alumna Phoenics 6 June 22, 2004 12:08
why my In-Form doesn't work? green Phoenics 2 May 27, 2004 21:03


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