CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF in Differential form (https://www.cfd-online.com/Forums/fluent-udf/49259-udf-differential-form.html)

Chin Fook September 14, 2008 22:35

UDF in Differential form
 
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.

Javier Larrondo September 15, 2008 21:55

Re: UDF in Differential form
 
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

chinc September 16, 2008 02:08

Re: UDF in Differential form
 
Hi Javier,

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

Chin Fook September 22, 2008 01:43

Re: UDF in Differential form
 
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) } }

Javier Larrondo September 22, 2008 05:25

Re: UDF in Differential form
 
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

ChinFook October 7, 2008 01:25

Re: UDF in Differential form
 
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.

Javier Larrondo October 7, 2008 03:11

Re: UDF in Differential form
 
Tell me all the steps that you did to load the UDF?


ChinFook October 7, 2008 03:41

Re: UDF in Differential form
 
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.

Javier Larrondo October 7, 2008 06:35

Re: UDF in Differential form
 
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


Rami October 15, 2008 09:25

Re: UDF in Differential form
 
Maybe the arguments to SQR become negative?

mila_oliv July 27, 2012 13:48

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!

;)


All times are GMT -4. The time now is 01:48.