CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Check if energy is enabled from inside udf (http://www.cfd-online.com/Forums/fluent-udf/74326-check-if-energy-enabled-inside-udf.html)

dmoroian March 30, 2010 07:25

Check if energy is enabled from inside udf
 
I wrote a udf which reads the temperature field using macro C_T(c,t). However, if the energy equation is not enabled the udf generates a SEGMENTATION FAULT.
Is it possible to check from within the udf if there is a temperature field?

Dragos

gearboy March 30, 2010 23:21

Quote:

Originally Posted by dmoroian (Post 252271)
I wrote a udf which reads the temperature field using macro C_T(c,t). However, if the energy equation is not enabled the udf generates a SEGMENTATION FAULT.
Is it possible to check from within the udf if there is a temperature field?

Dragos

#include "udf.h"
DEFINE_ON_DEMAND(test_temp_field)
{
Domain *domain;
Thread *c_thread;
domain=Get_Domain(1);
thread_loop_c(c_thread, domain) /*loops over all cell threads in domain*/
{

if(NNULLP(THREAD_STORAGE(c_thread,SV_T)))
Message0("Temp. field exists\n");
else
Message0("Temp. field doesn't exist\n");

}

dmoroian March 31, 2010 02:38

Thanks Ji,
Do you have a similar check for species?

Dragos

gearboy March 31, 2010 04:02

Quote:

Originally Posted by dmoroian (Post 252414)
Thanks Ji,
Do you have a similar check for species?

Dragos

Use the following for species transport model.
if(NNULLP(THREAD_STORAGE(c_thread,SV_Y_I(i))))

i is the number of your specified species.

dmoroian March 31, 2010 04:56

SV_Y_I is not working (sintax error), instead I think SV_Y_0 should be used and then check for particular SV_Y_I(i)

dmoroian April 12, 2010 08:20

Quote:

Originally Posted by dmoroian (Post 252432)
SV_Y_I is not working (sintax error), instead I think SV_Y_0 should be used and then check for particular SV_Y_I(i)

The above test gives false positives, the following check seems to work well (12.0.16):
Code:

if(!rp_spe)
  Error("Species transport is disabled!\n");
if(2 > n_spe)
  Error("Not enough species, minim 3, current %d.\n",n_spe);



All times are GMT -4. The time now is 00:13.