CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF - C_UDMI is giving sigsegv error (https://www.cfd-online.com/Forums/fluent/229365-udf-c_udmi-giving-sigsegv-error.html)

fit78 August 6, 2020 01:56

UDF - C_UDMI is giving sigsegv error
 
Hello,

I am having issues with C-UDMI with my simple code.

I read all the thread relevant to this but to no avail.

I am using Ansys 2019 R2
- I have allocated a memory in UDM GUI
-The UDF worked fine without C_UDMI.

Anyone can assist?
TQ
Fit78

-----------------------

/* UDF to define a simple mass transfer
The "to" phase is the gas phase and the "from" phase is the liquid phase */

#include "udf.h"

DEFINE_MASS_TRANSFER(liq_gas_source, cell, thread, from_index,from_species_index, to_index, to_species_index)
{

cell_t c;

Thread *t;

real m_vap,m_air;
real W_I;
real vof_cutoff = 0.05;
real tmr,vmr,amr,vpp;

real P_pvi;
real Diff;

real m_dot, dp, m_source;


Thread *gas = THREAD_SUB_THREAD(thread, to_index);
Thread *liq = THREAD_SUB_THREAD(thread, from_index);


real press = C_P(cell, thread);
real rho_l = C_R(cell,liq);
real rho_v = C_R(cell,gas);
real vof_l = C_VOF(cell,liq);
real vof_v = C_VOF(cell,gas);




m_dot = 0.;

m_vap=18.01528;
m_air=28.97;
//Mass diffusivity for air-water
Diff=0.282;

//total mole ratio - vapor mole ratio -air mole ratio
tmr=m_vap+m_air;
vmr=m_vap/tmr;
amr=m_air/tmr;


if ( (vof_l > vof_cutoff ) && (vof_l < (1 - vof_cutoff) ))

{ /* Evaporative cooling at interface */


//vapor partial pressure
vpp = (vmr/tmr)*press;

//mass fraction at interface
W_I=(m_vap*vpp)/((m_air*(press-vpp))+(m_vap*vpp));

//mass flow rate at interface - supposed to include dw/dr but later
m_dot=(rho_v*Diff)/(1-W_I);

// save mass flow rate to user defined memory in Fluent

C_UDMI(c,t,0) = m_dot;



}


return (m_dot);
}

AlexanderZ August 6, 2020 02:01

use
Code:

C_UDMI(cell,thread,0) = m_dot;

fit78 August 6, 2020 02:17

Thanks! That did it. Saved me lots of time debugging. Sometimes you just need a fresh pair of eyes. I wonder why the syntax is very inconsistent like this.

anonymous96_ November 6, 2023 01:49

Hi
I am trying to calculate volumetric flow rate through an interior surface.Following is my piece of code:

DEFINE_ON_DEMAND(ach_udf)
{
Thread *t,*to;
face_t f;
cell_t co;
Domain *d;
d = Get_Domain(1);
real A[ND_ND];
t = Lookup_Thread(d,2);
real ACHt_mean_out=0;
real ACHt_mean_in=0;

begin_f_loop(f,t)
{
F_AREA(A,f,t);
co = F_C0(f, t);
to = THREAD_T0(t);
real vel_roof= C_V(co,to);
if (vel_roof>0)
{
ACHt_mean_out += vel_roof*NV_MAG(A);
}
else
{
ACHt_mean_in +=vel_roof*NV_MAG(A);
}
}
end_f_loop(f,t)
}

This is getting compiled and solved properly. But as soon as I use C_UDMI for storage, it gives error on using execute on demand. Following is the code which gives error:

DEFINE_ON_DEMAND(ach_udf)
{
Thread *t,*to;
face_t f;
cell_t co;
Domain *d;
d = Get_Domain(1);
real A[ND_ND];
t = Lookup_Thread(d,2);
real ACHt_mean_out=0;
real ACHt_mean_in=0;

begin_f_loop(f,t)
{
F_AREA(A,f,t);
co = F_C0(f, t);
to = THREAD_T0(t);
real vel_roof= C_V(co,to);
if (vel_roof>0)
{
ACHt_mean_out += vel_roof*NV_MAG(A);
}
else
{
ACHt_mean_in +=vel_roof*NV_MAG(A);
}
}
end_f_loop(f,t)

C_UDMI (co,to,0)=ACHt_mean_out ;
}

Can you please tell me what is wrong here.

AlexanderZ November 6, 2023 22:56

allocate user defined memory
fluent gui-> user defined -> memory -> user defined memory location change to 1

anonymous96_ November 6, 2023 23:05

I have already allocated the UDM in GUI.

AlexanderZ November 7, 2023 00:14

Code:

#include "udf.h"

DEFINE_ON_DEMAND(ach_udf)
{
Thread *t,*to;
face_t f;
cell_t co;
Domain *d;
real ACHt_mean_out=0;
real ACHt_mean_in=0;
real A[ND_ND];
real vel_roof;
d = Get_Domain(1);
t = Lookup_Thread(d,2);

begin_f_loop(f,t)
{
F_AREA(A,f,t);
co = F_C0(f, t);
to = THREAD_T0(t);
vel_roof= C_V(co,to);
if (vel_roof>0)
{
ACHt_mean_out += vel_roof*NV_MAG(A);
}
else
{
ACHt_mean_in +=vel_roof*NV_MAG(A);
}
}
end_f_loop(f,t)

C_UDMI (co,to,0)=ACHt_mean_out ;
}


anonymous96_ November 7, 2023 00:41

I have included the header files too just not posted them here. As I said , the code runs successfully without adding C_UDMI(co, to,0)=........., but as soon as I add this to the code, it gives error on using "execute" for execute on demand.


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