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

UDF to Define Species Mass Fraction on Velocity-Inlet

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

Like Tree1Likes
  • 1 Post By MayTheFlowBeWithYou

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 28, 2017, 07:02
Default UDF to Define Species Mass Fraction on Velocity-Inlet
  #1
New Member
 
Michael
Join Date: Jul 2017
Location: Austria
Posts: 2
Rep Power: 0
MiBe is on a distinguished road
Hello everyone,
I have been trying for hours to write a DEFINE_PROFILE UDF which takes the Species Mass Fraction of 4 out of 5 species from boundary-adjacent cells and imposes the same concentration on the boundary. This is to simulate a flow with one wall of a 2d-duct replaced by a velocity-inlet with normal velocity=0. Imposing the concentrations from the steady case as profiles on the boundary does not give the desired results. I have been working with a c_face_loop. Here is my UDF. It compiles and runs, but does not give the desired results. I am thankful for any suggestion!

#include "udf.h"

DEFINE_PROFILE(O2_concentration, thread, position)
{

cell_t c;
Thread *t;
face_t f;
Thread *tf;
int n;

c_face_loop(c,t,n)
{
c0_thread=THREAD_T0(thread);
if(THREAD_TYPE(tf) == THREAD_F_WALL)
{
f = C_FACE(c,t,n);
t = C_FACE_THREAD(c,t,n);
F_PROFILE(f, thread, position) = C_YI(c0,c0_thread,n);
}
}
}
MiBe is offline   Reply With Quote

Old   July 31, 2017, 11:11
Default
  #2
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 8
MayTheFlowBeWithYou is on a distinguished road
I have had the same issue a while back, spend days on it, I'll save you from this. Here is the answer:


#include "udf.h"
#include "mem.h"
#include "metric.h"
#include "sg_mem.h"

/* MODEL FOR OUTLET PROFILES*/

DEFINE_PROFILE(Outlet_UDS, t, i)
{
Thread *t0;
face_t f;
cell_t c, c0;

begin_f_loop(f, t)
{
t0 = THREAD_T0(t);
c0 = F_C0(f, t);

/********** DEFINING PROFILE **********/
F_PROFILE(f, t, i) = C_UDSI(c0, t0, i); /* Lets hope this works. */
}
end_f_loop(f, t)
}


P.S. I know I probably #include too much stuff, I just never cared to optimize.
P.P.S. c_face_loop will loop over all the faces of the cells (in a 2d situation, each cell will have 4 faces). Looping over all 4 faces of each cell of your boundary and then setting the adjacent cell to each of those faces will indeed not give you the desired results. Frankly, I'm amazed it didn't just crash.
P.P.P.S. The last term in DEFINE_PROFILE is not a position, it's an index given by fluent to each UDS.
soheil_r7 likes this.
MayTheFlowBeWithYou is offline   Reply With Quote

Old   August 2, 2017, 12:49
Default
  #3
New Member
 
Michael
Join Date: Jul 2017
Location: Austria
Posts: 2
Rep Power: 0
MiBe is on a distinguished road
Hello,

thank you very much for your detailed explanation and especially for the provided example code. I have been trying to use this function both, as is and with different minor changes, as an input for the species mass fractions on a velocity-inlet. The compiled function can be read, but as soon as I try to impose it as a boundary condition in the velocity-inlet toolbox, I get the error message shown in the screenshot: <received fatal signal (Segmentation fault).>
do you remember how you solved this problem? I have tried

F_PROFILE(f, thread, position) = F_YI(f,thread,i);

but without getting a good result. The velocity magnitude is set to 0, could this cause the problem?

Thank you very much for your help so far!
Michael
Attached Images
File Type: jpg fluent_error.jpg (112.2 KB, 61 views)
MiBe is offline   Reply With Quote

Old   August 3, 2017, 05:36
Default
  #4
Member
 
MayTheFlowBeWithYou's Avatar
 
I have to remain anonymous, I'm sorry.
Join Date: Jun 2017
Location: The Netherlands, Delft University of Technology
Posts: 48
Rep Power: 8
MayTheFlowBeWithYou is on a distinguished road
Well, first of all, the "segmentation error" can be caused by 100's of different things, and practically doesn't tell you much more than "something doesn't work". I have found stupid things like the order in which variables are defined to even cause this sometimes. In my opinion it just shows that ANSYS did a lazy job in the error reporting of Fluent, and thus everything was just shoved under "segmentation error".

My code was intended for when you used a User-Defined Scalar instead of species, perhaps using:

F_PROFILE(f, t, i) = C_YI(c0, t0, i);

instead of

F_PROFILE(f, t, i) = C_UDSI(c0, t0, i);

will make it work for you? What the code is basically trying to do now is to impose the values of the cells next to the boundary upon the faces of the boundary itself. Chapter "1.6. Mesh Terminology" of the Customization guide for Fluent has a nice explanation of the difference between cells, faces and nodes. This might help you in choosing the correct macros in the future as well.

Last edited by MayTheFlowBeWithYou; August 3, 2017 at 08:28.
MayTheFlowBeWithYou is offline   Reply With Quote

Reply

Tags
boundary condition, fluent profile, species, udf, wall

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 fraction of species Lilly FLUENT 5 March 13, 2022 18:52
Multiphase flow - incorrect velocity on inlet Mike_Tom CFX 6 September 29, 2016 02:27
3-D parabolic velocity Inlet - Steady state - UDF Turbulent Flow mohibanwar Fluent UDF and Scheme Programming 10 May 18, 2015 11:34
How to define a mass source at a velocity inlet ? cfdiscool FLUENT 4 June 26, 2014 04:00
Simulation with UDF for species mass fraction and velocity profile virgy Fluent UDF and Scheme Programming 8 February 7, 2012 05:30


All times are GMT -4. The time now is 08:53.