|
[Sponsors] |
![]() |
![]() |
#1 |
Member
Stephan Langenberg
Join Date: Sep 2011
Location: Germany
Posts: 73
Rep Power: 15 ![]() |
Hi,
In order to realize an equation (attached) I need to catch up some deviations (pressure Gradient and temperature Gradient). - What is the best way to include deviations in a UDF? Should I use the Gradient Macro or is there a better way to use deviations? - In my opinion I need a pointer on the deviations, are these pointer identic with the Macro-NAme (for examplecan I use C_P_G as pointer and function variable for the pressure deviation?) - As a hint for me, Might this work? A= B*pressure' ....... double A 0.0; double B 0.0; //variables pressure' = C_P_G(c,t); ....... Greetings, Jim |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Member
Stephan Langenberg
Join Date: Sep 2011
Location: Germany
Posts: 73
Rep Power: 15 ![]() |
I tried a small UDF (only to catch up the gradient of temperature und build an equation with it)
I think I have to add something or activate a hook in the solver system, but I don't get the problem fixed. Tried #include "mem.h", but this seems not to be the missing step. Can someone please give my a feedback? #include "udf.h" DEFINE_PROPERTY(test_Gradienten,c,t) { /************************************************** ************************** Standard UDF Befehle ************************************************** ***************************/ double Rho = 0.0; double gradient = 0.0; double s1 = 5; /************************************************** ************************** Variablen aufrufen ************************************************** ***************************/ gradient = C_T_G(c,t)[1]; /************************************************** ************************* Zeiger Druck und Temperatur ************************************************** ***************************/ Rho = 1 + gradient * s1; return Rho; } C:\PROGRA~1\ANSYSI~1\v145\fluent\fluent14.5.0\win6 4\3ddp\fl1450s.exe received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
|
Ensure that the pointer is not null. The macro might be invoked before the temperate gradient is calculated.
Code:
#include "udf.h" DEFINE_PROPERTY(test_Gradienten,c,t) { /************************************************** ************************** Standard UDF Befehle ************************************************** ***************************/ double Rho = 0.0; double gradient = 0.0; double s1 = 5; /************************************************** ************************** Variablen aufrufen ************************************************** ***************************/ if (NNULLP(THREAD_STORAGE(t, SV_T_G))) gradient = C_T_G(c,t)[1]; /************************************************** ************************* Zeiger Druck und Temperatur ************************************************** ***************************/ Rho = 1 + gradient * s1; return Rho; } |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Member
Stephan Langenberg
Join Date: Sep 2011
Location: Germany
Posts: 73
Rep Power: 15 ![]() |
thank you. This one line fixed the UDF.
|
|
![]() |
![]() |
![]() |
|
|