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

Parse error in UDF Code

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 18, 2020, 02:15
Default Parse error in UDF Code
  #1
New Member
 
Sharey
Join Date: Jul 2020
Posts: 4
Rep Power: 5
Sharey is on a distinguished road
Hello everyone,
I am trying to work on a UDF, the function is to transfer the mass from steam to water using VOF Explicit (Volume fraction discretization) approach.
The UDF is initially showing the parse error in line parse error in line 16 and showing undeclared variable in line 17. UDF is given as:

#include <udf.h>
#include <mem.h>
#include <sg_mphase.h>
#define domain_ID 1

float h_lg = 2085.0;

/* 1. Filling up the UDS with the Volume Fraction for the vapor phase */
DEFINE_ADJUST(gradient_vapor, mix_domain)
{
Thread *mixture_thread;
cell_t c;

mix_domain = Get_Domain(domain_ID);

Domain *sub_domain;
sub_domain = Get_Domain(2);

int phase_domain_index = PHASE_DOMAIN_INDEX(sub_domain);

// Domain *vapor = DOMAIN_SUB_DOMAIN(mix_domain, phase_domain_index);
Thread *vap = THREAD_SUB_THREAD(mixture_thread, phase_domain_index);
thread_loop_c(vap, sub_domain)
{
begin_c_loop(c, vap)
{
C_UDSI(c, vap, 0) = C_VOF(c, vap);
}
end_c_loop(c, vap)
}
}

/* 2. Filling up the UDS with the Volume Fraction for the liquid phase */
DEFINE_ADJUST(gradient_liq, mix_domain)
{
Thread *mixture_thread;
cell_t c;

mix_domain = Get_Domain(domain_ID);

Domain *sub_domain;
sub_domain = Get_Domain(3);
int phase_domain_index = PHASE_DOMAIN_INDEX(sub_domain);

// Domain *liquid = DOMAIN_SUB_DOMAIN(mix_domain, phase_domain_index);
Thread *liq = THREAD_SUB_THREAD(mixture_thread, phase_domain_index);
thread_loop_c(liq, sub_domain)
{
begin_c_loop(c, liq)
{
C_UDSI(c, liq, 1) = C_VOF(c, liq);
}
end_c_loop(c, liq)
}
}

/* 3. DEFINE_MASS_TRASFER SOURCE */
DEFINE_MASS_TRANSFER(source, c, mix_thread, from_phase_index, from_species_index, to_phase_index, to_species_index)
{
real m_lg;
float h_lg = 2085.0;

mix_domain = Get_Domain(domain_ID);

Thread *vapor = THREAD_SUB_THREAD(mix_thread, from_phase_index);
Thread *liquid = THREAD_SUB_THREAD(mix_thread, to_phase_index);

if( C_VOF(c, vapor) != 0.0 && C_VOF(c, vapor) != 1.0)
{
m_lg = (0.6/h_lg)* NV_DOT(C_T_G(cell, vapor), C_UDSI_G(cell, vapor, 0));
}

if(C_VOF(c, liquid) != 0.0 && C_VOF(c, liquid) != 1.0)
{
m_lg = - (0.6/h_lg)* NV_DOT(C_T_G(cell, liquid), C_UDSI_G(cell, liquid, 1));
}

else
{
m_lg = 0.;
}
return m_lg;
}


Can anyone please help me regarding the error i am getting in above UDF?
Thanks
Sharey is offline   Reply With Quote

Old   July 18, 2020, 03:05
Default
  #2
New Member
 
Sharey
Join Date: Jul 2020
Posts: 4
Rep Power: 5
Sharey is on a distinguished road
Anybody?????
Sharey is offline   Reply With Quote

Old   July 20, 2020, 01:51
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
change lines order
was
Code:
mix_domain = Get_Domain(domain_ID);
Domain *sub_domain;
to be
Code:
Domain *sub_domain;
mix_domain = Get_Domain(domain_ID);
compile code
show log file
__________________
best regards


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

Old   July 23, 2020, 11:47
Default
  #4
New Member
 
Sharey
Join Date: Jul 2020
Posts: 4
Rep Power: 5
Sharey is on a distinguished road
Hi Alexander, thanks for replying. I am still facing the Segmentation error while hooking the function (DEFINE_ON_DEMAND) on EXECUTE ON DEMAND dialog box. Any, suggestion for this.
Sharey is offline   Reply With Quote

Reply

Tags
fluent vof, parse error, udf, undeclared variable


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
Urgent help for UDF Code needed force_95 FLUENT 2 October 25, 2019 07:35
Parse Error while Interpreting UDF zh_cfd Fluent UDF and Scheme Programming 0 September 25, 2018 05:47
parse error while interpreting udf chem engineer Fluent UDF and Scheme Programming 10 September 18, 2015 09:06
Parse Error for Surface Reaction UDF cgravell Main CFD Forum 0 March 6, 2013 09:30
parse error in transient udf spring FLUENT 1 July 6, 2010 06:26


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