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/)
-   -   Segmentation Error in Compiling UDF (https://www.cfd-online.com/Forums/fluent-udf/217870-segmentation-error-compiling-udf.html)

shakib May 28, 2019 05:32

Segmentation Error in Compiling UDF
 
Hello every one

I wanna see the concentration of bacterial particles as a water species ( like pressure and velocity ) in contours. my system is just in 1 phase.

I used to write a UDF. After I build and load the library and hook it and allocate the number of UDM locations, unfortunately when I try to start the calculation, segmentation fault will appear.

Please help me get rid of this problem.

My UDF code is:


#include <udf.h>
DEFINE_ADJUST(bacterial_growth, d)
{
Domain *domain;/*domain points to domain Thread*/
int ID = 9;/*Number of interior (Fluid) zone*/
Thread *t = Lookup_Thread(domain, ID);/*t points to Thread*/
cell_t c;/*An integer data type that identifies a particular cell within a cell thread that names "c"*/
real s1 = 2, s2 = 3;
const real ks1 = 1, ks2 = 2, mumax = 3;/*Using These 3 Orders to declare consistent*/
thread_loop_c(t, domain)/*Looping over Cell threads (e.g. fluid and solid) in Domain*/
{
{
begin_c_loop(c, t)/*Loops Over Cells in a Cell Thread*/
{
C_UDMI(c, t, 0) = mumax * (s1 / (ks1 + s1)) * (s2 / (ks2 + s2));
}
end_c_loop(c, t)
}
}
}




Thanks in advance.

AlexanderZ May 29, 2019 03:12

Code:

#include <udf.h>
DEFINE_ADJUST(bacterial_growth, d)
{
int ID = 9;/*Number of interior (Fluid) zone*/
Thread *t = Lookup_Thread(d, ID);/*t points to Thread*/
cell_t c;/*An integer data type that identifies a particular cell within a cell thread that names "c"*/
real s1 = 2, s2 = 3;
const real ks1 = 1, ks2 = 2, mumax = 3;/*Using These 3 Orders to declare consistent*/
thread_loop_c(t, d)/*Looping over Cell threads (e.g. fluid and solid) in Domain*/
        {
                begin_c_loop(c, t)/*Loops Over Cells in a Cell Thread*/
                        {
                                C_UDMI(c, t, 0) = mumax * (s1 / (ks1 + s1)) * (s2 / (ks2 + s2));
                        }
                end_c_loop(c, t)
        }
}

best regards

shakib June 1, 2019 04:50

Quote:

Originally Posted by AlexanderZ (Post 735013)
Code:

#include <udf.h>
DEFINE_ADJUST(bacterial_growth, d)
{
int ID = 9;/*Number of interior (Fluid) zone*/
Thread *t = Lookup_Thread(d, ID);/*t points to Thread*/
cell_t c;/*An integer data type that identifies a particular cell within a cell thread that names "c"*/
real s1 = 2, s2 = 3;
const real ks1 = 1, ks2 = 2, mumax = 3;/*Using These 3 Orders to declare consistent*/
thread_loop_c(t, d)/*Looping over Cell threads (e.g. fluid and solid) in Domain*/
        {
                begin_c_loop(c, t)/*Loops Over Cells in a Cell Thread*/
                        {
                                C_UDMI(c, t, 0) = mumax * (s1 / (ks1 + s1)) * (s2 / (ks2 + s2));
                        }
                end_c_loop(c, t)
        }
}

best regards

Thank you sir, it works fine.

Best regards.


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