# Restricting area in if statement

 Register Blogs Members List Search Today's Posts Mark Forums Read

 July 16, 2012, 12:12 Restricting area in if statement #1 New Member   Bradley J Join Date: Jul 2012 Location: Cincinnati, OH Posts: 12 Rep Power: 5 Hello, I have a UDF question about restrictions along the x axis. Right now, I have a 10mm by 10mm non uniform rectangular grid with the area of interest square uniform. I am using a source term to model mass transfer from liquid into vapor along the interface. There is a small bubble patch implemented at (10,0), sideways I know. I have set up my code below for you. The problem I am having is how to restrict the source term to be applied only from the (9.5,0) to (10,0) on the grid. There are no restrictions in the y direction. I was thinking of using another if statement involving the x value of centroid being less than 9.5 along with the first if statement. This is what I came up with and I am not sure if I am heading in the right direction. Thank you for your time. Bradley # include"udf.h" # include"mem.h" # include"metric.h" # include"math.h" /*calculating and storing the source term*/ DEFINE_EXECUTE_AT_END(source_memory) { #if !RP_HOST Domain *d; Thread *t; cell_t c; double vof; double vof_gradient; double st; double m_flux = 34.234; /*define mass flux*/ d=Get_Domain(2); /*liquid domain*/ real x[ND_ND]; thread_loop_c (t,d) { begin_c_loop (c,t) { vof = C_UDSI(c,t,0); vof_gradient = C_UDMI(c,t,0); C_CENTROID(x,c,t); if (((vof_gradient < 0.001)||(vof < 0.001)||(vof > 0.999)) && (x[0] < 0.0095)) { C_UDMI(c,t,1) = 0; } else st = -(2*vof*vof_gradient*m_flux); /*negative sign because mass is leaving the liquid domain*/ C_UDMI(c,t,1) = st; } end_c_loop (c,t) } #endif } Last edited by Blackhawks84; July 16, 2012 at 17:14. Reason: Updated code

 July 18, 2012, 01:48 #2 Senior Member     Alex Join Date: Jun 2012 Location: Germany Posts: 1,133 Rep Power: 19 Restricting the area with the if-statement like you did in your code usually works. Just keep in mind that the sources are applied on a "per-cell" base. So if the cell centroid of a cell is within the range you want the source term to be applied, but the cell extents to lets say 0.009, then your results will suffer from this inaccuracy.

July 22, 2012, 13:42
#3
New Member

Join Date: Jul 2012
Location: Cincinnati, OH
Posts: 12
Rep Power: 5
Quote:
 Originally Posted by flotus1 Restricting the area with the if-statement like you did in your code usually works. Just keep in mind that the sources are applied on a "per-cell" base. So if the cell centroid of a cell is within the range you want the source term to be applied, but the cell extents to lets say 0.009, then your results will suffer from this inaccuracy.
thank you for the response. I tried my code and it did not work out as well as planed. Is there a way to only call out an adjacent row of cell centroids along a boundary condition of a wall? Because I want to have two distinct factors for the source term to be applied. I want it to be at the interface and the centroid of the cells adjacent to the wall boundary condition.

 July 22, 2012, 15:32 #4 Senior Member     Alex Join Date: Jun 2012 Location: Germany Posts: 1,133 Rep Power: 19 I am not sure if this is possible. If your mesh is block-structured with a clearly defined cell size, you could easily change the threshold of the if-statement accordingly. With unstructured mesh types, you could perhaps loop over the faces of every cell and check if one of the faces belongs to the boundary. Perhaps you could do this by evaluating the centroid position of the face. Good luck

July 22, 2012, 16:50
#5
New Member

Join Date: Jul 2012
Location: Cincinnati, OH
Posts: 12
Rep Power: 5
Quote:
 Originally Posted by flotus1 I am not sure if this is possible. If your mesh is block-structured with a clearly defined cell size, you could easily change the threshold of the if-statement accordingly. With unstructured mesh types, you could perhaps loop over the faces of every cell and check if one of the faces belongs to the boundary. Perhaps you could do this by evaluating the centroid position of the face. Good luck
thank you for the reply. i have an non uniform structured grid. the new way i am thinking of doing it for a try is to change the loop to over the adjacent cells like this. let me know what you think.

# include"udf.h"
# include"mem.h"
# include"metric.h"
# include"math.h"
/*calculating and storing the source term*/
DEFINE_EXECUTE_AT_END(source_memory)
{
#if !RP_HOST
Domain *d;
face_t f;
cell_t c, c0;
real CC[ND_ND];
/*will be 2D axisymmetric*/
int Zone_ID = 6; /*zone id boundary conditions, 6 = base wall*/
double vof;
double st;
double m_flux = 34.234; /*define mass flux*/
d=Get_Domain(2); /*liquid domain*/
/*initialize cells: loops over all cells in the liquid domain*/
{
begin_c_loop(c,ct)
{
C_UDMI(c,t,1) = 0;
/*fills the UDM with 0*/
}
end_c_loop(c,ct)
}
{
/*loops over all faces on the base wall in the liquid domain*/
begin_f_loop(f,t)
{
/*c0 and t0 identify the adjacent cell*/
c0 = F_C0(f,t);
/*loops over all cells adjacent to wall*/
vof = C_UDSI(c,t,0); /*DEFINE_ADJUST(store_vof,d): C_UDSI(c,t,0) = C_VOF(c,t);*/
C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));*/
if ((vof_gradient < 0.001)||(vof < 0.001)||(vof > 0.999))
{
C_UDMI(c0,t0,1) = 0;
}
else
{
/*negative sign because mass is leaving the liquid domain*/
C_UDMI(c0,t0,1) = st;
}
}
end_f_loop(f,t)
}
#endif
}

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post saisanthoshm88 CFX 11 September 17, 2015 18:42 Attesz CFX 7 January 5, 2013 04:32 alfaben STAR-CCM+ 2 September 17, 2011 03:46 mike CFX 1 March 19, 2008 08:22 Markus Alzon FLUENT 0 June 21, 2007 08:38

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