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

Calculate integrallll!!!!!!!!

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 5, 2012, 05:37
Default Calculate integrallll!!!!!!!!
  #1
New Member
 
Ch_Flame
Join Date: Apr 2012
Location: Iran
Posts: 13
Rep Power: 13
fatemeh chitgarha is on a distinguished road
I want to calculate an integral spatial. One of the following variables in integral is a UDS function of time and place(UDSI(X,t)).I want to calculate this Integral in every time step in a preprocessing stage. But i confused!
Do FLUENT UDS information saves at everyTIME step? What should I do??? HOW call info?????????
Here, I attached my UDF file.
Maybe you can find the problem and help me!
Thank you very much!

#include "udf.h"
DEFINE_ON_DEMAND(on_demand)
{
Domain *d;
Thread *t;
cell_t c;
real sum_diss=0.;
real sum_dissa=0.;
d = Get_Domain(1);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
for(CURRENT_TIME =15.491; CURRENT_TIME > 0.001; CURRENT_TIME--)
sum_diss += C_UDSI(c,t,0) * C_R(c,t) * C_VOLUME(c,t);
sum_dissa += C_UDSI(c,t,0) * C_VOLUME(c,t);
end_c_loop(c,t)
}
begin_c_loop(c,t)
{
C_UDMI(c, t, 1) = sum_diss/sum_dissa;
}
end_c_loop(c,t)
}
}
fatemeh chitgarha is offline   Reply With Quote

Old   August 5, 2012, 12:39
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 22
Amir is on a distinguished road
Dear Fatemeh,

Your implemented algorithm doesn't make sense! you cannot march in time like that; you have to choose a proper macro such as DEFINE_ADJUST which executed each time step and use global variables to store accumulative ones.
__________________
Amir
Amir is offline   Reply With Quote

Old   August 6, 2012, 02:37
Default
  #3
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
You should use DEFINE_EXECUTE_AT_END so as to sum up the variables you need at the end of each time step. Declare the sum_diss and sum_dissa as global variables(outside the DEFINE_EXECUTE_AT_END macro range).

real sum_diss=0.;
real sum_dissa=0.;
DEFINE_EXECUTE_AT_END(execute_at_end)
{
Domain *d;
Thread *t;
cell_t c;

d = Get_Domain(1);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
sum_diss+=C_UDSI(c,t,0)*C_R(c,t)*C_VOLUME(c,t);
sum_dissa+=C_UDSI(c,t,0)*C_VOLUME(c,t);
C_UDMI(c, t, 1) = sum_diss/sum_dissa;
}
end_c_loop(c,t)
}
Message0("current time=%f,sum_diss=%f,sum_dissa=%f\n",CURRENT_TIME,s um_diss,sum_dissa);
}





Quote:
Originally Posted by fatemeh chitgarha View Post
I want to calculate an integral spatial. One of the following variables in integral is a UDS function of time and place(UDSI(X,t)).I want to calculate this Integral in every time step in a preprocessing stage. But i confused!
Do FLUENT UDS information saves at everyTIME step? What should I do??? HOW call info?????????
Here, I attached my UDF file.
Maybe you can find the problem and help me!
Thank you very much!

#include "udf.h"
DEFINE_ON_DEMAND(on_demand)
{
Domain *d;
Thread *t;
cell_t c;
real sum_diss=0.;
real sum_dissa=0.;
d = Get_Domain(1);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
for(CURRENT_TIME =15.491; CURRENT_TIME > 0.001; CURRENT_TIME--)
sum_diss += C_UDSI(c,t,0) * C_R(c,t) * C_VOLUME(c,t);
sum_dissa += C_UDSI(c,t,0) * C_VOLUME(c,t);
end_c_loop(c,t)
}
begin_c_loop(c,t)
{
C_UDMI(c, t, 1) = sum_diss/sum_dissa;
}
end_c_loop(c,t)
}
}
gearboy is offline   Reply With Quote

Old   August 8, 2012, 19:56
Default
  #4
New Member
 
Ch_Flame
Join Date: Apr 2012
Location: Iran
Posts: 13
Rep Power: 13
fatemeh chitgarha is on a distinguished road
tnx For YOUR REPLY! if i put C_UDMI in inside loop, integral is soleved for each cell, but i need vloume integral in intire domain in each time step!!!! what do I do?
tnx for help.

Quote:
Originally Posted by gearboy View Post
You should use DEFINE_EXECUTE_AT_END so as to sum up the variables you need at the end of each time step. Declare the sum_diss and sum_dissa as global variables(outside the DEFINE_EXECUTE_AT_END macro range).

real sum_diss=0.;
real sum_dissa=0.;
DEFINE_EXECUTE_AT_END(execute_at_end)
{
Domain *d;
Thread *t;
cell_t c;

d = Get_Domain(1);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
sum_diss+=C_UDSI(c,t,0)*C_R(c,t)*C_VOLUME(c,t);
sum_dissa+=C_UDSI(c,t,0)*C_VOLUME(c,t);
C_UDMI(c, t, 1) = sum_diss/sum_dissa;
}
end_c_loop(c,t)
}
Message0("current time=%f,sum_diss=%f,sum_dissa=%f\n",CURRENT_TIME,s um_diss,sum_dissa);
}
fatemeh chitgarha is offline   Reply With Quote

Old   August 8, 2012, 19:59
Default
  #5
New Member
 
Ch_Flame
Join Date: Apr 2012
Location: Iran
Posts: 13
Rep Power: 13
fatemeh chitgarha is on a distinguished road
Tnx for reply

Quote:
Originally Posted by Amir View Post
Dear Fatemeh,

Your implemented algorithm doesn't make sense! you cannot march in time like that; you have to choose a proper macro such as DEFINE_ADJUST which executed each time step and use global variables to store accumulative ones.
fatemeh chitgarha is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate CF Odusseas Tecplot 3 August 28, 2020 15:16
how to calculate flow properties along the first grid point near to the wall kiran OpenFOAM Post-Processing 2 September 12, 2010 13:59
calculate values for eps and k from Re or u????? sbar OpenFOAM Pre-Processing 5 August 16, 2010 05:10
How to calculate Torque for francis turbine manish CFX 4 March 15, 2007 03:57
How to calculate energy dissipation chinthakindi Main CFD Forum 0 February 23, 2004 07:36


All times are GMT -4. The time now is 02:43.