|
[Sponsors] |
DPM Switching doesn't switch law when I have specified |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 11, 2018, 16:39 |
DPM Switching doesn't switch law when I have specified
|
#1 |
Member
sunil kumar
Join Date: May 2016
Posts: 80
Rep Power: 10 |
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; } |
|
April 11, 2018, 23:03 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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++;} } } |
|
April 12, 2018, 04:49 |
|
#3 |
Member
sunil kumar
Join Date: May 2016
Posts: 80
Rep Power: 10 |
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. |
|
April 13, 2018, 04:39 |
|
#4 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
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++;} } } Ed |
|
April 14, 2018, 04:44 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 |
|
|
|
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 |