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

udf to access variables from a different case

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 12, 2011, 05:01
Default udf to access variables from a different case
  #1
New Member
 
Join Date: Jun 2011
Posts: 18
Rep Power: 15
yashmash is on a distinguished road
Hi all,

I would like to save some variables (for each cell) from one case and use those variables (as materials properties, for each cell) into another case. I am using the same mesh in both cases.
Any hints on how to write a UDF for that?

Cheers,

Yashmash
yashmash is offline   Reply With Quote

Old   October 12, 2011, 09:01
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by yashmash View Post
I would like to save some variables (for each cell) from one case and use those variables (as materials properties, for each cell) into another case. I am using the same mesh in both cases.
Any hints on how to write a UDF for that?
Hi,

I know a procedure for your purpose but I don't know it's the best or not. You can do that by interpolating your desired data in (file->interpolate) and then read that in a new case in a same manner; but as you can see, you're permitted to interpolate special variables for which conservation equation has been solved; so there's a trick with a temporary UDS! First store your desired data in a UDS and ensure you've deactivated this scalar equation in (solve->control->solution), then you can interpolate this type of data.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   October 14, 2011, 04:08
Default
  #3
New Member
 
Join Date: Jun 2011
Posts: 18
Rep Power: 15
yashmash is on a distinguished road
Hello Amir,

Thanks for your help. I have used your method successfully, however, I was hoping you could help me on another issue.
Now that I have my uds in my other case, I want to use that variable in the calculation of my material property (material absorption coefficient in that case). I have written a UDF as follows:

DEFINE_PROPERTY(abs_coeff,cell,thread)
{
Thread *t;
cell_t c;
real value = 0;
real abs_coeff = 0;
Domain *d;
d = Get_Domain(1);
/* Calculating the scattering coefficient */
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
value = C_UDSI(c,t,0);
}
end_c_loop(c,t)
}
abs_coeff = 4.22*value;
return abs_coeff;
}

I have turned off the uds solver and am NOT re-initializing (since that would make my uds values equal to zero). But the values of absorption coefficient that is returned by fluent are not what I am expecting (they are constant throughout my domain, which shouldnt be the case since the values of my uds are not constant).

Are the steps that I'm following ok? Where am I going wrong?

Thanks a lot,

Yashmash
yashmash is offline   Reply With Quote

Old   October 14, 2011, 04:29
Default
  #4
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi,
Your UDF is not correct. Do not use any loop in that ....
Quote:
DEFINE_PROPERTY(abs_coeff,cell,thread)
{
real abs_coeff = 0;
abs_coeff = 4.22*C_UDSI(cell,thread,0);
return abs_coeff;
}
Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   October 14, 2011, 04:59
Default
  #5
New Member
 
Join Date: Jun 2011
Posts: 18
Rep Power: 15
yashmash is on a distinguished road
Sweet! It works now..

Your assistance was much appreciated Amir, enjoy your week end
yashmash is offline   Reply With Quote

Old   January 25, 2012, 03:41
Default
  #6
New Member
 
Join Date: Jun 2011
Posts: 18
Rep Power: 15
yashmash is on a distinguished road
Hi Amir,

I was hoping you could help me with the following UDF. I am running atime dependent eulerian model with 3 phases. My udf is to store into a UDS the time-averaged volume fraction of one of the phases. However the values that are returned are the time-averaged volume fractions divided by a constant (constant is 74). Please see my UDF below:

#include "udf.h"
#define Rtio2 4260
DEFINE_ON_DEMAND(TiO2_loading_gm3)
{
Thread *thread_ti;
Thread *t;
Thread *mix_thread;
cell_t c;
real vof_ti = 0;
Domain *d;
d = Get_Domain(3);
/* Loop over all cell threads in the domain */

thread_loop_c(thread_ti,d)
{
/*thread_ti = THREAD_SUB_THREAD(mix_thread, 3);*/
/* Loop over all cells */
begin_c_loop(c,thread_ti)
{
vof_ti = C_STORAGE_R(c,thread_ti,SV_VOF_MEAN);

C_UDSI(c, thread_ti, 0) = vof_ti;
}
end_c_loop(c,thread_ti)

}
}

Your assistance is much appreciated,

Thanks,

Yash
yashmash is offline   Reply With Quote

Old   January 25, 2012, 10:10
Default
  #7
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Hi,

I'm not sure if I can help here because I don't know what the "C_STORAGE_R(c,thread_ti,SV_VOF_MEAN)" performs exactly. but it seems strange if you want the averaged field by using a DEFINE_ON_DEMAND macro! If I was you, with a simple DEFINE_ADJUST macro store the desired variable in a UDS and ....

Bests,
__________________
Amir
Amir 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
UDF to record FLUENT Solver variables... mariachi Fluent UDF and Scheme Programming 11 September 24, 2019 01:07
UDF Data access problems Mosheraa FLUENT 4 June 17, 2011 14:16
UDF to record FLUENT solver variables... mariachi FLUENT 1 February 3, 2010 23:18
can't access face variables ... bart weisser FLUENT 2 September 28, 2007 15:09
Error (ACCESS VIOLATION) with UDF Ale FLUENT 2 May 28, 2002 03:50


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