|
[Sponsors] |
April 5, 2016, 17:45 |
F_FLUX macro creating error in UDF
|
#1 |
New Member
Sean Babiniec
Join Date: Apr 2016
Posts: 4
Rep Power: 10 |
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 |
|
April 5, 2016, 19:20 |
|
#2 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
Have a try and let me know if it worked. |
||
April 5, 2016, 20:27 |
|
#3 | |
New Member
Sean Babiniec
Join Date: Apr 2016
Posts: 4
Rep Power: 10 |
Quote:
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? |
||
April 6, 2016, 04:38 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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; |
|
April 6, 2016, 12:10 |
|
#5 |
New Member
Sean Babiniec
Join Date: Apr 2016
Posts: 4
Rep Power: 10 |
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. |
|
April 25, 2016, 18:40 |
|
#6 |
New Member
Sean Babiniec
Join Date: Apr 2016
Posts: 4
Rep Power: 10 |
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. |
|
Tags |
f_flux, udf error |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
C functions in UDF Macro | jacek | FLUENT | 0 | July 1, 2015 09:32 |
UDF macro not compliled | KITetima | Fluent UDF and Scheme Programming | 12 | October 23, 2013 10:13 |
reading "global" variables in a UDF macro? | bawfuls | Fluent UDF and Scheme Programming | 1 | July 1, 2010 22:22 |
DPM: using UDF for creating and deleting Particles | Markus Alzon | FLUENT | 0 | July 4, 2007 02:18 |
errors in interpreted udf for two macro | Asghari | FLUENT | 0 | August 7, 2006 03:29 |