|
[Sponsors] |
July 16, 2012, 13:12 |
Restricting area in if statement
|
#1 |
New Member
Bradley J
Join Date: Jul 2012
Location: Cincinnati, OH
Posts: 12
Rep Power: 14 |
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 18:14. Reason: Updated code |
|
July 18, 2012, 02:48 |
|
#2 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,428
Rep Power: 49 |
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, 14:42 |
|
#3 | |
New Member
Bradley J
Join Date: Jul 2012
Location: Cincinnati, OH
Posts: 12
Rep Power: 14 |
Quote:
|
||
July 22, 2012, 16:32 |
|
#4 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,428
Rep Power: 49 |
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, 17:50 |
|
#5 | |
New Member
Bradley J
Join Date: Jul 2012
Location: Cincinnati, OH
Posts: 12
Rep Power: 14 |
Quote:
# 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; Thread *t *t0, *ct; 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 vof_gradient; 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*/ thread_loop_c(ct,d) { begin_c_loop(c,ct) { C_UDMI(c,t,1) = 0; /*fills the UDM with 0*/ } end_c_loop(c,ct) } thread_loop_f(ct,d) { /*loops over all faces on the base wall in the liquid domain*/ t = Lookup_Thread(d, Zone_ID); begin_f_loop(f,t) { /*c0 and t0 identify the adjacent cell*/ c0 = F_C0(f,t); t0 = THREAD_T0(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);*/ vof_gradient = C_UDMI(c,t,0); /*DEFINE_EXECUTE_AT_END(grad_vof): 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 { st = -(2*vof*vof_gradient*m_flux); /*negative sign because mass is leaving the liquid domain*/ C_UDMI(c0,t0,1) = st; } } end_f_loop(f,t) } #endif } |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Non overlap area fractions | saisanthoshm88 | CFX | 13 | December 11, 2024 17:03 |
Problem with reference area | alfaben | STAR-CCM+ | 3 | April 21, 2020 10:46 |
Water subcooled boiling | Attesz | CFX | 7 | January 5, 2013 04:32 |
CFX Solver Memory Error | mike | CFX | 1 | March 19, 2008 08:22 |
Storing Surface Area of each cell in a file? | Markus Alzon | FLUENT | 0 | June 21, 2007 09:38 |