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 store y-direction gradient using UDS

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 2, 2015, 03:23
Default How to store y-direction gradient using UDS
  #1
New Member
 
AaronSyu
Join Date: May 2015
Posts: 13
Rep Power: 10
aronsyu is on a distinguished road
Hello every one

I tried to store y-direction gradient using UDS but fail.

when I interpreted UDF , fluent returns an error message

"Error: C:/Users/USER/AppData/Local/Temp/12_2.c.5332.6.c: line 81: subscripted expression is not an array or pointer: float."

Thanks for your help, I am much obliged to you.



Here is the part of my UDF code below , if I delete line 81, then every goes perfect.

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

DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;
domain = Get_Domain(domain_ID);
/* Fill UDS with the variable. */

thread_loop_c (t,domain)
{
begin_c_loop (c,t)

{
C_UDSI(c,t,0) = C_VOF(c,t);
}

end_c_loop (c,t)
}


thread_loop_f (t,domain)
{
if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
begin_f_loop (f,t)

{
F_UDSI(f,t,0) = F_VOF(f,t);
}

end_f_loop (f,t)
}
}

DEFINE_ON_DEMAND(store_gradient)
{
Domain *domain;
cell_t c;
Thread *t;
domain=Get_Domain(1); /* Fill the UDM with magnitude of gradient. */

thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,gvof) = NV_MAG(C_UDSI_G(c,t,0));
C_UDMI(c,t,ygvof) = NV_MAG(C_UDSI_G(c,t,0)[1]);
/* here is line 81 */

/* I chenged line 81 like "C_UDMI(c,t,ygvof) = C_UDSI_G(c,t,0)[1];"*/
/* and interpreted success but after I Execute on Demand, fluent returns a MPI error message*/

}
end_c_loop (c,t)
}
}

---------------------------------
aronsyu is offline   Reply With Quote

Old   December 2, 2015, 06:46
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
C_UDMI(c,t,ygvof) = NV_MAG(C_UDSI_G(c,t,0)[1]);

This line gives you the magnitude of the gradient in Y direction, which does not make much sense. If you want the gradient in Y direction, use

C_UDMI(c,t,ygvof) = C_UDSI_G(c,t,0)[1];
Bruno Machado is offline   Reply With Quote

Old   December 2, 2015, 08:26
Default
  #3
New Member
 
AaronSyu
Join Date: May 2015
Posts: 13
Rep Power: 10
aronsyu is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
C_UDMI(c,t,ygvof) = NV_MAG(C_UDSI_G(c,t,0)[1]);

This line gives you the magnitude of the gradient in Y direction, which does not make much sense. If you want the gradient in Y direction, use

C_UDMI(c,t,ygvof) = C_UDSI_G(c,t,0)[1];

Thank you ,

When I changed

C_UDMI(c,t,ygvof) =NV_MAG( C_UDSI_G(c,t,0)[1]);

to

C_UDMI(c,t,ygvof) = C_UDSI_G(c,t,0)[1];

fluent returns MPI error message

I really don't know what's wrong with my UDF code....
aronsyu is offline   Reply With Quote

Old   December 2, 2015, 08:36
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Try to compile. Compiling is 100 times better than interpreting.
pakk is offline   Reply With Quote

Old   December 18, 2015, 07:06
Default
  #5
New Member
 
AaronSyu
Join Date: May 2015
Posts: 13
Rep Power: 10
aronsyu is on a distinguished road
Thank you, but compile/interpreted won't bring this problem.
aronsyu is offline   Reply With Quote

Old   December 18, 2015, 07:10
Default
  #6
New Member
 
AaronSyu
Join Date: May 2015
Posts: 13
Rep Power: 10
aronsyu is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
C_UDMI(c,t,ygvof) = NV_MAG(C_UDSI_G(c,t,0)[1]);

This line gives you the magnitude of the gradient in Y direction, which does not make much sense. If you want the gradient in Y direction, use

C_UDMI(c,t,ygvof) = C_UDSI_G(c,t,0)[1];
I solve this problem finally.

The problem happened cause I FORGOT RETURN MY CALCULATION
aronsyu is offline   Reply With Quote

Reply


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
Question about C_UDMI and F_UDMI and How to define the gradient of a UDM? aestas Fluent UDF and Scheme Programming 4 May 14, 2018 10:50
question regarding LES of pipe flow - pimpleFoam Dan1788 OpenFOAM Running, Solving & CFD 37 December 26, 2017 14:42
Gradient Computation: finite differences and adjoint method doan.nak SU2 3 November 22, 2017 05:37
[General] Problem in calculating Gradient masaaki ParaView 0 March 16, 2015 06:38
Doubts UDS Flux, UDS Unsteady for VOF model kel85uk FLUENT 0 March 17, 2010 08:53


All times are GMT -4. The time now is 01:05.