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

Gradient of UDS is zero while UDS has non-zero values

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 21, 2021, 21:36
Post Gradient of UDS is zero while UDS has non-zero values
  #1
New Member
 
YF
Join Date: Sep 2016
Posts: 5
Rep Power: 10
foolfishzju is on a distinguished road
Hi everyone,

I would like to get the gradient of species mass concentration to compute the mass transfer coefficient based on Fick's law. The code runs in parallel mode.

I am stuck with the issue of getting zero gradients of UDS. But when I check the value of UDS, there are non-zero values.

My UDF code is as below,

----------------------------------------------------------------------------------

#include "udf.h"

DEFINE_ADJUST(spec_interf_concen,mixture_domain)
{

#if !RP_HOST

int liq_phase_id = 0;
int gas_phase_id = 1;
int co2_species_id = 0;
int yi = 0;

......

Domain *pDomain = DOMAIN_SUB_DOMAIN(mixture_domain,gas_phase_id);
{

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(mix_thread, mixture_domain, pt)
{

if (FLUID_THREAD_P(mix_thread))
{

begin_c_loop(c,mix_thread)
{

liq_thread = THREAD_SUB_THREAD(mix_thread,liq_phase_id);
gas_thread = THREAD_SUB_THREAD(mix_thread,gas_phase_id);

......

C_UDSI(c,pt[liq_phase_id],yi) = C_YI(c,pt[liq_phase_id],co2_species_id);

if((vof_l_c > 1e-6)&&(vof_l_c < 0.999999))
{
ca = press/KH_px*rho_l/Ml*vof_l_c;
C_UDSI(c,pt[liq_phase_id],yi) = ca*Mg/(ca*Mg+rho_l*vof_l_c);
}

......

}
end_c_loop_int(c,mix_thread)

}

}

/* Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL); */

#endif

}


DEFINE_LINEARIZED_MASS_TRANSFER(surface_renewal, c, mixture_thread, from_phase_index, from_species_index, to_phase_index, to_species_index, lin_from, lin_to)
{

Thread *liq;
Thread **pt;

int liquid_species_id = 0;
int gas_phase_ID = 1;
int co2_species_id = 0;
int yi = 0;

......

real rho_l, rho_g, r_rho_lg;
real cg_G[3];

liq = THREAD_SUB_THREAD(mixture_thread, to_phase_index);
pt = THREAD_SUB_THREADS(mixture_thread);

rho_l = C_R(c,liq);
rho_g = C_R(c,pt[gas_phase_ID]);

vof_l = C_VOF(c,liq);
vof_g = C_VOF(c,pt[gas_phase_ID]);

if (NULL != THREAD_STORAGE(liq,SV_UDSI_G(yi)))
{

/* gradient of species mass concentration */
NV_V(cg_G,=,C_UDSI_G(c,liq,yi));
Message("Magnitude of species mass concentration: %f \n",NV_MAG(cg_G));

}
else
{

NV_S(cg_G,=,0.0);

}

......

return m_source;

}

----------------------------------------------------------------------------------

Moreover, I did the following setup to keep the memory from freeing:
/solve/set/expert

but the TUI shows the option is incompatible with the adaption in parallel. I wonder whether this option will affect the value of UDS gradient.
__________________
Yuan Fang
foolfishzju is offline   Reply With Quote

Old   November 23, 2021, 00:06
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
manual
Quote:
the solver continually removes data from memory that it does not need. In order to retain the
gradient data (when you want to set up user-defined scalar transport equations, for example), you can
prevent the solver from freeing up memory by issuing the text command solve/set/expert and
then answering yes to the question, “Keep temporary solver memory from being freed?”
Note that when you do this, all of the gradient data is retained, but the calculation requires more
memory to run.
so looks like you can't access gradient data without this setting
__________________
best regards


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

Old   November 23, 2021, 20:55
Default
  #3
New Member
 
YF
Join Date: Sep 2016
Posts: 5
Rep Power: 10
foolfishzju is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
manual


so looks like you can't access gradient data without this setting
Hi Alexander,

Do you know how to fix this issue?

I found a similar topic in Ansys forum:
https://forum.ansys.com/discussion/1...on-not-only-in

A coordinator mentioned that there is an unofficial method retrieving the gradient values, but he did not give the solution.
foolfishzju is offline   Reply With Quote

Old   November 24, 2021, 04:41
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
unofficial way is to use reconstruction gradient macros, which you are using already

Code:
 Alloc_Storage_Vars(...)
 Scalar_Reconstruction(...)
 Scalar_Derivatives(...)
 Free_Storage_Vars(...)
you may check if memory for temperature gradient is allocated or not using following code
Code:
thread_loop_c(t, d)
 {
 if (!SV_ALLOCATED_P(t, SV_T)) {
 Message("Energy Equation not active in zone %d on compute
 node %d\n", THREAD_ID(t), myid);
 } else {
 Message("Energy Equation active in zone %d on compute node
 %d\n", THREAD_ID(t), myid);
 }
__________________
best regards


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

Reply

Tags
mass fraction (y), uds gradient of scalar, zero gradient


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
reconstruct gradient of UDS loving_cfd FLUENT 10 May 18, 2020 09:39
temperature gradient source term in uds cfd_mech FLUENT 0 July 27, 2014 05:55
non-exact gradient values elisabet OpenFOAM Programming & Development 3 July 18, 2012 08:45
reconstruction gradient of a UDS gemini Fluent UDF and Scheme Programming 0 June 7, 2009 17:03
Gradient UDS tom FLUENT 1 April 28, 2006 04:46


All times are GMT -4. The time now is 21:40.