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

F_FLUX macro creating error in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 5, 2016, 16:45
Default F_FLUX macro creating error in UDF
  #1
New Member
 
Sean Babiniec
Join Date: Apr 2016
Posts: 4
Rep Power: 10
seanbabs is on a distinguished road
Hello everybody,
First post here, but been using the forum as an information mine for a while now. Thank you all for your helpful posts; they have been very useful.

However, I've come across a problem that I cannot solve by mere google-fu.

I am attempting to execute a c_face_loop within a DEFINE_SOURCE algorithm to get the total mass flow rate in each cell.

The part of the UDF that is giving me trouble is as follows:

int face;
int numf;
real massflow;
real summassflow;
float count = 0.0

c_face_loop(cell, thread, numf)
{
face = C_FACE(cell, thread, numf);
summassflow += -F_FLUX(face,thread);
count += 1.0;
}
massflow = summassflow / count;

When I run this, I get the dreaded fatal signal. However, if I replace F_FLUX with any other face macro, such as F_V, the code runs, although it obviously doesn't give the correct answer.

I am using the pressure-based solver.
Has anybody run across something similar where F_FLUX creates issues? Does anybody have any ideas to get around this?

Thanks in advance for your help.

Sean
seanbabs is offline   Reply With Quote

Old   April 5, 2016, 18:20
Default
  #2
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
Quote:
Originally Posted by seanbabs View Post
Hello everybody,
First post here, but been using the forum as an information mine for a while now. Thank you all for your helpful posts; they have been very useful.

However, I've come across a problem that I cannot solve by mere google-fu.

I am attempting to execute a c_face_loop within a DEFINE_SOURCE algorithm to get the total mass flow rate in each cell.

The part of the UDF that is giving me trouble is as follows:

int face;
int numf;
real massflow;
real summassflow;
float count = 0.0

c_face_loop(cell, thread, numf)
{
face = C_FACE(cell, thread, numf);
summassflow += -F_FLUX(face,thread);
count += 1.0;
}
massflow = summassflow / count;

When I run this, I get the dreaded fatal signal. However, if I replace F_FLUX with any other face macro, such as F_V, the code runs, although it obviously doesn't give the correct answer.

I am using the pressure-based solver.
Has anybody run across something similar where F_FLUX creates issues? Does anybody have any ideas to get around this?

Thanks in advance for your help.

Sean
The arguments for the F_FLUX(face,thread) is face and face thread. I think instead of using the C_FACE you might have to define it as "face_t face;" so Fluent returns the integers for all the faces.

Have a try and let me know if it worked.
Bruno Machado is offline   Reply With Quote

Old   April 5, 2016, 19:27
Default
  #3
New Member
 
Sean Babiniec
Join Date: Apr 2016
Posts: 4
Rep Power: 10
seanbabs is on a distinguished road
Quote:
Originally Posted by Bruno Machado View Post
The arguments for the F_FLUX(face,thread) is face and face thread. I think instead of using the C_FACE you might have to define it as "face_t face;" so Fluent returns the integers for all the faces.

Have a try and let me know if it worked.
Thanks for the reply! I tried that just now, and it didn't seem to work. I'll mess around with it some more.

The one thing I don't understand is that if I replace F_FLUX with F_V, it works. F_FLUX and F_V appear to take the same arguments, so I don't know why one will run and the other won't. Does this make sense to you?
seanbabs is offline   Reply With Quote

Old   April 6, 2016, 03:38
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
According to the help, F_V is only defined at boundary faces, but F_FLUX is defined at boundary faces and interior faces.

Based on this, I would expect that F_FLUX would work, but that F_V would give the error... Sorry, can't help you there...


Not directly related to your problem: what do you want to achieve with this UDF? It looks like you want to calculate the net mass flow into the cell, but excluding sinks and sources it should be very close to zero in a converged solution.
And this line:
Code:
massflow = summassflow / count;
What? Your variable "summassflow" is the net mass flow into the cell, which at least has a physical meaning. Why would you divide that by the number of faces of the cell?
pakk is offline   Reply With Quote

Old   April 6, 2016, 11:10
Unhappy
  #5
New Member
 
Sean Babiniec
Join Date: Apr 2016
Posts: 4
Rep Power: 10
seanbabs is on a distinguished road
You are right that that bit of code is meaningless. That was a remnant of trying to calculate the mass flow into the cell a different way and I forgot to change it before posting.
What I am trying to do is sum all the mass flow into the cell, so I should make an if statement to only sum the negative components.

This is part of a larger UDF that implements some pseudo-equilibrium kinetics. I've got it to work on transient operation, but due to computational cost I need to get it to work in steady state.

Therefore I was trying to calculate the energy source as such:

Mdot * DH / C_VOLUME

Where DH is in J/kg

Alternatively, I could get the "time" component by calculating the residence time in each cell, but that gets very tricky in 3D with unstructured grids.
seanbabs is offline   Reply With Quote

Old   April 25, 2016, 17:40
Default
  #6
New Member
 
Sean Babiniec
Join Date: Apr 2016
Posts: 4
Rep Power: 10
seanbabs is on a distinguished road
Hello everybody,

I've simplified the code to try to get this to run properly, and still haven't been able to calculate the mass flux through the face of a cell. I get the
segmentation fault error.

Here is my test code:
#include "udf.h"
DEFINE_SOURCE(fluxtest, c, t, dS, eqn)
{
Thread *tf; face_t f;
real flux = 0.;
real source;
int n;


c_face_loop(c, t, n) {
f = C_FACE(c, t, n); tf = C_FACE_THREAD(c, t, n);
flux = F_FLUX(f, tf);
}
printf("%f", flux);
source = 0.0;
dS[eqn] = 0.0;

return source;
}

I am hooking the UDF to an energy source, as eventually that is what I am interested in. Other model specifics are:
-Eulerian multiphase
-Species transport

Any help would be great.
seanbabs is offline   Reply With Quote

Reply

Tags
f_flux, udf error


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
C functions in UDF Macro jacek FLUENT 0 July 1, 2015 08:32
UDF macro not compliled KITetima Fluent UDF and Scheme Programming 12 October 23, 2013 09:13
reading "global" variables in a UDF macro? bawfuls Fluent UDF and Scheme Programming 1 July 1, 2010 21:22
DPM: using UDF for creating and deleting Particles Markus Alzon FLUENT 0 July 4, 2007 01:18
errors in interpreted udf for two macro Asghari FLUENT 0 August 7, 2006 02:29


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