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

How to get data of mass fraction in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 29, 2020, 08:11
Default
  #21
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
T_derivatives function is declared in pbns/sg.h, however, I do not think that it is relevant for you. You need to fetch gradients of mass fractions of species. That is accessible via C_YI_G or as stated earlier, using SV_Y_G, 0.

What error do you get if you use either C_YI_G or SV_Y_G? I would recommend the former since that is an easy wrapper for users.
this is modification code


DEFINE_ADJUST(gradient, domain)
{
Thread *t;
Thread **pt;
cell_t c;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,P_PHASE);
real voidx, voidy, voidz=0.0;
{
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);
}
{
Alloc_Storage_Vars(domain, SV_Y_RG, SV_Y_G, SV_NULL);
//Y_derivatives(domain);
Free_Storage_Vars(domain, SV_Y_RG, SV_NULL);
}
mp_thread_loop_c (t,domain,pt)
if (FLUID_THREAD_P(t))
{
Thread *tp = pt[P_PHASE];
begin_c_loop (c,t)
{
// (C_VOF_G(c,tp)[0]*C_T_G(c,t)[0]+C_VOF_G(c,tp)[1]*C_T_G(c,t)[1]+C_VOF_G(c,tp)[2]*C_T_G(c,t)[2]);
C_UDMI(c,t,0) = (C_VOF_G(c,tp)[0]*C_YI_G(c,tp,0)[0] + C_VOF_G(c,tp)[1]*C_YI_G(c,tp,0)[1] + C_VOF_G(c,tp)[2]*C_YI_G(c,tp,0)[2]);
}
end_c_loop (c,t)
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL);
Free_Storage_Vars(domain, SV_Y_G, SV_NULL);
//Message("C_UDMI(cell,mix_air,0) = %g\n",C_UDMI(c,t,0));
}



without error and successful initializing but
when i running, appear this message 'the f1 process could not be started' and automatically FLUENT closed.
mahdi-united is offline   Reply With Quote

Old   February 29, 2020, 08:17
Default
  #22
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
T_derivatives function is declared in pbns/sg.h, however, I do not think that it is relevant for you. You need to fetch gradients of mass fractions of species. That is accessible via C_YI_G or as stated earlier, using SV_Y_G, 0.

What error do you get if you use either C_YI_G or SV_Y_G? I would recommend the former since that is an easy wrapper for users.
this is modified code


DEFINE_ADJUST(gradient, domain)
{
Thread *t;
Thread **pt;
cell_t c;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,P_PHASE);
real voidx, voidy, voidz=0.0;
{
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);
}
{
Alloc_Storage_Vars(domain, SV_Y_RG, SV_Y_G, SV_NULL);
//Y_derivatives(domain);
Free_Storage_Vars(domain, SV_Y_RG, SV_NULL);
}
mp_thread_loop_c (t,domain,pt)
if (FLUID_THREAD_P(t))
{
Thread *tp = pt[P_PHASE];
begin_c_loop (c,t)
{
// (C_VOF_G(c,tp)[0]*C_T_G(c,t)[0]+C_VOF_G(c,tp)[1]*C_T_G(c,t)[1]+C_VOF_G(c,tp)[2]*C_T_G(c,t)[2]);
C_UDMI(c,t,0) = (C_VOF_G(c,tp)[0]*C_YI_G(c,tp,0)[0] + C_VOF_G(c,tp)[1]*C_YI_G(c,tp,0)[1] + C_VOF_G(c,tp)[2]*C_YI_G(c,tp,0)[2]);
}
end_c_loop (c,t)
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL);
Free_Storage_Vars(domain, SV_Y_G, SV_NULL);
//Message("C_UDMI(cell,mix_air,0) = %g\n",C_UDMI(c,t,0));
}


without error and successful initializing
but when i running appear this message
'the f1 process could not be started ' and automatically fluent closed
mahdi-united is offline   Reply With Quote

Old   February 29, 2020, 09:13
Default
  #23
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
T_derivatives function is declared in pbns/sg.h, however, I do not think that it is relevant for you. You need to fetch gradients of mass fractions of species. That is accessible via C_YI_G or as stated earlier, using SV_Y_G, 0.

What error do you get if you use either C_YI_G or SV_Y_G? I would recommend the former since that is an easy wrapper for users.
this is modification code


DEFINE_ADJUST(gradient, domain)
{
Thread *t;
Thread **pt;
cell_t c;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,P_PHASE);
real voidx, voidy, voidz=0.0;
{
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);
}
{
Alloc_Storage_Vars(domain, SV_Y_RG, SV_Y_G, SV_NULL);
//Y_derivatives(domain);
Free_Storage_Vars(domain, SV_Y_RG, SV_NULL);
}
mp_thread_loop_c (t,domain,pt)
if (FLUID_THREAD_P(t))
{
Thread *tp = pt[P_PHASE];
begin_c_loop (c,t)
{
// (C_VOF_G(c,tp)[0]*C_T_G(c,t)[0]+C_VOF_G(c,tp)[1]*C_T_G(c,t)[1]+C_VOF_G(c,tp)[2]*C_T_G(c,t)[2]);
C_UDMI(c,t,0) = (C_VOF_G(c,tp)[0]*C_YI_G(c,tp,0)[0] + C_VOF_G(c,tp)[1]*C_YI_G(c,tp,0)[1] + C_VOF_G(c,tp)[2]*C_YI_G(c,tp,0)[2]);
}
end_c_loop (c,t)
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL);
Free_Storage_Vars(domain, SV_Y_G, SV_NULL);
//Message("C_UDMI(cell,mix_air,0) = %g\n",C_UDMI(c,t,0));
}



without error and successful initializing but
when i running, appear this message 'the f1 process could not be started' and automatically FLUENT closed.
mahdi-united is offline   Reply With Quote

Old   February 29, 2020, 09:20
Default Solver
  #24
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Are you using pressure based solver or density based? If it is pressure based, then you need to tell Fluent to specifically save gradients using the following command

(rpsetvar 'species/save-gradients? #t)

before using the UDF.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 29, 2020, 09:35
Default
  #25
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Are you using pressure based solver or density based? If it is pressure based, then you need to tell Fluent to specifically save gradients using the following command

(rpsetvar 'species/save-gradients? #t)

before using the UDF.
thanks for helping


what is the answer for question 'species/save-gradients?'?
mahdi-united is offline   Reply With Quote

Old   February 29, 2020, 09:49
Default true
  #26
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
It's not a question, rather a boolean. And the Vale is already given in my post as #t.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 29, 2020, 09:59
Default
  #27
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
It's not a question, rather a boolean. And the Vale is already given in my post as #t.
when i write the #t for answering
appear message "invalid command"
mahdi-united is offline   Reply With Quote

Old   February 29, 2020, 10:44
Default
  #28
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Are you using pressure based solver or density based? If it is pressure based, then you need to tell Fluent to specifically save gradients using the following command

(rpsetvar 'species/save-gradients? #t)

before using the UDF.
when i using this message

appear message: Error: eval: unbound variable Error Object: args
mahdi-united is offline   Reply With Quote

Old   February 29, 2020, 11:10
Default rpvar
  #29
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Whole of this command need to be given in one go, along with the parentheses.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 29, 2020, 11:15
Default
  #30
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Whole of this command need to be given in one go, along with the parentheses.
is this message important when udf compiling?


""INFO from activate-context: context VOF: Implicit and Steady State not yet defined.
mahdi-united is offline   Reply With Quote

Old   February 29, 2020, 11:20
Default
  #31
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Whole of this command need to be given in one go, along with the parentheses.
OMG i'm very tired

this command"(rpsetvar 'species/save-gradients? #t)" is ok
but still appear the message "the f1 process could not be started" and automatically FLUENT closed.
mahdi-united is offline   Reply With Quote

Old   February 29, 2020, 11:39
Default Issue
  #32
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Then possibly the issue is not with UDF. Does the case run without the UDF?

And are there still comments starting with // instead of contained in /* */? If yes, then you should either remove those comments or put those in /* */.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 29, 2020, 11:53
Default
  #33
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Then possibly the issue is not with UDF. Does the case run without the UDF?

And are there still comments starting with // instead of contained in /* */? If yes, then you should either remove those comments or put those in /* */.
dear friend thanks a lot for helping



DEFINE_ADJUST(gradient, domain)
{
Thread *t;
Thread **pt;
cell_t c;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,P_PHASE);
real voidx, voidy, voidz=0.0;
{
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);
}
{
Alloc_Storage_Vars(domain, SV_Y_RG, SV_Y_G, SV_NULL);
Free_Storage_Vars(domain, SV_Y_RG, SV_NULL);
}
mp_thread_loop_c (t,domain,pt)
if (FLUID_THREAD_P(t))
{
Thread *tp = pt[P_PHASE];
begin_c_loop (c,t)
{

C_UDMI(c,t,0) = (C_VOF_G(c,tp)[0]*C_YI_G(c,tp,0)[0] + C_VOF_G(c,tp)[1]*C_YI_G(c,tp,0)[1] + C_VOF_G(c,tp)[2]*C_YI_G(c,tp,0)[2]);
}
end_c_loop (c,t)
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL);
Free_Storage_Vars(domain, SV_Y_G, SV_NULL);

}

unfortunately still there is error
i think error coming from line "T_derivatives" that should be reform to mass fraction command
mahdi-united is offline   Reply With Quote

Old   February 29, 2020, 12:08
Default T_derivatives
  #34
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Well, you have nothing to lose by trying T_derivatives in your code.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 6, 2020, 05:03
Default
  #35
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Well, you have nothing to lose by trying T_derivatives in your code.
hi

do you know meaning of "-1" in command:
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG,Vof_Deriv_Accumulate);
mahdi-united is offline   Reply With Quote

Old   March 6, 2020, 05:15
Default
  #36
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
probably it is Index that identifies the user-defined scalar,
however, index must be > -1, so I could be wrong
__________________
best regards


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

Old   March 6, 2020, 05:20
Default
  #37
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
probably it is Index that identifies the user-defined scalar,
however, index must be > -1, so I could be wrong
thanks for helping
how to change this section :
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);


for accessing the mass fraction gradients?
mahdi-united is offline   Reply With Quote

Old   March 6, 2020, 05:24
Default
  #38
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
probably it is Index that identifies the user-defined scalar,
however, index must be > -1, so I could be wrong
and another question
is there identical command "Vector_Derivatives(pDomain,SV_Y,0,SV_Y_G,0,SV_Y_R G,0,yi_derivatives)"

in udf?
mahdi-united is offline   Reply With Quote

Old   March 6, 2020, 07:10
Default Explanation
  #39
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
-1 is actually SV_NULL and is a variable attribute defined in Fluent's variable structure. Anything more than that would be a goose chase.

For mass fractions, use Y in place of VOF. Vof_Deriv_Accumulate is to be replaced with NULL.

Yes, Vector_Derivatives, Vector_Reconstructionn, as well as Vector_Gradient_Reconstruction exist. This is when user wants a gradient but not spatial.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 6, 2020, 07:57
Default
  #40
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
Quote:
Originally Posted by vinerm View Post
-1 is actually SV_NULL and is a variable attribute defined in Fluent's variable structure. Anything more than that would be a goose chase.

For mass fractions, use Y in place of VOF. Vof_Deriv_Accumulate is to be replaced with NULL.

Yes, Vector_Derivatives, Vector_Reconstructionn, as well as Vector_Gradient_Reconstruction exist. This is when user wants a gradient but not spatial.
thanks for responding
do i should write the commands :

"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);"


for mass fraction gradients?(modify ocde by replacing VOF with Y and etc)
mahdi-united is offline   Reply With Quote

Reply

Tags
macros, segmentation error, udf


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
mass fraction of species Lilly FLUENT 5 March 13, 2022 17:52
CFD by anderson, chp 10.... supersonic flow over flat plate varunjain89 Main CFD Forum 18 May 11, 2018 07:31
Accessing the species mass fraction for particles data in UDF mac_09 FLUENT 17 August 9, 2017 20:15
Define mass flow profile with regards to species mass fraction danS Fluent UDF and Scheme Programming 0 June 20, 2017 06:21
Water subcooled boiling Attesz CFX 7 January 5, 2013 03:32


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