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   March 6, 2020, 09:06
Default SV_Y_G and C_YI_G
  #41
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Yes, you have to write it as SV_Y_G but while accessing a cell value, it has to be C_YI_G.
__________________
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, 09:18
Default
  #42
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
Yes, you have to write it as SV_Y_G but while accessing a cell value, it has to be C_YI_G.
does this section"Alloc_Storage_Vars(domain, SV_Y_RG, SV_Y_G, SV_NULL);
yi_derivatives(domain,0);
Free_Storage_Vars(domain, SV_Y_RG, SV_NULL);"
should be exist too??
mahdi-united is offline   Reply With Quote

Old   March 6, 2020, 09:24
Default Sequence of commands
  #43
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
If you do that then Alloc_... comes twice, which is not required. Yes, Free_... for RG is alright.
__________________
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, 09:31
Default
  #44
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
If you do that then Alloc_... comes twice, which is not required. Yes, Free_... for RG is alright.
dear friend

please modify my code. i'm confused very much

please help


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(pDomain,SV_Y_RG,SV_Y_G,SV_NULL) ;
Scalar_Reconstruction(pDomain, SV_Y,-1,SV_Y_RG,NULL);
Scalar_Derivatives(pDomain,SV_Y,-1,SV_Y_G,SV_Y_RG,NULL);
}
{

Alloc_Storage_Vars(domain, SV_Y_RG, SV_Y_G, SV_NULL);
yi_derivatives(domain,0);
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)
{
#if RP_3D
/*(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_YI_G(c,tp,0)[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]);
#endif
}
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);

}

thanks a lot
mahdi-united is offline   Reply With Quote

Old   March 6, 2020, 09:44
Default Code
  #45
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
The reality is as follows. If you use the command stated earlier,

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

then you do not need any of these function. C_YI_G are directly available. So, you should remove all functions such as Alloc_, Scalar_, Free_, and yi_derivates. Rest should work as it is.
__________________
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, 10:07
Default
  #46
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
The reality is as follows. If you use the command stated earlier,

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

then you do not need any of these function. C_YI_G are directly available. So, you should remove all functions such as Alloc_, Scalar_, Free_, and yi_derivates. Rest should work as it is.
i eliminate those commands and write this"(rpsetvar 'species/save-gradients? #t)"
in TUI

and run but earlier 1st iteration appear message "the f1 process couldnot be started"
and fluent closed
mahdi-united is offline   Reply With Quote

Old   March 6, 2020, 10:42
Default Modified Code
  #47
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Paste the modified code here. Do note that my previous suggestion will work as long as you are trying to access only mass fraction gradient. If you also want volume fraction gradient, then it has to be modified. But better to take one step at a time.
__________________
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, 11:03
Default
  #48
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
Paste the modified code here. Do note that my previous suggestion will work as long as you are trying to access only mass fraction gradient. If you also want volume fraction gradient, then it has to be modified. But better to take one step at a time.
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);
}



mp_thread_loop_c (t,domain,pt)
if (FLUID_THREAD_P(t))
{
Thread *tp = pt[P_PHASE];
begin_c_loop (c,t)
{
#if RP_3D

C_UDMI(c,t,0) = C_YI_G(c,tp,0)[0];
#endif
}
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);

}
mahdi-united is offline   Reply With Quote

Old   March 6, 2020, 11:29
Default Code - Modified
  #49
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Try this one. Ensure to give the rp command before using it. And it must be compiled not Interpreted. Ensure that you have at least one UDM assigned and patched with 0 values before using this UDF.

Code:
DEFINE_ADJUST(mfgradient, domain)
{
  Thread *t;
  Thread **pt;
  cell_t c;

  mp_thread_loop_c (t,domain,pt)
  {
    if (FLUID_THREAD_P(t) && n_udm > 0)
    {
      begin_c_loop (c,t)
      {
         C_UDMI(c,t,0) = C_YI_G(c,pt[P_PHASE],0)[0];
      }
      end_c_loop (c,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   March 6, 2020, 11:56
Default
  #50
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
Try this one. Ensure to give the rp command before using it. And it must be compiled not Interpreted. Ensure that you have at least one UDM assigned and patched with 0 values before using this UDF.

Code:
DEFINE_ADJUST(mfgradient, domain)
{
  Thread *t;
  Thread **pt;
  cell_t c;

  mp_thread_loop_c (t,domain,pt)
  {
    if (FLUID_THREAD_P(t) && n_udm > 0)
    {
      begin_c_loop (c,t)
      {
         C_UDMI(c,t,0) = C_YI_G(c,pt[P_PHASE],0)[0];
      }
      end_c_loop (c,t)
    }
  }
}
unfortunately

fluent closed
mahdi-united is offline   Reply With Quote

Old   March 6, 2020, 12:04
Default Confirmation
  #51
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Just to confirm, does your case have following characteristics?

1. Multiphase
2. Primary phase with at least two species

If not, then the UDF will not work.
__________________
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, 12:06
Default
  #52
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
Just to confirm, does your case have following characteristics?

1. Multiphase
2. Primary phase with at least two species

If not, then the UDF will not work.
yes multiphase vof model

primary is mix-air with two species
secendary is water with one species
mahdi-united is offline   Reply With Quote

Old   March 6, 2020, 12:12
Default Good
  #53
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Well, then it is weird. If you use the rp command and then check in Contours, do you see gradients for mass fraction and volume fraction? For volume fraction you have to give TUI so that Fluent keeps the memory from being freed. If you do not have gradients available in Contour plots, then there is some issue with the setup
__________________
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, 12:45
Default
  #54
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, then it is weird. If you use the rp command and then check in Contours, do you see gradients for mass fraction and volume fraction? For volume fraction you have to give TUI so that Fluent keeps the memory from being freed. If you do not have gradients available in Contour plots, then there is some issue with the setup
thank you so much
mahdi-united is offline   Reply With Quote

Old   March 7, 2020, 17:38
Default Code
  #55
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
I checked it at my end and the code works perfectly good. Could you share the output of compilation, i.e., the output shown by Fluent when you click on Build?
__________________
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 8, 2020, 07:09
Default
  #56
Senior Member
 
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6
mahdi-united is on a distinguished road
hi how are you today


Copied F:\Cooling Tower\mass-transfer\mass-transfer_files\dp0\FFF-1\Fluent/F:\Cooling Tower\mass-transfer\mass-transfer_files\dp0\FFF-1\Fluent\TOTAL-VOF2.c to F:\Cooling Tower\mass-transfer\mass-transfer_files\dp0\FFF-1\Fluent\libudf\src udf_names.c and user_nt.udf files in 3ddp_host are upto date.
(system "copy "D:\ANSYS Inc\v195\fluent"\fluent19.5.0\src\udf\makefile_nt. udf "F:\Cooling Tower\mass-transfer\mass-transfer_files\dp0\FFF-1\Fluent\libudf\win64\3ddp_host\makefile" ")
1 file(s) copied.
(chdir "F:\Cooling Tower\mass-transfer\mass-transfer_files\dp0\FFF-1\Fluent\libudf")(chdir "win64\3ddp_host")udf_names.c and user_nt.udf files in 3ddp_node are upto date.
(system "copy "D:\ANSYS Inc\v195\fluent"\fluent19.5.0\src\udf\makefile_nt. udf "F:\Cooling Tower\mass-transfer\mass-transfer_files\dp0\FFF-1\Fluent\libudf\win64\3ddp_node\makefile" ")
1 file(s) copied.
(chdir "F:\Cooling Tower\mass-transfer\mass-transfer_files\dp0\FFF-1\Fluent\libudf")(chdir "win64\3ddp_node")
Done.
mahdi-united is offline   Reply With Quote

Old   March 8, 2020, 07:59
Default Compilation
  #57
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
As per this output, there is no compilation of the UDF. You need to compile the UDF outside workbench. And then load it within workbench.
__________________
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 8, 2020, 08:04
Default
  #58
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
As per this output, there is no compilation of the UDF. You need to compile the UDF outside workbench. And then load it within workbench.
how to compile udf outside the workbench?
i compile every udf in workbench always and there is no problem to running
mahdi-united is offline   Reply With Quote

Old   March 8, 2020, 13:33
Default Compilation
  #59
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
It is possible to compile within WB as well, provided the paths for the compiler are correctly set. If the compilation is good, you should be able to find .dll file in the libudf/win64. If it does not exist, then the compilation is not successful. To confirm it, delete the existing libudf directory and compile it again.

And as stated earlier, even without the UDF, but after issuing command
Code:
(rpsetvar 'species/save-gradients? #t)
you should be able to display gradients of species in the Contours. If those are not there, then UDF will not work either.
__________________
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 9, 2020, 10:46
Default
  #60
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 is possible to compile within WB as well, provided the paths for the compiler are correctly set. If the compilation is good, you should be able to find .dll file in the libudf/win64. If it does not exist, then the compilation is not successful. To confirm it, delete the existing libudf directory and compile it again.

And as stated earlier, even without the UDF, but after issuing command
Code:
(rpsetvar 'species/save-gradients? #t)
you should be able to display gradients of species in the Contours. If those are not there, then UDF will not work either.
hi
i run my project without udf and it's running well and the contour of species mass fraction exist. but when i running without udf and writing command "(rpsetvar 'species.....)" before running, appear this message"the f1 process couldnot be started" and FLUENT closed(exactly similar to running with udf)!!!!!
it seams entirely FLUENT don't access to species mass fraction!!!


second, this file (---.dll) exist in libudf folder in path of storing my project
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 18:52
CFD by anderson, chp 10.... supersonic flow over flat plate varunjain89 Main CFD Forum 18 May 11, 2018 08:31
Accessing the species mass fraction for particles data in UDF mac_09 FLUENT 17 August 9, 2017 21:15
Define mass flow profile with regards to species mass fraction danS Fluent UDF and Scheme Programming 0 June 20, 2017 07:21
Water subcooled boiling Attesz CFX 7 January 5, 2013 04:32


All times are GMT -4. The time now is 15:10.