
[Sponsors] 
June 29, 2010, 15:39 
Setting BC for each cell on face

#1 
New Member
Luk
Join Date: Jun 2009
Posts: 24
Rep Power: 10 
Dear all
I am trying to do something completely new for me, and my UDF skills do not permit me to prepare this. I would be grateful for any help. The problem is to set a BC (mass flow inlet) in that way that each cell would have different magnitude (accordingly to its area) and the sum of it for all cells would be my total mass flow inlet. I have tried to use both C_VOLUME and F_AREA macros but nothing worked. I thought that the result is compared with one of them. My code cannot work unless I fill it with proper macros or function, but put there some of my thoughts how this should work in my opinion. If that changes anything, the case is 3D x,y  horizontal coords zvertical coord Code:
#include "udf.h" DEFINE_PROFILE(xyz, thread, position) { real x[ND_ND]; real A[ND_ND]; real area, vol; /*area for F_AREA, vol for C_VOLUME*/ face_t f; begin_f_loop(f, thread) /* I understand that f_loop macro need to be set on face only*/ { F_CENTROID(x,f,thread); /*this will keep centroid coordinates of each cell*/ area=F_AREA(A,f,thread);/*this did not work/* vol=C_VOLUME(c,thread);/*this either*/ /*of course, according to used macros (area or vol) the variables will differ/* F_PROFILE(f, thread, position)= (area/0.8)*10; /* area  cell area [m], 0.8  area of the whole inlet surface [m], 10  desired magnitude of the mass flow The idea is that e.g. we have 200 cells on that BC surface desired magnitude = desired magnitude */ } end_f_loop(f, thread) } Regards.
__________________
******************************* 

July 1, 2010, 06:15 

#2 
Senior Member
Dragos
Join Date: Mar 2009
Posts: 649
Rep Power: 13 
Code:
#include "udf.h" DEFINE_PROFILE(xyz, thread, position) { real A[ND_ND]; real area; /*area for F_AREA*/ face_t f; begin_f_loop(f, thread) { F_AREA(A,f,thread); area = NV_MAG(A); F_PROFILE(f, thread, position)= (area/0.8)*10; /* area  cell area [m], 0.8  area of the whole inlet surface [m], 10  desired magnitude of the mass flow The idea is that e.g. we have 200 cells on that BC surface desired magnitude = desired magnitude */ } end_f_loop(f, thread) } 

July 2, 2010, 02:22 

#3 
New Member
Luk
Join Date: Jun 2009
Posts: 24
Rep Power: 10 
Thank you dmoroian very much for you attention and help.
I have put your code into my case, but unfortunatelly the results are not desired one. I will prepare 4cell face and thoroughly test it. Perhaps this fixed magnitude 0.8 is a problem. Maybe you or someone else could help or advice me in another matter. These two codes (mass flow and this one) will be eventually in one code. I have prepared code: Code:
#include "udf.h" DEFINE_PROFILE(inlet_x_velocity, thread, position) { real x[ND_ND]; face_t f; begin_f_loop(f, thread) { F_CENTROID(x, f, thread); if (x[1]<x[0] && x[0]<x[1]) { F_PROFILE(f, thread, position)= 10.; /* mass flow = magnitude related to area of all cells, for now is fixed*/ /*} else { F_PROFILE(f, thread, position)= 0; /* mass flow = 0 */ /*} end_f_loop(f, thread) }} And now I would like to set it on transient case. The obstacles or openings are rotating around the center. Code:
#include "udf.h" DEFINE_PROFILE(inlet_x_velocity, thread, position) { real x[ND_ND]; real t=CURRENT_TIME; double angle,angle2,sinangle,cosangle; face_t f; begin_f_loop(f, thread) { angle=6*t; /* assumption: each second > 6 grad of rotation*/ angle2=angle+90 sinangle=sin(angle2); cosangle=cos(angle); F_CENTROID(x, f, thread); /* 0.5 > radius */ if (x[1]<0.5*cosangle && x[0]<0.5*sinangle) { F_PROFILE(f, thread, position)= 10; /* mass flow = magnitude related to area of all cells, for now is fixed */ } else { F_PROFILE(f, thread, position)= 0; /* mass flow = 0 */ } end_f_loop(f, thread) }} Maybe someone created something like that and could provide me with the code or help me to understand the C++ syntax in that case? I assume there will be loop in the loop. Regards
__________________
******************************* 

July 2, 2010, 02:52 

#4 
Senior Member
Dragos
Join Date: Mar 2009
Posts: 649
Rep Power: 13 
My point with "this should be a workable udf" was that is clean and you should start from here, not use it as it is.
One thing that you have to modify is the hardcoded value of the total area. This should be computed using a loop over all faces: Code:
... float totalArea = 0; begin_f_loop(f, thread) { F_AREA(A,f,thread); totalArea += NV_MAG(A); } end_f_loop(f, thread) ... 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Cells with t below lower limit  Purushothama  Siemens  2  May 31, 2010 21:58 
BlockMeshmergePatchPairs  hjasak  OpenFOAM Native Meshers: blockMesh  11  August 15, 2008 07:36 
fluent add additional zones for the mesh file  SSL  FLUENT  2  January 26, 2008 12:55 
Trimmed cell and embedded refinement mesh conversion issues  michele  OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ...  2  July 15, 2005 04:15 
Warning 097  AB  Siemens  6  November 15, 2004 05:41 