CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Error : UDF to store normal distance of interface from the cell center

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 6, 2022, 17:34
Default Error : UDF to store normal distance of interface from the cell center
  #1
New Member
 
Krishna
Join Date: Oct 2016
Posts: 12
Rep Power: 10
kavatar is on a distinguished road
Hello Everyone,

I am trying to store the normal distance of reconstructed interface from the cell center in each cell (if interface exists) in VOF Geo-reconstruct. I have come across the macro Get_Surface_Distance(c,t). The user defined function I am using is:

#include "udf.h"
#include "sg_mphase.h"
#include "sg_vof.h"
#include "sg.h"

DEFINE_ADJUST(gradient, domain)
{
#if !RP_HOST
Thread *t;
Thread **pt;
cell_t c;

int phase_domain_index = 0;

Domain *pDomain =
DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
{
Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_N ULL);
Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG,Vof_Deriv_Accumulate);
}

mp_thread_loop_c (t,domain,pt)

if (FLUID_THREAD_P(t))
{
Thread *ppt = pt[phase_domain_index];

begin_c_loop (c,t)
{
//0.05 is my volume fraction cutoff criteria
if(C_VOF(c,ppt)>0.05 && C_VOF(c,ppt)<0.95)
{
C_UDMI(c,t,0)=Get_Surface_Distance(c,ppt);
}
else
{
C_UDMI(c,t,0)=0;
}
}
end_c_loop (c,t)
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL);
#endif
}


This udf compiles without any error but when I run it on a grid It gives random values.

For example I take domain box (-5mm,-5mm,0) to (5mm,5mm,100mm). Subsequently mesh it into 10 equal cells with cell size of 10mm. Then I initialize multiphase (VOF) simulation as: from Z=0 to 30; Fraction_water=1, from Z=30 to 50; Fraction_water=0.75, and from Z=50 to 100; Fraction_Water=0.

After initialization I run the simulation for few time steps so that interface is reconstructed. Than I compile and hook the above udf and again re-run the simulation for single time step. After checking the UDMI_0 values I find that in cell where interface exists 0.05<C_VOF<0.95 or (30mm<Z<50mm); UDMI_0 values are 1.7977E+306 which is like garbage values.

Could anyone please help me solve this issue?. or If there is any other way to get the value of normal distance of interface from cell center than please let me know.

Thanks and Regards
Krishna
kavatar is offline   Reply With Quote

Old   December 7, 2022, 01:41
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
should it be brackets after mp_thread_loop_c (t,domain,pt)?
Code:
mp_thread_loop_c (t,domain,pt)
{}
also I'm not sure it the thread pointer should be t or ppt here
Code:
begin_c_loop (c,t)
{
//0.05 is my volume fraction cutoff criteria
if(C_VOF(c,ppt)>0.05 && C_VOF(c,ppt)<0.95)
{
C_UDMI(c,t,0)=Get_Surface_Distance(c,ppt);
}
else
{
C_UDMI(c,t,0)=0;
}
}
end_c_loop (c,t)
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 7, 2022, 02:34
Default
  #3
New Member
 
Krishna
Join Date: Oct 2016
Posts: 12
Rep Power: 10
kavatar is on a distinguished road
Hello Alexander,

I have applied the brackets after mp_thread_loop_c (t,domain,pt) as per your suggestion.

My new udf look like:

#include "udf.h"
#include "sg_mphase.h"
#include "sg_vof.h"
#include "sg.h"

DEFINE_ADJUST(gradient, domain)
{
#if !RP_HOST
Thread *t;
Thread **pt;
cell_t c;

int phase_domain_index = 0;

Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
{
Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_N ULL);
Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG,Vof_Deriv_Accumulate);
}

mp_thread_loop_c (t,domain,pt)
{
if (FLUID_THREAD_P(t))
{
Thread *ppt = pt[phase_domain_index];

begin_c_loop (c,t)
{
if(C_VOF(c,ppt)>0.05 && C_VOF(c,ppt)<0.95)
{
C_UDMI(c,t,0)=Get_Surface_Distance(c,ppt);
}
else
{
C_UDMI(c,t,0)=0;
}
}
end_c_loop (c,t)
}
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL);
#endif
}



But the results value didn't change and I am still getting C_UDMI[0]=1.7977E+306 in interface cells.



Looking forward for your further suggestions


Also as per your second suggestion I took all the listed combinations of (ppt and t) as:

if(C_VOF(c,t)>0.05 && C_VOF(c,t)<0.95)
{
C_UDMI(c,t,0)=Get_Surface_Distance(c,t);
}


and

if(C_VOF(c,ppt)>0.05 && C_VOF(c,ppt)<0.95)
{
C_UDMI(c,t,0)=Get_Surface_Distance(c,t);
}


and

if(C_VOF(c,t)>0.05 && C_VOF(c,t)<0.95)
{
C_UDMI(c,t,0)=Get_Surface_Distance(c,ppt);
}


But none of these worked and I got the error as:

Error: received a fatal signal (Segmentation fault).
Error Object: #f
kavatar is offline   Reply With Quote

Old   December 7, 2022, 08:43
Default
  #4
New Member
 
Krishna
Join Date: Oct 2016
Posts: 12
Rep Power: 10
kavatar is on a distinguished road
Hello Alexander,

I guess the problem lies in the red colored line only:

#include "udf.h"
#include "sg_mphase.h"
#include "sg_vof.h"
#include "sg.h"

DEFINE_ADJUST(gradient, domain)
{
#if !RP_HOST
Thread *t;
Thread **pt;
cell_t c;

int phase_domain_index = 0;

Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
{
Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_N ULL);
Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG,Vof_Deriv_Accumulate);
}

mp_thread_loop_c (t,domain,pt)
{
if (FLUID_THREAD_P(t))
{
Thread *ppt = pt[phase_domain_index];

begin_c_loop (c,t)
{
if(C_VOF(c,ppt)>0.05 && C_VOF(c,ppt)<0.95)
{
C_UDMI(c,t,0)=Get_Surface_Distance(c,ppt);
}
else
{
C_UDMI(c,t,0)=0;
}
}
end_c_loop (c,t)
}
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL);
#endif
}

when I replace

C_UDMI(c,t,0)=Get_Surface_Distance(c,ppt);

with

C_UDMI(c,t,0)=C_VOF(c,ppt);

UDF works fine and volume fraction of water is stored in the UDMI.

Could you please check what is wrong with C_UDMI(c,t,0)=Get_Surface_Distance(c,ppt);.

I tried C_UDMI(c,t,0)=Get_Surface_Distance(c,t);, but this gives error as Error: received a fatal signal (Segmentation fault).
Error Object: #f


waiting for your response.

Thanks and regards
Krishna
kavatar is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unit Normal Vector and Interface Jump ||.|| mcfdma OpenFOAM Programming & Development 3 February 20, 2023 10:00
My radial inflow turbine Abo Anas CFX 27 May 11, 2018 02:44
Error - Solar absorber - Solar Thermal Radiation MichaelK CFX 12 September 1, 2016 06:15
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 07:28
Warning 097- AB Siemens 6 November 15, 2004 05:41


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