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

deviation and Gradients

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By blackmask

Reply
 
LinkBack Thread Tools Display Modes
Old   August 5, 2013, 16:22
Default deviation and Gradients
  #1
Member
 
Stephan Langenberg
Join Date: Sep 2011
Location: Germany
Posts: 73
Rep Power: 5
Jim87 is on a distinguished road
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
Attached Images
File Type: jpg formel_pvT.JPG (52.8 KB, 8 views)
Jim87 is offline   Reply With Quote

Old   August 7, 2013, 08:18
Default
  #2
Member
 
Stephan Langenberg
Join Date: Sep 2011
Location: Germany
Posts: 73
Rep Power: 5
Jim87 is on a distinguished road
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.
Jim87 is offline   Reply With Quote

Old   August 8, 2013, 07:42
Default
  #3
Senior Member
 
Join Date: Aug 2011
Posts: 315
Rep Power: 11
blackmask will become famous soon enough
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 likes this.
blackmask is offline   Reply With Quote

Old   August 9, 2013, 06:44
Default
  #4
Member
 
Stephan Langenberg
Join Date: Sep 2011
Location: Germany
Posts: 73
Rep Power: 5
Jim87 is on a distinguished road
thank you. This one line fixed the UDF.
Jim87 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 23:06.