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

UDF in Differential form

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

Like Tree1Likes
  • 1 Post By Javier Larrondo

Reply
 
LinkBack Thread Tools Display Modes
Old   September 14, 2008, 22:35
Default UDF in Differential form
  #1
Chin Fook
Guest
 
Posts: n/a
Dear All,

Appreciate if you could help me with this:

I am running a 2D steady state heat transfer simulation. At the end of the simulation, I intend to incorporate an UDF capable of calculating at each cell the value of the following differential equation: p(i,j)=a*[(dT/dx)^2+dT/dy)^2].

In this case, I am not sure which Macro is to be used and how to code the above formula in differential form to calculate the desired p(i,j) at each cell.

Thanks in advance for your commend.
  Reply With Quote

Old   September 15, 2008, 21:55
Default Re: UDF in Differential form
  #2
Javier Larrondo
Guest
 
Posts: n/a
You can use a UDM value to store p(i,j) in each cell. And use the DEFINE_ON_DEMAND macro to do the calculation for you.

DEFINE_ON_DEMAND(calc_eq) {

Domain *d;

Thread *t;

cell_t c;

d = Get_Domain(1);

thread_loop_c(t,d)

{

begin_c_loop(c,t)

{

C_UDMI(c,t,0)=a*(SQR(C_T_G(c,t)[0])+SQR(C_T_G(c,t)[1]);

}

end_c_loop(c,t)

} }

Practically that's it. Hope it works, I didn't run it to check if it working. Cheers, Javier
mdakbari likes this.
  Reply With Quote

Old   September 16, 2008, 02:08
Default Re: UDF in Differential form
  #3
chinc
Guest
 
Posts: n/a
Hi Javier,

I will try that up later. Thanks and I really appreciate your help.
  Reply With Quote

Old   September 22, 2008, 01:43
Default Re: UDF in Differential form
  #4
Chin Fook
Guest
 
Posts: n/a
Hi Javier,

I amended the above UDF and it compiled perfectly. However, unfortunately upon execution i received the following fatal error:

Error: FLUENT 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. Error Object: ()

Any idea why this happened? Appreciate your comment.

/*================================================= =======*/ #include "udf.h"

DEFINE_ON_DEMAND(calc_eq)

{ Domain *d; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */

real a = 24; Thread *t; cell_t c; d = Get_Domain(1); /* Get the domain using Fluent utility */

thread_loop_c(t,d)

{ begin_c_loop(c,t)

{

C_UDMI(c,t,0)=SQR(C_T_G(c,t)[0])+SQR(C_T_G(c,t)[1]);

}

end_c_loop(c,t) } }
  Reply With Quote

Old   September 22, 2008, 05:25
Default Re: UDF in Differential form
  #5
Javier Larrondo
Guest
 
Posts: n/a
Sometimes this happens when the User Defined Scalars or Memories are not created. Go to the following Panel: Define > User Defined> Memory And create 1 UDM. Then you can use your UDF. Cheers, Javier
  Reply With Quote

Old   October 7, 2008, 01:25
Default Re: UDF in Differential form
  #6
ChinFook
Guest
 
Posts: n/a
Hi Javier,

Thanks for your previous postings. I have finally got the visual Studio. NET 2003 installed and managed to compile the UDF. Even the library is succesfully created. I was happy for a few seconds that when I later try to execute the UDF (EXECUTE ON DEMAND), I obtained the following error prompt:

Error: FLUENT 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. Error Object: ()

Any idea why am I getting this message? Thanks in advance for your comment.
  Reply With Quote

Old   October 7, 2008, 03:11
Default Re: UDF in Differential form
  #7
Javier Larrondo
Guest
 
Posts: n/a
Tell me all the steps that you did to load the UDF?

  Reply With Quote

Old   October 7, 2008, 03:41
Default Re: UDF in Differential form
  #8
ChinFook
Guest
 
Posts: n/a
The followings are the steps involved:

1. Set the environment variables. 2. Execute fluent.exe (2D) from Microsoft Visual Studio. NET 's Command Prompt. 3. Load the case and data of of simulation (2D convection, lam, steady) 4. Compile the UDM. (the compilation result seems perfect) 5. Perform Execute on Demand of the UDM and that it is that I was prompt the error message.

BTW, i am running Fluent from a server. Will that be a problem?

Even when I try using the supplied UDF (taken under UDF helP)things doesn't work out. I wonder if it is problem with the memory location.

Another question, will the results of UDF be made available under the post processing panel after the execution that as usual we can plot its contour?

Many thanks.
  Reply With Quote

Old   October 7, 2008, 06:35
Default Re: UDF in Differential form
  #9
Javier Larrondo
Guest
 
Posts: n/a
Did you add the extra User Defined Memory??

Go to the following Menu:

Define > User-Defined > Memory

Add one User-Defined Memory

And then run your execute on demand.

Also if the gradients doesn't give a value, go to the TUI and type

solve/set/expert and when Fluent ask for:

Keep temporary solver memory from being freed? type yes.

Finally, you can access the values of your new User-defined memory from any contour, vector, pathline...etc panel.

Good luck,

Javier

  Reply With Quote

Old   October 15, 2008, 09:25
Default Re: UDF in Differential form
  #10
Rami
Guest
 
Posts: n/a
Maybe the arguments to SQR become negative?
  Reply With Quote

Old   July 27, 2012, 13:48
Default
  #11
New Member
 
Join Date: Jul 2012
Posts: 18
Rep Power: 4
mila_oliv is on a distinguished road
hey guys,

it's been a wuile since you two wrote all this, but i'm trying to do something similar and i know that the problem is related to the gradient, but i don't know how to fix it...
if you have some idea, please let me know!

mila_oliv 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get differential of variable Ri CD-adapco 0 July 8, 2006 21:34
Finite Differential Method example (help!!) Anne NUMECA 1 January 1, 2006 11:02
Finite Differential Method example (help!!) Anne FLUENT 0 December 17, 2005 05:40
Differential eq. Viktor Bessonov Main CFD Forum 14 January 31, 2005 05:21
differential pressure UDF Phil Main CFD Forum 1 August 20, 2004 10:10


All times are GMT -4. The time now is 13:58.