|
[Sponsors] |
February 6, 2016, 06:28 |
VOF Diffusion UDF
|
#1 |
New Member
Join Date: Nov 2015
Posts: 5
Rep Power: 11 |
Hi,
I'm trying to simulate the coagulation process of a fiber – consisting of PAN, DMSO and H2O – in water. I let Fluent take care of the inner diffusion and implement a UDF for the diffusion between the two phases (fiber and bath/water). Note that the x-axis is the center of the straight fiber, starting at 0. I only implement one fourth of the fiber for symmetry reasons. Y- and z-values are all positive. To do this, first, I identify the face-thread that holds all the faces creating the boundary between the two phases. This happens inside the INIT-function. My thought is that all the faces should have the distance to the x-axis equal to the fiber radius. Cross section of the fiber is the y,z-plane and the center of it is y=0, z=0, so I simply use Pythagoras for that. The coordinates are not exact so that my condition for all the face centers is: R-dr < r <R+dr R is the fixed radius of the fiber, r is the distance of the face-center to the x-axis and dr is a tolerance to make up for little errors, e.g. rounding errors and the circle being approximated by a polygon (the edges of the faces). The code looks like this: Code:
thread_loop_f(local_thread, my_domain) { /* loop over all faces of current thread */ begin_f_loop(f, local_thread) { F_CENTROID(x, f, local_thread); r = sqrt(1e12*x[1]*x[1] + 1e12*x[2]*x[2]) * 1e-6; /* all faces must be part of the boundary between bath and fiber */ if(r <= radius_fiber-delta_r || r >= radius_fiber+delta_r) { boolean = 1; } if(boolean==1) { break; } } end_f_loop(f, local_thread) /* face_thread was found */ if(boolean==0) { face_thread = local_thread; break; } boolean = 0; } Code:
cell_t cell1, cell2; face_t f; begin_f_loop(f, face_thread) { cell1=F_C0(f, face_thread); cell2=F_C1(f, face_thread); … // diffusion process } Code:
printf(“cell1=%d, cell=%d\n”, cell1, cell1); Code:
w_bath_dmso=C_YI(cell1, thread_bath, 0); So basically, all values assigned to the cells and faces are wrong. What is strange is that it still seems to work for the INIT-function (at least I think it does), because it assigns face_thread the right one. The number of faces is right, at least. This is driving me crazy. Do you have an idea how to fix this? Thanks in advance! |
|
February 6, 2016, 19:00 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
I'm assuming you're running in parallel; the first thing to try is running the simulation in serial mode. How are you handling this global variable face_thread? Perhaps if this variable isn't shared on all compute nodes then the wrong thread is being called (giving garbage numbers).
From looking at your mesh, it appears there are three cell zones and the interface between two of these zones are of interest. Interfaces between cell zones have two face boundaries by default (one from each side). The face thread ID for these boundaries are available under Define > Boundary Conditions... > ID (manual process within the GUI, you could reconfigure your UDF for finding both face threads if you wanted). These faces can be merged from Mesh > Merge... and then you'd have one interior boundary (which you may already have) which you can find the face thread ID the same as before. It might be a typo, but you've printed the same cell thread for "cell1" and "cell" with your printf function. |
|
February 11, 2016, 12:51 |
|
#3 |
New Member
Join Date: Nov 2015
Posts: 5
Rep Power: 11 |
Hi,
thanks for your reply!. I'm running the simulation in serial, as parallel gives me a segmentation fault. There are indeed three cell zones (Bath, Fiber, Jet). I did have an interior between fiber and bath but I set as moving wall, creating an interior-bath-fiber-shadow which I set as moving wall as well. Could this somehow affect my UDF? Thank you for your help! Kind regards, CES |
|
February 12, 2016, 00:27 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Interior faces have cells on either side and using both F_C0 and F_C1 makes sense to gather the cell index of each cell. However, if you have a face on the boundary of the domain (or connected to a shadow boundary) then only one adjacent cell exists (accessible with F_C0).
Try removing the second cell line of code (copied below) and check that one side of your diffusion process is working correctly. Code:
cell2=F_C1(f, face_thread); |
|
February 14, 2016, 12:24 |
|
#5 |
New Member
Join Date: Nov 2015
Posts: 5
Rep Power: 11 |
Sadly this doesn't work either.
I've got another strange problem which might be related to this. Somehow I do have water in my fiber phase, even though my boundary conditions are only set to inject PAN and DMSO. I do want water to diffuse from the bath into the fiber, but this happens even if diffusion is off. Might I have missed something in the setup? I set linearized mass transfer to off. Is there something else I need to do in order to make the UDF work? Thanks for your help! Kind regards, CES |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
UDF for BCs in VOF model | CLINT_E | FLUENT | 4 | October 5, 2011 15:54 |
error because of UDF or VOF ???? | nishith | Fluent UDF and Scheme Programming | 0 | April 21, 2010 07:23 |
writing UDF for modelig mass transfer for VOF | ardalan soleymani | FLUENT | 0 | July 11, 2007 02:09 |
UDF for VOF | mikhail | FLUENT | 2 | October 17, 2000 23:38 |