CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   DPM Switching doesn't switch law when I have specified (https://www.cfd-online.com/Forums/fluent-udf/200737-dpm-switching-doesnt-switch-law-when-i-have-specified.html)

skumar112 April 11, 2018 15:39

DPM Switching doesn't switch law when I have specified
 
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;
}

AlexanderZ April 11, 2018 22:03

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

skumar112 April 12, 2018 03:49

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.

obscureed April 13, 2018 03:39

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

AlexanderZ April 14, 2018 03:44

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


All times are GMT -4. The time now is 08:01.