|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
lili
Join Date: May 2019
Posts: 12
Rep Power: 7 ![]() |
Hi, I'd like to get mass fraction data and store UDM at the end of tilmestep.
I tried calculation with UDF that can execute value at the end of tilmestep but it doesn't work and i get segmentation error. My UDF is here, #include "udf.h" #include "sg_pdf.h" #include "pdf_props.h" DEFINE_EXECUTE_AT_END(mass_fraction) { Domain *d; Thread *t; cell_t c; d = Get_Domain(1); real mass; thread_loop_c(t,d) { begin_c_loop(c, t) { mass = Pdf_Yi(c, t, 54); /*54 is an index of species i want to get value */ C_UDMI(c, t, 0) = mass; Message("mf = %g\n", mass); } end_c_loop(c,t) } } my calculation model has both solid zone and fluid zone. Addition to that, I use an Chemkin as a species model. I also tried to change Pdf_Yi(cat,54) into C_YI(c,t,54) but it also didn't work. Do you know if there are some problems in my UDF or not, how to use C_YI or Pdf_Yi macros, or the other ways to get mass fraction value at the end of tilmestep without these macros. regards |
|
![]() |
![]() |
![]() |
![]() |
#2 |
New Member
Sai Likitha Siddanathi
Join Date: Aug 2019
Posts: 1
Rep Power: 0 ![]() |
In most of the cases while we use UDM we need to allocate the memory first.
It can be done it 2 ways : 1. by setting the parameters /solve/set/expert in the fluent TUI. 2. Or by allocating the variables using Alloc_Storage_Vars(domain, SV_*_RG, SV_*_G, SV_NULL) macro. In most of the cases the 2nd method is advisable while using UDF. So try allocating memory and let me know if you still face the problem. |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 ![]() ![]() |
when did you get segmentation error,
if on initialization: user-defined -> memory -> udm locations 1 best regards |
|
![]() |
![]() |
![]() |
![]() |
#4 | |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 ![]() |
Quote:
what is the argument should be put in * in SV_*_G for mass fraction? |
||
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
|
It is Y and since there are multiple components, an additional argument is required; so it written as
SV_Y_G, 0 for first component
__________________
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. |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 ![]() |
||
![]() |
![]() |
![]() |
![]() |
#7 |
Senior Member
|
Look at the source listing in your installation
./ansys_inc/vXXX/fluent/fluentXX.Y.Z/src
__________________
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. |
|
![]() |
![]() |
![]() |
![]() |
#8 |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 ![]() |
||
![]() |
![]() |
![]() |
![]() |
#9 |
Senior Member
|
Location varies from computer to computer. You have to find where Ansys products are installed in your computer. I have given the path further from there. If it is Windows, then most likely in Program Files. If it is Linux then it could be anywhere. Just type command
Code:
which fluent
__________________
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. |
|
![]() |
![]() |
![]() |
![]() |
#10 | |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 ![]() |
Quote:
thank you so much |
||
![]() |
![]() |
![]() |
![]() |
#11 | |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 ![]() |
Quote:
this is my code to storing volume fraction and mass fraction gradient in DEFINE_ADJUST is it right?? thanks a lot 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,0, SV_Y_G,0, SV_NULL); //Yi_derivatives(domain); Free_Storage_Vars(domain, SV_Y_RG,0, 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_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]); } 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,0, SV_NULL); //Message("C_UDMI(cell,mix_air,0) = %g\n",C_UDMI(c,t,0)); } i dont know is the YI_derivatives right or mistake |
||
![]() |
![]() |
![]() |
![]() |
#12 |
Senior Member
|
Allocation and reconstruction is available on domain. So, use
Alloc...(domain instead of Alloc...(pDomain Do not use braces unnecessarily; will make code ambiguous. Use Free command only if Alloc has been used.
__________________
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. |
|
![]() |
![]() |
![]() |
![]() |
#13 | |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 ![]() |
Quote:
IS the Yi_derivatives right?? is there any problem in code? |
||
![]() |
![]() |
![]() |
![]() |
#14 |
Senior Member
|
Well, those ones appear to be alright to me. You can confirm by plotting their contours. To be able to do that, you have to issue the following command and then run at least 1 iteration
solve set expert and then select yes to the question about Keeping Memory from being freed.
__________________
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. |
|
![]() |
![]() |
![]() |
![]() |
#15 |
Senior Member
|
Do you mean the literal Yi_derivatives command? There is no such command in Fluent.
__________________
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. |
|
![]() |
![]() |
![]() |
![]() |
#16 | |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 ![]() |
Quote:
but code can't access to mass fraction gradient and will appear error in iteration1. |
||
![]() |
![]() |
![]() |
![]() |
#17 |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 ![]() |
||
![]() |
![]() |
![]() |
![]() |
#18 |
Senior Member
|
Post the modified code. Do note that Fluent does not accept // as argument. Change those to /* */.
__________________
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. |
|
![]() |
![]() |
![]() |
![]() |
#19 |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 ![]() |
||
![]() |
![]() |
![]() |
![]() |
#20 |
Senior Member
|
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.
__________________
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. |
|
![]() |
![]() |
![]() |
Tags |
macros, segmentation error, udf |
|
|
![]() |
||||
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 |