# VOF Diffusion UDF

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

February 6, 2016, 06:28
VOF Diffusion UDF
#1
New Member

Join Date: Nov 2015
Posts: 5
Rep Power: 3
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 */
{
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 */
boolean = 1;
}
if(boolean==1) { break; }
}
if(boolean==0) {
break;
}
boolean = 0;
}```
The thread is saved in the global variable face_thread and then used in the MASS_TRANSFER-function. There I use the F_C0 and F_C1 commands to access the cells of both sides of the faces and compute the diffusion. In addition, I identify the cell-threads containing the cells of the fiber and the bath and store them in the global variables thread_bath and thread_fiber (that seems to work fine). This is the code for MASS_TRANSFER:

Code:
```cell_t cell1, cell2;
face_t f;
{
… // diffusion process
}```
By using

Code:
`printf(“cell1=%d, cell=%d\n”, cell1, cell1);`
I get IDs for the cells that make sense (e.g. 300 to 360). The problem starts after that whenever I try to do the diffusion. I start by assigning the values of the cells to self-made variables, e.g.

Code:
`w_bath_dmso=C_YI(cell1, thread_bath, 0);`
I made sure that the index 0 is the right one. However, if I try to look at the value by using a similar printf-command, I get some random values, ranging from 0 to some million or even less than zero although the mass fraction values should be something between 0 and 1. Since this problem occurred while initializing, I thought maybe the values are not assigned yet, but even if I check the coordinates, they have some random values assigned to them. Some of them even have negative values for y and z despite there being no negative coordinates in these directions inside the geometry. Even in the INIT-function when I compute the distance of a face to the x-axis, I get values that don’t make any sense.

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?

Attached Images
 fig1.jpg (27.2 KB, 5 views) fig2.jpg (38.9 KB, 5 views) fig3.jpg (56.8 KB, 4 views) fig4.jpg (174.9 KB, 5 views)

 February 6, 2016, 19:00 #2 Senior Member   Join Date: Mar 2015 Posts: 800 Rep Power: 11 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: 3 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: 800 Rep Power: 11 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: 3
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?

Kind regards,

CES
Attached Images
 2.jpg (64.4 KB, 4 views)

 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 Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20 CLINT_E FLUENT 4 October 5, 2011 14:54 nishith Fluent UDF and Scheme Programming 0 April 21, 2010 06:23 ardalan soleymani FLUENT 0 July 11, 2007 01:09 mikhail FLUENT 2 October 17, 2000 22:38

All times are GMT -4. The time now is 16:12.