CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   deviation and Gradients (http://www.cfd-online.com/Forums/fluent-udf/121802-deviation-gradients.html)

Jim87 August 5, 2013 16:22

deviation and Gradients
 
1 Attachment(s)
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

Jim87 August 7, 2013 08:18

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.

blackmask August 8, 2013 07:42

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;

}


Jim87 August 9, 2013 06:44

thank you. This one line fixed the UDF.


All times are GMT -4. The time now is 21:03.