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

Simple Udf HELP

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 5, 2023, 14:30
Default Simple Udf HELP
  #1
New Member
 
Mohammadreza Tohidi
Join Date: Jul 2023
Posts: 4
Rep Power: 2
Reza_th is on a distinguished road
hello guys.

Anyone can help me to update the prev_b only at the end of each time step? in the code i wrote here prev_b will be updated at each iteration

Any suggestion?




#include "udf.h"

real k = 0.1;
real L = 0.01;
real T_inf_BC2 = 273.15;
real T_inf_BC1 = 270.15;
real T_inf_BC3 = 280.0;
real h_BC2 = -2000.0;
real h_BC3 = -10.0;
real b = 0;
real m_snow = 4;
real prev_b = 0; // Variable to store the previous value of 'b'

DEFINE_PROFILE(heat_flux_bc, thread, position)
{
real x[ND_ND];
real flux;
real time = CURRENT_TIME;
real i = time / CURRENT_TIMESTEP;
face_t f;
real t_face;
real h_BC1 = -(k / L);

begin_f_loop(f, thread)
{
F_CENTROID(x, f, thread);
t_face = C_T(f, thread); //[K]

if (t_face < 273.15)
{
flux = h_BC1 * (t_face - T_inf_BC1);
b = prev_b + m_snow - 1;
}
else
{
if (i > 300)
{
flux = h_BC3 * (t_face - T_inf_BC3); //[w/m2]
b = prev_b + flux - m_snow;
}
else
{
flux = h_BC2 * (t_face - T_inf_BC2); //[w/m2]
b = prev_b + m_snow + 1;
}
}
F_PROFILE(f, thread, position) = flux;
}
end_f_loop(f, thread)
prev_b = b;


Message("t_face = %.5f K\n", t_face);
Message("flux = %.5f w/m2\n", flux);
Message("i = %.5f \n", i);
Message("b = %.5f K\n", b);
Message("prev_b = %.5f K\n", prev_b);

}
Reza_th is offline   Reply With Quote

Old   October 5, 2023, 23:58
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
DEFINE_EXECUTE_AT_END macro
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ 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
Simple UDF for piston movement NicolasCheshire Fluent UDF and Scheme Programming 1 October 7, 2016 10:36
Simple parabolic velocity UDF with symmetry - what am I not understanding!?! NPGrad FLUENT 1 September 30, 2016 11:42
Error in Simple UDF! Abhya Fluent UDF and Scheme Programming 1 March 14, 2013 08:36
FLUENT UDF Simple error. startup0820 Fluent UDF and Scheme Programming 0 August 14, 2012 03:54
simple rigid body motion UDF Dan FLUENT 0 January 11, 2006 05:48


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