CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Multiphase mass transfer udf

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

Like Tree3Likes
  • 1 Post By deada
  • 2 Post By deada

LinkBack Thread Tools Search this Thread Display Modes
Old   March 20, 2017, 11:47
Default Multiphase mass transfer udf
New Member
Join Date: Jun 2016
Posts: 9
Rep Power: 7
deada is on a distinguished road

I want to run a eulerian multiphase simulation with a primary (p1) and two secondary phases (s1 and s2). In every cell of my domain, where the strain rate of secondary phase s1 exceeds a certain threshold mass shall be transferred from s1 to s2. From what I read in the fluent theory guid the best way to realize that is to use DEFINE_LINEARIZED_MASS_TRANSFER() or DEFINE_MASS_TRANSFER(). (btw. I'm using fluent 16.2 right now)

Since this is the first time I am dealing with an udf, the right usage and implementation is unknown to me. Here is a first udf, that I tried to compile in fluent:

#include "udf.h"


real strain_rate_mag = C_STRAIN_RATE_MAG(cell,thread);
real strain_rate_thresh = 100;

Thread *s1 = THREAD_SUB_THREAD(thread, from_index);
Thread *s2 = THREAD_SUB_THREAD(thread, to_index);
real vof_L = C_VOF(cell,s1);
real vof_S = C_VOF(cell,s2);

real m_dot, dstrain, m_source;
m_dot = 0.0;
m_source = 0.0;

if (strain_rate_mag > strain_rate_thresh)
    dstrain = strain_rate_mag - strain_rate_thresh;
    dstrain = MAX(dstrain, 1e-4);
    m_dot = 0.1;
    m_source = m_dot*vof_L;
    *d_mdot_d_vof_from = m_dot;
    *d_mdot_d_vof_to = -m_dot;

return m_source;
There are some lines in the code which I don't really understand by now and it also doesn't compile. So here are my questions:

1.) I read that cell and thread are given to the define macro by the solver. Do I still somehow have to define them before? How does it know the right thread? And does it automatically loop over all cells or do i have to but the macro inside a loop of some kind?

2.) I only want mass being transfered from s1 which has the ID 3 to s2 with the ID 4 and my secondary phases are not made up of multiple species. How do I tell that to the udf? Before the DEFINE_LINEARIZED_MASS_TRANSFER() line, should I include something like:
int from_index,from_species_index,to_index,to_species_index;
eg. I assume the line Thread *s1 = THREAD_SUB_THREAD(thread, from_index); to take the mixture thread pointer and give me a pointer to the first secondary phase. But therefore I need to it the ID of s1 somehow, don't I?

3.) When I click on build in the Compiled UDFs window I get the following text line feedback:
udf_names.c and user_nt.udf files in 3ddp are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\v162\fluent"\fluent16.2.0\src\udf\makefile_nt.udf "libsel\win64\3ddp\makefile" ")
        1 file(s) copied.
(chdir "libsel")(chdir "win64\3ddp")# Generating ud_io1.h
# Generating udf_names.c because of strain_source.obj
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj strain_source.obj
Microsoft (R) Incremental Linker Version 14.10.25017.0
Copyright (C) Microsoft Corporation.  All rights reserved.

   Bibliothek "libudf.lib" and Objekt "libudf.exp" are created.
strain_source.obj : error LNK2019: Reference to non-resolved external symbol "__imp__store_vof_norm" in function "_strain_source".
C:\PROGRA~1\ANSYSI~1\v162\fluent\fluent16.2.0\win64\3ddp\fl1620.lib : warning LNK4272:library computer type "x64" in conflict with destination computer type "X86"
libudf.dll : fatal error LNK1120: 1 non-resolved external
What confuses me about that feedback is that it states that the destination computer type is X86 but I'm using an x64. Furthermore, I don't know what "__imp__store_vof_norm" is.

Hints and help to any of my questions is highly appreciated!
Thanks, Thies

Last edited by deada; March 27, 2017 at 08:16.
deada is offline   Reply With Quote

Old   March 23, 2017, 09:29
New Member
Join Date: Jun 2016
Posts: 9
Rep Power: 7
deada is on a distinguished road
A little update:
I have solved the question 3 (the x86 vs x64 issue) by following the instructions given here:
I had to install the more recent Windows SDK instead of the .NET Framework 2.0 as suggested in the wiki and added the path C:\Program Files\Microsoft SDKs\Windows\v7.0\Include to the enviroment variables. Now I am able to compile the udf without any errors. However when I run the case without including mass transfer, everything is fine. But as soon as I activate it I get an segmentation fault. When I activated the mass transfer I also learned that I set the from_index and to_index manually in the GUI so I think question 2 is also solved.

But I still do not have an idea what causes the segmentation fault and if my udf does what I intend it to do
Error:  received a fatal signal (Segmentation fault).

Error:  received a fatal signal (Segmentation fault).
Error Object: #f
RenterCFD likes this.
deada is offline   Reply With Quote

Old   March 27, 2017, 08:17
New Member
Join Date: Jun 2016
Posts: 9
Rep Power: 7
deada is on a distinguished road
Hi again,
by stepwise shortening of my .c file i found that the segmentation fault originated from the first line
real strain_rate_mag = C_STRAIN_RATE_MAG(cell,thread)
because I needed to use a subthread to thread as an input. Changing it to s1 and moving it below the THREAD_SUB_THREAD command solved the problem
Dri and RenterCFD like this.
deada is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
mass flow in is not equal to mass flow out saii CFX 12 March 19, 2018 05:21
Accessing phase interaction mass transfer rate in UDF ahmadimo Fluent UDF and Scheme Programming 0 July 29, 2014 12:54
Eulerian-Granular Mass transfer UDF problem therandomestname FLUENT 1 April 25, 2011 17:58
writing UDF for modelig mass transfer for VOF ardalan soleymani FLUENT 0 July 11, 2007 01:09
Multiphase flow with mass transfer? A. Ataki FLUENT 1 November 10, 2003 04:46

All times are GMT -4. The time now is 19:35.