CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

VOF Diffusion UDF

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

Reply
 
LinkBack Thread Tools Display Modes
Old   February 6, 2016, 06:28
Default VOF Diffusion UDF
  #1
CES
New Member
 
Join Date: Nov 2015
Posts: 5
Rep Power: 3
CES is on a distinguished road
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;
	}
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;
	begin_f_loop(f, face_thread)
	{
		cell1=F_C0(f, face_thread);
		cell2=F_C1(f, face_thread);
		… // 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?

Thanks in advance!
Attached Images
File Type: jpg fig1.jpg (27.2 KB, 5 views)
File Type: jpg fig2.jpg (38.9 KB, 5 views)
File Type: jpg fig3.jpg (56.8 KB, 4 views)
File Type: jpg fig4.jpg (174.9 KB, 5 views)
CES is offline   Reply With Quote

Old   February 6, 2016, 19:00
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 793
Rep Power: 9
`e` is on a distinguished road
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.
`e` is offline   Reply With Quote

Old   February 11, 2016, 12:51
Default
  #3
CES
New Member
 
Join Date: Nov 2015
Posts: 5
Rep Power: 3
CES is on a distinguished road
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
CES is offline   Reply With Quote

Old   February 12, 2016, 00:27
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 793
Rep Power: 9
`e` is on a distinguished road
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);
`e` is offline   Reply With Quote

Old   February 14, 2016, 12:24
Default
  #5
CES
New Member
 
Join Date: Nov 2015
Posts: 5
Rep Power: 3
CES is on a distinguished road
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
Attached Images
File Type: jpg 2.jpg (64.4 KB, 4 views)
CES is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
UDF for BCs in VOF model CLINT_E FLUENT 4 October 5, 2011 14:54
error because of UDF or VOF ???? nishith Fluent UDF and Scheme Programming 0 April 21, 2010 06:23
writing UDF for modelig mass transfer for VOF ardalan soleymani FLUENT 0 July 11, 2007 01:09
UDF for VOF mikhail FLUENT 2 October 17, 2000 22:38


All times are GMT -4. The time now is 10:51.