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

DPM Switching doesn't switch law when I have specified

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 11, 2018, 16:39
Default DPM Switching doesn't switch law when I have specified
  #1
Member
 
sunil kumar
Join Date: May 2016
Posts: 80
Rep Power: 10
skumar112 is on a distinguished road
I have set a DPM switch so that the laws change with a user defined scalar but the laws are not switching when I have specified. Does anyone know why this is

Material *m = TP_MATERIAL(tp);
if (TP_USER_REAL(tp,0) > 0.5)
{
TP_CURRENT_LAW(tp) = DPM_LAW_USER_1;
}
if (TP_USER_REAL(tp,0) <= 0.5)
{
TP_CURRENT_LAW(tp) = DPM_LAW_INITIAL_INERT_HEATING;
}
skumar112 is offline   Reply With Quote

Old   April 11, 2018, 23:03
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
code looks correct (comparing to example from manual)
did you hook your function in fluent GUI?

you may try to check your condition (TP_USER_REAL(tp,0) > 0.5) using Message function:
Code:
DEFINE_DPM_SWITCH(dpm_switch, tp, coupled)
{
Material *m = TP_MATERIAL(tp);
int i=0,j=0;
if (TP_USER_REAL(tp,0) > 0.5)
{
TP_CURRENT_LAW(tp) = DPM_LAW_USER_1;
if i==0 {Message0("in DPM_LAW_USER_1 \n"); i++;}
}
else {
TP_CURRENT_LAW(tp) = DPM_LAW_INITIAL_INERT_HEATING;
if j==0 {Message0("DPM_LAW_INITIAL_INERT_HEATING \n "); j++;}
}
}
best regards
AlexanderZ is offline   Reply With Quote

Old   April 12, 2018, 04:49
Default
  #3
Member
 
sunil kumar
Join Date: May 2016
Posts: 80
Rep Power: 10
skumar112 is on a distinguished road
Yes I have hooked the function in the GUI.

It moves into the heating law as it displays the message but the law is not doing what I am expecting it to do. That was very helpful thank you I will have to give it some further investigation.
skumar112 is offline   Reply With Quote

Old   April 13, 2018, 04:39
Default
  #4
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 12
obscureed is on a distinguished road
Hi AlexanderZ,

Is the intention of i and j to get the information messages only once? With your code as suggested, this will not happen, because i and j are initialised to 0 on every visit. To get only one message, you would need to define i and j as static variables outside the UDF:
Code:
static int i=0,j=0;
DEFINE_DPM_SWITCH(dpm_switch, tp, coupled)
{
Material *m = TP_MATERIAL(tp);
if (TP_USER_REAL(tp,0) > 0.5)
{
  TP_CURRENT_LAW(tp) = DPM_LAW_USER_1;
  if (i==0) {Message0("in DPM_LAW_USER_1 \n"); i++;}
}else {
  TP_CURRENT_LAW(tp) = DPM_LAW_INITIAL_INERT_HEATING;
  if (j==0) {Message0("DPM_LAW_INITIAL_INERT_HEATING \n "); j++;}
}
}
There is now an issue that you now get one message, even for many particles and many releases. To get the message again, you need to reset i and j, for example by recompiling. This is not an easy area...
Ed
obscureed is offline   Reply With Quote

Old   April 14, 2018, 04:44
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
thank you for comment.
with i and j i wanted to run message function only once.

we may put i and j in DEFINE_EXECUTE_AT_END macros to set i and j = 0 after each time step.
For that case we should define i and j as global variables.

best regards
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
DPM Switching skumar112 Fluent UDF and Scheme Programming 0 April 4, 2018 13:10
DPM UDF for switching law amilachandra Fluent UDF and Scheme Programming 1 September 15, 2016 04:43
UDF for Drag law in DPM mail.leonardo Fluent Multiphase 1 July 18, 2016 04:41
UDF for DPM Law Switch Leepox Fluent UDF and Scheme Programming 0 August 26, 2013 06:36
questions about the DPM law rookie FLUENT 0 June 16, 2003 12:41


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