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

NV macros

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 20, 2017, 06:53
Question NV macros
  #1
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 9
MayTheFlowBeWithYou is on a distinguished road
Dear CFD-online community,

I am trying to make a UDF for transport of a UDS. I am planning to build this on the following example from the manual (basically I'm trying to add a flux based on the Nernst equation and diffusion to it):

/************************************************** ********************/
/* UDF that implements a simplified advective term in the */
/* scalar transport equation */
/************************************************** ********************/

#include "udf.h"

DEFINE_UDS_FLUX(my_uds_flux,f,t,i)
{
cell_t c0, c1 = -1;
Thread *t0, *t1 = NULL;
real NV_VEC(psi_vec), NV_VEC(A), flux = 0.0;
c0 = F_C0(f,t);
t0 = F_C0_THREAD(f,t);
F_AREA(A, f, t);
/* If face lies at domain boundary, use face values; */
/* If face lies IN the domain, use average of adjacent cells. */
if (BOUNDARY_FACE_THREAD_P(t)) /*Most face values will be available*/
{
real dens;
/* Depending on its BC, density may not be set on face thread*/
if (NNULLP(THREAD_STORAGE(t,SV_DENSITY)))
dens = F_R(f,t); /* Set dens to face value if available */
else
dens = C_R(c0,t0); /* else, set dens to cell value */
NV_DS(psi_vec, =, F_U(f,t), F_V(f,t), F_W(f,t), *, dens);
flux = NV_DOT(psi_vec, A); /* flux through Face */ }
else
{
c1 = F_C1(f,t); /* Get cell on other side of face */
t1 = F_C1_THREAD(f,t);
NV_DS(psi_vec, =, C_U(c0,t0),C_V(c0,t0),C_W(c0,t0),*,C_R(c0,t0));
NV_DS(psi_vec, +=, C_U(c1,t1),C_V(c1,t1),C_W(c1,t1),*,C_R(c1,t1));
flux = NV_DOT(psi_vec, A)/2.0; /* Average flux through face */
}
/* ANSYS Fluent will multiply the returned value by phi_f (the scalar’s
value at the face) to get the ‘‘complete’’ advective term. */
return flux;
}

The thing about this example is that it uses the macro "NV_DS" which is not explained in the manual (the manual talks about ("NV_V", "NV_VV", "NV_V_VS" and "NV_VS_VS").

If I look at, for example:
NV_DS(psi_vec, =, C_U(c0,t0),C_V(c0,t0),C_W(c0,t0),*,C_R(c0,t0));
It is pretty obvious that it want to take the velocity in each direction for each adjacent cell and multiply by the density in that cell.

The question however is that, according to the manual chapter 3.4.3. "The NV Macros", the correct way to do this would be:
NV_VV(psi_vec, =, C_U(c0,t0),C_V(c0,t0),C_W(c0,t0),*,C_R(c0,t0));

So, what is the difference between NV_DS and NV_VV?

Additionally, Does this "DEFINE_UDS_FLUX(my_uds_flux,f,t,i)" loop over faces of over cells?

If it loops over cells, then what does "adjacent cell" mean? in a 3D space there would be 6 adjacent cells, does it automatically take the adjacent in the x,y,z-direction correctly for positions 0,1,2 in the vector?
MayTheFlowBeWithYou is offline   Reply With Quote

Reply

Tags
nv macros, nv_ds


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
Flow Variable Macros in UDF to return CFL in the cell bobinson Fluent UDF and Scheme Programming 0 May 11, 2017 14:56
particle data macros hwet Fluent UDF and Scheme Programming 1 February 22, 2016 01:11
Tecplot360 - Macros calling Macros? eRzBeNgEl CFX 1 April 15, 2011 07:32
What are UDF macros C_T_S , C_T_AP,...???? Asghari FLUENT 0 January 28, 2007 11:54
Orientation of Face Variable Macros hirokata FLUENT 0 February 17, 2006 01:12


All times are GMT -4. The time now is 18:39.