|
[Sponsors] |
November 4, 2016, 21:28 |
when to use UDF (UDF v UDS)
|
#1 |
Senior Member
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18 |
Hi folks,
I have a question that might be a little general. When should we use UDM? and why we should use it if we can relate everything to UDS in the code? What is the advantage of UDM other than postprocessing some desired variables? |
|
November 7, 2016, 17:22 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
User-defined functions (UDF) are functions that can be loaded with the Fluent solver to customise or add features to the program; UDF are written in both cases of user-defined memory (UDM) and user-defined scalars (UDS).
UDM allocates an extra space in memory (real data type) for each cell and face (or alternatively nodes). UDM could be used to store time-averaged temperature or mass fluxes on boundaries which could be used to alter boundary conditions mid-simulation (or ignored; and used exclusively for postproccessing). UDS are for adding another transport equation to your model. For example, instead of using the energy equation for tracking the temperature field, you could use a UDS. Likewise a reacting species could interact with the default transport equations via their source terms. |
|
November 7, 2016, 17:39 |
|
#3 |
Senior Member
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18 |
Thanks for the reply.
I have written a UDF code for two transport equations(basically I would like to recreate the SST turbulence model). The code is compiled successfully but upon starting the simulation it says that there is a segmentation violation error and for that reason solver crashes. I did a little bit of research and found that it could be attributed to some variables or parameters whose value is not stored and some people suggested that I better use UDM but honestly I do not know what should I do and that is why I asked this question in the first place. Shall I store the value of the transported quantities in a UDM? or it is automatically stored since I have defined UDS? and if yes then what could be the reason I get that error? I would be happy to post my code here for you to take a brief look at it in case you have time? Thank you so much again. Ali |
|
November 7, 2016, 18:17 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
The values should be available from the UDS with the F_UDSI macro. Sure, post your code and we'll take a look.
|
|
November 7, 2016, 18:38 |
|
#5 |
Senior Member
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18 |
Thanks.
The UDF is attached here. I would really appreciate it if you can take a look at it. I have used C_UDSI since I assumed they would be cell values not face values. There are somethings that I wanted to share with you about the UDF. I have used DEFINE_ADJUST for modifying the laminar viscosity and the effect of eddy viscosity is added to laminar viscosity in this section of the code. I did it this way since C_MU_T apparently is not a write-in parameter but I can adjust C_MU_L anytime. Also since I will uncheck turbulence in flow solution controls>equations>turbulence, I figured even if I use DEFINE_TURBULENT_VISCOSITY the solver would not find the viscosity through this. So the 0.001003 value that you see in DEFINE_ADJUST is the laminar viscosity of the fluid. The UDF file is attached. Please find the attachment. Thanks again for you help in advance. Ali |
|
November 7, 2016, 19:10 |
|
#6 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Use trailing periods on integers to avoid erroneous type casts:
Code:
#define ALPHA1 5./9. #define ALPHA2 0.44 #define BETA1 3./40. #define BETA2 0.0828 The code generally looks good and no obvious errors, are you sure you've allocated two UDS in Fluent? Otherwise, try finding the location of the error by eliminating lines of code and/or using Message() to print to the screen every few lines to determine how far Fluent has reached through your code. |
|
November 7, 2016, 21:35 |
|
#7 |
Senior Member
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18 |
Thanks.
I tried adding periods. It did not solve the issue. |
|
November 8, 2016, 01:46 |
|
#8 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Adding periods for the real data types would only help evaluating the fractions correctly (5/9 = 0.555... instead of truncating to zero). Have you tried my other suggestions?
|
|
November 8, 2016, 12:47 |
|
#9 |
Senior Member
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18 |
I am trying to put messages in between the lines but it gives me this message
error: conflicting types for CX_Message my command for inputting message is: Message("1"); Is this wrong? |
|
November 8, 2016, 13:37 |
|
#10 |
Senior Member
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18 |
One question, If the first Macro I use is DEFINE_SOURCE and in that I am using a value stored in a UDM, shall I bring the DEFINE_ADJUST macro before source macro?(the parameter value is assigned to UDM in the DEFINE_ADJUST macro)
Thanks, Ali |
|
November 9, 2016, 04:26 |
|
#11 | |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Quote:
The order of the Fluent macros in your UDF is not important, Fluent calls these functions at particular hooks in the solver. DEFINE_ADJUST is called at the beginning of each iteration whereas DEFINE_SOURCE is called for the transport equations. |
||
December 9, 2016, 17:36 |
segmentation fault error from thread_loop_c (t,domain)
|
#12 |
Senior Member
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18 |
Hi again,
apparently this line is creating the problem: thread_loop_c (t,domain) I get segmentation fault error from this line. Any idea? Thanks, Ali |
|
December 9, 2016, 20:23 |
|
#13 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Duplicate post, responses are at: Error: received a fatal signal (Segmentation fault). Error Object: #f
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDS or UDF for modify shear stress equations..? | aeroprince1986 | Fluent UDF and Scheme Programming | 0 | April 14, 2015 05:16 |
UDF diffusivity (strain rate)-UDS | Lilly | Fluent UDF and Scheme Programming | 0 | September 6, 2013 03:47 |
UDS & UDF | geg | FLUENT | 0 | May 25, 2006 13:06 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |
UDF: different diffusivities for different uds | Elmar Riesmeier | FLUENT | 1 | May 6, 2001 20:53 |