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

Define_source macro fluent udf

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By Kimia
  • 2 Post By Kimia
  • 1 Post By Shehryar

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 18, 2017, 01:57
Angry Define_source macro fluent udf
  #1
New Member
 
Ali Shehryar
Join Date: Dec 2016
Posts: 13
Rep Power: 10
Shehryar is on a distinguished road
Hello experts!

Hope you are all fine. i am in need to take guidance regarding a small UDF which i wrote to add a source term. Actually i am working on transient Multiphase Eulerian model with one primary phase and one secondary phae. i have deactivated built in gravity and want to introduce a source term in y-momentum equation of secondary phase. Here is my UDF for the said purpose

#include "udf.h"


DEFINE_SOURCE(gravity_source,c,t,dS,eqn)
{
real gravity;
real source;
real density;
Thread *subthread;
subthread=THREAD_SUB_THREAD(t,1);
gravity = 9.8;
density=1000.0;
source = gravity*density*C_VOF(c,subthread);
dS[eqn] = 0.0;
return source;
}

that is, source=gravity x density x volume fraction of secondary phase.


but when i interpret/compile it with FLUENT i receive "Segmentation fault" error due to the presence of term "C_VOF(c,subthread)"
i run my UDF without this term and it runs fine. but i have to use this term to extract the volume fraction in the cell.

if you know where i am at fault please let me know, much appreciated.
Thanks in anticipation.
Shehryar is offline   Reply With Quote

Old   July 18, 2017, 19:43
Default
  #2
New Member
 
Join Date: Jun 2016
Posts: 17
Rep Power: 10
Kimia is on a distinguished road
Hi,

First of all your UDF compiles just fine if you compile it and not interpret it.
Second, in the Eulerian multiphase model, you have access to the momentum source terms in primary and secondary phase zones and not the mixture.
The thread you are calling is the mixture thread. You don't need to do that. You can just add the source term through the cell zone conditions>secondary zone> Source terms> Y momentum
I think your UDF should directly be added to your secondary phase and be like this:

DEFINE_SOURCE(gravity_source,c,t,dS,eqn)
{
real gravity;
real source;
real density;
gravity = 9.8;
density=1000.0;
source = gravity*density*C_VOF(c,t);
dS[eqn] = 0.0;
return source;
}

You can call the density as well by C_R(c,t).

I hope this helps.
Shehryar likes this.
Kimia is offline   Reply With Quote

Old   July 18, 2017, 23:43
Exclamation
  #3
New Member
 
Ali Shehryar
Join Date: Dec 2016
Posts: 13
Rep Power: 10
Shehryar is on a distinguished road
Thank you very much for the reply
But if i use C_VOF(c,t) then its sure i am getting volume fraction of secondary phase? By using

subthread=THREAD_SUB_THREAD(t,1);
C_VOF(c,subthread)

i was trying to get the volume fraction of secondary phase.
Shehryar is offline   Reply With Quote

Old   July 18, 2017, 23:52
Default
  #4
New Member
 
Ali Shehryar
Join Date: Dec 2016
Posts: 13
Rep Power: 10
Shehryar is on a distinguished road
i have compiled and added the source term in momentum equation of secondary phase. it runs fine. but i am still confused if C_VOF(c,t) is giving me the volume fraction of secondary phase or not.
Shehryar is offline   Reply With Quote

Old   July 19, 2017, 14:33
Default
  #5
New Member
 
Join Date: Jun 2016
Posts: 17
Rep Power: 10
Kimia is on a distinguished road
When you add the source term to the secondary phase, by default the threads that are passed on by FLUENT are phase level threads from that specific phase. so t here is pointer to secondary phase threads.
If however you want to a add a source term to the mixture phase and you want the volume fraction of the secondary phase you need to include THREAD_SUB_THREAD.
Shehryar and daliyou like this.
Kimia is offline   Reply With Quote

Old   July 20, 2017, 00:49
Thumbs up Thanks
  #6
New Member
 
Ali Shehryar
Join Date: Dec 2016
Posts: 13
Rep Power: 10
Shehryar is on a distinguished road
Perfect. i got it. i run the UDF using C_VOF(c,t) and its running successfully. Thanks a lot mate.
Kimia likes this.
Shehryar is offline   Reply With Quote

Old   November 12, 2018, 05:37
Default primary phase
  #7
New Member
 
Dali You
Join Date: Nov 2018
Location: Austria
Posts: 2
Rep Power: 0
daliyou is on a distinguished road
Quote:
Originally Posted by Kimia View Post
When you add the source term to the secondary phase, by default the threads that are passed on by FLUENT are phase level threads from that specific phase. so t here is pointer to secondary phase threads.
If however you want to a add a source term to the mixture phase and you want the volume fraction of the secondary phase you need to include THREAD_SUB_THREAD.
Hello Guys,

I would like to add a source term (turbulence energy) to mixture phase. I need the velocity of the primary and secondary phase. I define as following after reading your post and other suggest:

DEFINE_SOURCE(Gb, c, phase_t, dS, eqn)
{
real Cb, U_rel_x, U_rel_y, U_rel, U_r, source;
real rho_c, rho_d, delta_rho;
const real g_force = 9.81;
Thread *thread_c,*thread_d,*mt;
Thread **all_phase_t;
/*array*/
mt=THREAD_SUPER_THREAD(phase_t);
all_phase_t=THREAD_SUB_THREADS(mt);
thread_c = all_phase_t[0];
/*THREAD_SUB_THREAD(mt, 1); THREAD_SUB_THREAD(mix_thread, WATER_ID); liquid phase */
thread_d = all_phase_t[1]; /*THREAD_SUB_THREAD(mix_thread, AIR_ID); gas phase */
U_rel_x = C_U(c, thread_d) - C_U(c, thread_c);
U_rel_y = C_V(c, thread_d) - C_V(c, thread_c);
U_r = sqrt(U_rel_x*U_rel_x + U_rel_y*U_rel_y);
/* relative velocity from udf */
/* U_r=sqrt(pow(U_rel_x,2.0)+pow(U_rel_y,2.0))*/
Cb= 0.8;
rho_c = C_R(c, thread_c);
/* water density */
rho_d = C_R(c, thread_d); /* air density */
delta_rho = rho_c - rho_d; /* delta rho */
source= Cb*C_MU_L(c,phase_t)/C_MU_EFF(c,phase_t)*delta_rho*g_force*C_VOF(c,phas e_t)*U_r;*/
dS[eqn]= 0.0;
return source;
}

When hooking to fluent, there is no compiler error and some errors for calculating, as foolowing:
999999 (..\src\mpsystem.c@1172): mpt_read: failed: errno = 10054
999999: mpt_read: error: read failed trying to read 4 bytes: Invalid argument
MPI Application rank 0 exited before MPI_Finalize() with status -1073741819


I tried to fix it line by line, the problem is
'thread_c = all_phase_t[0];'

Can you give me some suggests? Thanks a lot!

Best regards
Dali
daliyou is offline   Reply With Quote

Reply

Tags
segmentation fault, udf code


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
Two questions on Fluent UDF Steven Fluent UDF and Scheme Programming 7 March 23, 2018 04:22
Problem running fluent with udf on batch tobi b. Fluent UDF and Scheme Programming 3 April 14, 2016 14:54
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
How does FLUENT process an UDF!!!!???? Bharadwaj B S Fluent UDF and Scheme Programming 31 March 9, 2015 07:32
fluent udf problem: write specific data for every iteration in a file. nnvoro Fluent UDF and Scheme Programming 1 May 27, 2013 16:26


All times are GMT -4. The time now is 06:19.